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 ...@@ -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 PASS Cache.put with HTTP 500 response
FAIL Cache.put called twice with same Request and different Responses Entry already exists. 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. 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 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 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.
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. Harness: the test ran to completion.
...@@ -160,16 +160,12 @@ cache_test(function(cache) { ...@@ -160,16 +160,12 @@ cache_test(function(cache) {
'Cache.put should only accept a Request object as the request.'); 'Cache.put should only accept a Request object as the request.');
}, 'Cache.put with an invalid request'); }, 'Cache.put with an invalid request');
// TODO: This test currently causes a renderer crash. Enable test again once the cache_test(function(cache) {
// crash is resolved. http://crbug.com/426153 return assert_promise_rejects(
if (false) { cache.put(new_test_request(), 'Hello world!'),
cache_test(function(cache) { new TypeError(),
return assert_promise_rejects( 'Cache.put should only accept a Response object as the response.');
cache.put(new_test_request(), 'Hello world!'), }, 'Cache.put with an invalid response');
new TypeError(),
'Cache.put should only accept a Response object as the response.');
}, 'Cache.put with an invalid response');
}
cache_test(function(cache) { cache_test(function(cache) {
return assert_promise_rejects( return assert_promise_rejects(
...@@ -207,13 +203,9 @@ cache_test(function(cache) { ...@@ -207,13 +203,9 @@ cache_test(function(cache) {
'Cache.put should throw a TypeError for non-GET requests.'); 'Cache.put should throw a TypeError for non-GET requests.');
}, 'Cache.put with a non-GET request'); }, 'Cache.put with a non-GET request');
// TODO: This test currently causes a renderer crash. Enable test again once the cache_test(function(cache) {
// crash is resolved. http://crbug.com/426153 return assert_promise_rejects(
if (false) { cache.put(new_test_request(), null),
cache_test(function(cache) { new TypeError(),
return assert_promise_rejects( 'Cache.put should throw a TypeError for an empty response.');
cache.put(new_test_request(), null), }, 'Cache.put with an empty response');
new TypeError(),
'Cache.put should throw a TypeError for an empty response.');
}, 'Cache.put with an empty response');
}
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
NoInterfaceObject, NoInterfaceObject,
ActiveDOMObject, ActiveDOMObject,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface Body { ] interface Body {
readonly attribute boolean bodyUsed; readonly attribute boolean bodyUsed;
[CallWith=ScriptState] Promise arrayBuffer(); [CallWith=ScriptState] Promise arrayBuffer();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
GarbageCollected, GarbageCollected,
Exposed=ServiceWorker, Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorkerCache, RuntimeEnabled=ServiceWorkerCache,
TypeChecking=Interface,
] interface Cache { ] interface Cache {
// FIXME: Blink doesn't support union types, we use overrides instead. See http://crbug.com/240176 // FIXME: Blink doesn't support union types, we use overrides instead. See http://crbug.com/240176
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
GarbageCollected, GarbageCollected,
Exposed=ServiceWorker, Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorkerCache, RuntimeEnabled=ServiceWorkerCache,
TypeChecking=Interface,
] interface CacheStorage { ] interface CacheStorage {
[CallWith=ScriptState] Promise has(ScalarValueString cacheName); [CallWith=ScriptState] Promise has(ScalarValueString cacheName);
[CallWith=ScriptState] Promise open(ScalarValueString cacheName); [CallWith=ScriptState] Promise open(ScalarValueString cacheName);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
[ [
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
Exposed=ServiceWorker, Exposed=ServiceWorker,
TypeChecking=Interface,
] interface ExtendableEvent : Event { ] interface ExtendableEvent : Event {
[CallWith=ScriptState] void waitUntil(any value); [CallWith=ScriptState] void waitUntil(any value);
}; };
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
// https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#fetch-event-interface // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#fetch-event-interface
[ [
RuntimeEnabled=ServiceWorkerOnFetch, RuntimeEnabled=ServiceWorkerOnFetch,
Exposed=ServiceWorker Exposed=ServiceWorker,
TypeChecking=Interface,
] interface FetchEvent : Event { ] interface FetchEvent : Event {
readonly attribute Request request; readonly attribute Request request;
readonly attribute boolean isReload; readonly attribute boolean isReload;
......
...@@ -14,6 +14,7 @@ typedef Dictionary OpenEndedDictionary; ...@@ -14,6 +14,7 @@ typedef Dictionary OpenEndedDictionary;
Exposed=ServiceWorker, Exposed=ServiceWorker,
RaisesException=Constructor, RaisesException=Constructor,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface Headers { ] interface Headers {
[RaisesException] void append(ByteString name, ByteString value); [RaisesException] void append(ByteString name, ByteString value);
[ImplementedAs=remove, RaisesException] void delete(ByteString key); [ImplementedAs=remove, RaisesException] void delete(ByteString key);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
[ [
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
Exposed=ServiceWorker, Exposed=ServiceWorker,
TypeChecking=Interface,
] interface InstallEvent : ExtendableEvent { ] interface InstallEvent : ExtendableEvent {
void replace(); void replace();
[CallWith=ScriptState] Promise reloadAll(); [CallWith=ScriptState] Promise reloadAll();
......
...@@ -16,6 +16,7 @@ enum RequestCredentials { "omit", "same-origin", "include" }; ...@@ -16,6 +16,7 @@ enum RequestCredentials { "omit", "same-origin", "include" };
RaisesException=Constructor, RaisesException=Constructor,
ActiveDOMObject, ActiveDOMObject,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface Request { ] interface Request {
readonly attribute ByteString method; readonly attribute ByteString method;
readonly attribute ScalarValueString url; readonly attribute ScalarValueString url;
......
...@@ -18,6 +18,7 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque" }; ...@@ -18,6 +18,7 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque" };
RaisesException=Constructor, RaisesException=Constructor,
ActiveDOMObject, ActiveDOMObject,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface Response { ] interface Response {
// FIXME: Implement redirect(). // FIXME: Implement redirect().
readonly attribute ResponseType type; readonly attribute ResponseType type;
......
...@@ -41,6 +41,7 @@ enum ServiceWorkerState { ...@@ -41,6 +41,7 @@ enum ServiceWorkerState {
[ [
ActiveDOMObject, ActiveDOMObject,
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
TypeChecking=Interface,
] interface ServiceWorker : EventTarget { ] interface ServiceWorker : EventTarget {
// FIXME: Should inherit this from Worker. // FIXME: Should inherit this from Worker.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
Exposed=ServiceWorker, Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerClient { ] interface ServiceWorkerClient {
readonly attribute unsigned long id; readonly attribute unsigned long id;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
Exposed=ServiceWorker, Exposed=ServiceWorker,
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerClients { ] interface ServiceWorkerClients {
[CallWith=ScriptState] Promise getAll(optional ServiceWorkerClientQueryOptions options); [CallWith=ScriptState] Promise getAll(optional ServiceWorkerClientQueryOptions options);
}; };
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
// https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-interface // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-interface
[ [
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
GarbageCollected GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerContainer { ] interface ServiceWorkerContainer {
[Unforgeable] readonly attribute ServiceWorker? controller; [Unforgeable] readonly attribute ServiceWorker? controller;
[CallWith=ScriptState] readonly attribute Promise ready; [CallWith=ScriptState] readonly attribute Promise ready;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
Exposed=ServiceWorker, Exposed=ServiceWorker,
Global=(Worker,ServiceWorker), Global=(Worker,ServiceWorker),
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
TypeChecking=Interface,
] interface ServiceWorkerGlobalScope : WorkerGlobalScope { ] interface ServiceWorkerGlobalScope : WorkerGlobalScope {
readonly attribute ServiceWorkerClients clients; readonly attribute ServiceWorkerClients clients;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
ActiveDOMObject, ActiveDOMObject,
RuntimeEnabled=ServiceWorker, RuntimeEnabled=ServiceWorker,
GarbageCollected, GarbageCollected,
TypeChecking=Interface,
] interface ServiceWorkerRegistration : EventTarget { ] interface ServiceWorkerRegistration : EventTarget {
[Unforgeable] readonly attribute ServiceWorker? installing; [Unforgeable] readonly attribute ServiceWorker? installing;
[Unforgeable] readonly attribute ServiceWorker? waiting; [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