| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..70dd95133cde8606d18f15a932bd591dffc6fed1
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
|
| @@ -0,0 +1,67 @@
|
| +
|
| +self.addEventListener('install', function(event) {
|
| + var scope = registration.scope;
|
| + var scopeUrl = new URL(scope);
|
| +
|
| + test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + event.registerForeignFetchScopes(scope);
|
| + });
|
| + }, 'Not an array');
|
| +
|
| + test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + event.registerForeignFetchScopes([{}]);
|
| + });
|
| + }, 'Not a string in array');
|
| +
|
| + test(function() {
|
| + assert_throws(new TypeError(), function() {
|
| + event.registerForeignFetchScopes(["/foo"]);
|
| + });
|
| + }, "Relative url not under scope");
|
| +
|
| + test(function() {
|
| + var url = new URL(scopeUrl);
|
| + url.host = "example.com";
|
| + assert_throws(new TypeError(), function() {
|
| + 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]);
|
| + });
|
| + t.done();
|
| + }), 1);
|
| + }, 'Call after event returned');
|
| +
|
| + test(function() {
|
| + event.registerForeignFetchScopes([]);
|
| + }, 'Empty array');
|
| +
|
| + test(function() {
|
| + event.registerForeignFetchScopes([scope, scope + '/foo']);
|
| + }, 'Absolute urls');
|
| +
|
| + test(function() {
|
| + // Figure out scope relative to location of this script:
|
| + var localDir = location.pathname;
|
| + localDir = localDir.substr(0, localDir.lastIndexOf('/'));
|
| + assert_true(scopeUrl.pathname.startsWith(localDir));
|
| + var relativeScope = scopeUrl.pathname.substr(localDir.length + 1);
|
| +
|
| + event.registerForeignFetchScopes([
|
| + scopeUrl.pathname,
|
| + relativeScope,
|
| + './' + relativeScope,
|
| + relativeScope + '/foo']);
|
| + }, "Relative urls");
|
| +
|
| +});
|
| +
|
| +// Import testharness after install handler to make sure our install handler
|
| +// runs first.
|
| +importScripts('../../resources/testharness.js');
|
|
|