Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js

Issue 1656933003: Add origins argument to registerForeignFetchScopes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add url::Origin::operator== to make tests simpler Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
index fcbb266fef4247d6438a04dd205c87e3503b285f..54994dcbed043b6d6a2f374e578f73f7ad54faac 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
@@ -4,19 +4,19 @@ self.addEventListener('install', function(event) {
test(function() {
assert_throws(new TypeError(), function() {
- event.registerForeignFetchScopes(scope);
+ event.registerForeignFetchScopes(scope, '*');
});
- }, 'Not an array');
+ }, 'Scopes not an array');
test(function() {
assert_throws(new TypeError(), function() {
- event.registerForeignFetchScopes([{}]);
+ event.registerForeignFetchScopes([{}], '*');
});
- }, 'Not a string in array');
+ }, 'Scopes not a string in array');
test(function() {
assert_throws(new TypeError(), function() {
- event.registerForeignFetchScopes(['/foo']);
+ event.registerForeignFetchScopes(['/foo'], '*');
});
}, 'Relative url not under scope');
@@ -24,25 +24,25 @@ self.addEventListener('install', function(event) {
var url = new URL(scope_url);
url.host = 'example.com';
assert_throws(new TypeError(), function() {
- event.registerForeignFetchScopes([url.href]);
+ event.registerForeignFetchScopes([url.href], '*');
});
}, 'Absolute url not under scope');
async_test(function(t) {
self.setTimeout(t.step_func(function() {
assert_throws('InvalidStateError', function() {
- event.registerForeignFetchScopes([scope]);
+ event.registerForeignFetchScopes([scope], '*');
});
t.done();
}), 1);
}, 'Call after event returned');
test(function() {
- event.registerForeignFetchScopes([]);
- }, 'Empty array');
+ event.registerForeignFetchScopes([], '*');
+ }, 'Empty array with wildcard origin string');
test(function() {
- event.registerForeignFetchScopes([scope, scope + '/foo']);
+ event.registerForeignFetchScopes([scope, scope + '/foo'], '*');
}, 'Absolute urls');
test(function() {
@@ -56,8 +56,63 @@ self.addEventListener('install', function(event) {
scope_url.pathname,
relative_scope,
'./' + relative_scope,
- relative_scope + '/foo']);
+ relative_scope + '/foo'], '*');
}, 'Relative urls');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([scope]);
+ });
+ }, 'No origins specified');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([scope], {});
+ });
+ }, 'Origins not a string or array');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([scope], [{}]);
+ });
+ }, 'Origins contains something not a string');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([scope], '/foo');
+ });
+ }, 'Origin not an absolute URL');
+
+ test(function() {
+ event.registerForeignFetchScopes([scope], ['*']);
+ }, 'Wildcard origin string in array');
+
+ test(function() {
+ event.registerForeignFetchScopes([scope], 'https://example.com/');
+ }, 'Origin string');
+
+ test(function() {
+ event.registerForeignFetchScopes([scope], ['https://example.com/']);
+ }, 'Origin string in array');
+
+ test(function() {
+ event.registerForeignFetchScopes(
+ [scope], ['https://example.com/', 'https://chromium.org']);
+ }, 'Array with multiple origins');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([scope],
+ ['*', 'https://example.com/']);
+ });
+ }, 'Origins includes wildcard and other strings');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([scope],
+ ['https://example.com/', '*']);
+ });
+ }, 'Origins includes other strings and wildcard');
});
// Import testharness after install handler to make sure our install handler

Powered by Google App Engine
This is Rietveld 408576698