Commit 5715d4b5 authored by jsbell@chromium.org's avatar jsbell@chromium.org

Service Worker: Annotate IDLs with [TypeChecking] to turn it on

We should be doing type checking everywhere, but for back-compat reasons
Blink currently doesn't do "interface" or "unrestricted" enforcement.
Turn it on for all the new SW interfaces (since there's no compat
issue) and to fix a cache where Cache.put()'s second argument went
unchecked.

R=haraken@chromium.org
BUG=426153

Review URL: https://codereview.chromium.org/676563002

git-svn-id: svn://svn.chromium.org/blink/trunk@184295 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent eb8c304e
......@@ -8,9 +8,11 @@ FAIL Cache.put with an empty response body assert_equals: Cache.put should updat
PASS Cache.put with HTTP 500 response
FAIL Cache.put called twice with same Request and different Responses Entry already exists.
FAIL Cache.put with an invalid request assert_promise_rejects: Cache.put should only accept a Request object as the request. Promise did not reject.
PASS Cache.put with an invalid response
FAIL Cache.put with a non-HTTP/HTTPS request assert_promise_rejects: Cache.put should reject non-HTTP/HTTPS requests with a TypeError. Promise did not reject.
FAIL Cache.put with a relative URL assert_equals: Cache.put should accept a relative URL as the request. :[object].url expected "" but got "http://127.0.0.1:8000/serviceworker/resources/relative-url"
FAIL Cache.put with a non-GET request assert_promise_rejects: Cache.put should throw a TypeError for non-GET requests. Promise did not reject.
FAIL Cache.put with a non-GET request assert_promise_rejects: Cache.put should throw a TypeError for non-GET requests. Promise did not reject.
PASS Cache.put with an empty response
Harness: the test ran to completion.
......@@ -160,16 +160,12 @@ cache_test(function(cache) {
'Cache.put should only accept a Request object as the request.');
}, 'Cache.put with an invalid request');
// TODO: This test currently causes a renderer crash. Enable test again once the
// crash is resolved. http://crbug.com/426153
if (false) {
cache_test(function(cache) {
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new_test_request(), 'Hello world!'),
new TypeError(),
'Cache.put should only accept a Response object as the response.');
}, 'Cache.put with an invalid response');
}
cache_test(function(cache) {
return assert_promise_rejects(
......@@ -207,13 +203,9 @@ cache_test(function(cache) {
'Cache.put should throw a TypeError for non-GET requests.');
}, 'Cache.put with a non-GET request');
// TODO: This test currently causes a renderer crash. Enable test again once the
// crash is resolved. http://crbug.com/426153
if (false) {
cache_test(function(cache) {
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new_test_request(), null),
new TypeError(),
'Cache.put should throw a TypeError for an empty response.');
}, 'Cache.put with an empty response');
}
......@@ -9,6 +9,7 @@
NoInterfaceObject,
ActiveDOMObject,
GarbageCollected,
TypeChecking=Interface,
] interface Body {
readonly attribute boolean bodyUsed;
[CallWith=ScriptState] Promise arrayBuffer();
......
......@@ -8,6 +8,7 @@
GarbageCollected,
Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorkerCache,
TypeChecking=Interface,
] interface Cache {
// FIXME: Blink doesn't support union types, we use overrides instead. See http://crbug.com/240176
......
......@@ -7,6 +7,7 @@
GarbageCollected,
Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorkerCache,
TypeChecking=Interface,
] interface CacheStorage {
[CallWith=ScriptState] Promise has(ScalarValueString cacheName);
[CallWith=ScriptState] Promise open(ScalarValueString cacheName);
......
......@@ -32,6 +32,7 @@
[
RuntimeEnabled=ServiceWorker,
Exposed=ServiceWorker,
TypeChecking=Interface,
] interface ExtendableEvent : Event {
[CallWith=ScriptState] void waitUntil(any value);
};
......@@ -5,7 +5,8 @@
// https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#fetch-event-interface
[
RuntimeEnabled=ServiceWorkerOnFetch,
Exposed=ServiceWorker
Exposed=ServiceWorker,
TypeChecking=Interface,
] interface FetchEvent : Event {
readonly attribute Request request;
readonly attribute boolean isReload;
......
......@@ -14,6 +14,7 @@ typedef Dictionary OpenEndedDictionary;
Exposed=ServiceWorker,
RaisesException=Constructor,
GarbageCollected,
TypeChecking=Interface,
] interface Headers {
[RaisesException] void append(ByteString name, ByteString value);
[ImplementedAs=remove, RaisesException] void delete(ByteString key);
......
......@@ -32,6 +32,7 @@
[
RuntimeEnabled=ServiceWorker,
Exposed=ServiceWorker,
TypeChecking=Interface,
] interface InstallEvent : ExtendableEvent {
void replace();
[CallWith=ScriptState] Promise reloadAll();
......
......@@ -16,6 +16,7 @@ enum RequestCredentials { "omit", "same-origin", "include" };
RaisesException=Constructor,
ActiveDOMObject,
GarbageCollected,
TypeChecking=Interface,
] interface Request {
readonly attribute ByteString method;
readonly attribute ScalarValueString url;
......
......@@ -18,6 +18,7 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque" };
RaisesException=Constructor,
ActiveDOMObject,
GarbageCollected,
TypeChecking=Interface,
] interface Response {
// FIXME: Implement redirect().
readonly attribute ResponseType type;
......
......@@ -41,6 +41,7 @@ enum ServiceWorkerState {
[
ActiveDOMObject,
RuntimeEnabled=ServiceWorker,
TypeChecking=Interface,
] interface ServiceWorker : EventTarget {
// FIXME: Should inherit this from Worker.
......
......@@ -7,6 +7,7 @@
Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorker,
GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerClient {
readonly attribute unsigned long id;
......
......@@ -7,6 +7,7 @@
Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorker,
GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerClients {
[CallWith=ScriptState] Promise getAll(optional ServiceWorkerClientQueryOptions options);
};
......@@ -31,7 +31,8 @@
// https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-interface
[
RuntimeEnabled=ServiceWorker,
GarbageCollected
GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerContainer {
[Unforgeable] readonly attribute ServiceWorker? controller;
[CallWith=ScriptState] readonly attribute Promise ready;
......
......@@ -33,6 +33,7 @@
Exposed=ServiceWorker,
Global=(Worker,ServiceWorker),
RuntimeEnabled=ServiceWorker,
TypeChecking=Interface,
] interface ServiceWorkerGlobalScope : WorkerGlobalScope {
readonly attribute ServiceWorkerClients clients;
......
......@@ -7,6 +7,7 @@
ActiveDOMObject,
RuntimeEnabled=ServiceWorker,
GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerRegistration : EventTarget {
[Unforgeable] readonly attribute ServiceWorker? installing;
[Unforgeable] readonly attribute ServiceWorker? waiting;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment