diff options
author | Moonchild <moonchild@palemoon.org> | 2021-02-25 01:03:57 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-02-25 01:03:57 +0000 |
commit | ceadffab6b357723981a429e11222daf6cd6dcfb (patch) | |
tree | 5603053048d6a460f79b22bdf165fb74d32d39b0 /testing/web-platform/tests/service-workers/cache-storage | |
parent | 14fb2f966e9b54598c451e3cb35b4aa0480dafed (diff) | |
parent | ad5a13bd501e379517da1a944c104a11d951a3f5 (diff) | |
download | UXP-RC_20210225.tar UXP-RC_20210225.tar.gz UXP-RC_20210225.tar.lz UXP-RC_20210225.tar.xz UXP-RC_20210225.zip |
Merge branch 'master' into releaseRC_20210225
Diffstat (limited to 'testing/web-platform/tests/service-workers/cache-storage')
45 files changed, 0 insertions, 2139 deletions
diff --git a/testing/web-platform/tests/service-workers/cache-storage/OWNERS b/testing/web-platform/tests/service-workers/cache-storage/OWNERS deleted file mode 100644 index 2e63dd220..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -@inexorabletash -@wanderview diff --git a/testing/web-platform/tests/service-workers/cache-storage/common.https.html b/testing/web-platform/tests/service-workers/cache-storage/common.https.html deleted file mode 100644 index b00199844..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/common.https.html +++ /dev/null @@ -1,52 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: Verify that Window and Workers see same storage</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script> - -function wait_for_message(worker) { - return new Promise(function(resolve) { - worker.addEventListener('message', function listener(e) { - resolve(e.data); - worker.removeEventListener('message', listener); - }); - }); -} - -promise_test(function(t) { - var cache_name = 'common-test'; - return self.caches.delete(cache_name) - .then(function() { - var worker = new Worker('resources/common-worker.js'); - worker.postMessage({name: cache_name}); - return wait_for_message(worker); - }) - .then(function(message) { - return self.caches.open(cache_name); - }) - .then(function(cache) { - return Promise.all([ - cache.match('https://example.com/a'), - cache.match('https://example.com/b'), - cache.match('https://example.com/c') - ]); - }) - .then(function(responses) { - return Promise.all(responses.map( - function(response) { return response.text(); } - )); - }) - .then(function(bodies) { - assert_equals(bodies[0], 'a', - 'Body should match response put by worker'); - assert_equals(bodies[1], 'b', - 'Body should match response put by worker'); - assert_equals(bodies[2], 'c', - 'Body should match response put by worker'); - }); -}, 'Window sees cache puts by Worker'); - -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/blank.html b/testing/web-platform/tests/service-workers/cache-storage/resources/blank.html deleted file mode 100644 index a3c3a4689..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/blank.html +++ /dev/null @@ -1,2 +0,0 @@ -<!DOCTYPE html> -<title>Empty doc</title> diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js b/testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js deleted file mode 100644 index d0e8544b5..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/common-worker.js +++ /dev/null @@ -1,15 +0,0 @@ -self.onmessage = function(e) { - var cache_name = e.data.name; - - self.caches.open(cache_name) - .then(function(cache) { - return Promise.all([ - cache.put('https://example.com/a', new Response('a')), - cache.put('https://example.com/b', new Response('b')), - cache.put('https://example.com/c', new Response('c')) - ]); - }) - .then(function() { - self.postMessage('ok'); - }); -}; diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html b/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html deleted file mode 100644 index 00702df9e..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-iframe.html +++ /dev/null @@ -1,38 +0,0 @@ -<!DOCTYPE html> -<meta charset=utf-8> -<title>Controlled frame for Cache API test with credentials</title> -<script> - -function xhr(url, username, password) { - return new Promise(function(resolve, reject) { - var xhr = new XMLHttpRequest(), async = true; - xhr.open('GET', url, async, username, password); - xhr.send(); - xhr.onreadystatechange = function() { - if (xhr.readyState !== XMLHttpRequest.DONE) - return; - if (xhr.status === 200) { - resolve(xhr.responseText); - } else { - reject(new Error(xhr.statusText)); - } - }; - }); -} - -window.onmessage = function(e) { - Promise.all(e.data.map(function(item) { - return xhr(item.name, item.username, item.password); - })) - .then(function() { - navigator.serviceWorker.controller.postMessage('keys'); - navigator.serviceWorker.onmessage = function(e) { - window.parent.postMessage(e.data, '*'); - }; - }); -}; - -</script> -<body> -Hello? Yes, this is iframe. -</body> diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js b/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js deleted file mode 100644 index 43965b5fe..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/credentials-worker.js +++ /dev/null @@ -1,59 +0,0 @@ -var cache_name = 'credentials'; - -function assert_equals(actual, expected, message) { - if (!Object.is(actual, expected)) - throw Error(message + ': expected: ' + expected + ', actual: ' + actual); -} - -self.onfetch = function(e) { - if (!/\.txt$/.test(e.request.url)) return; - var content = e.request.url; - var cache; - e.respondWith( - self.caches.open(cache_name) - .then(function(result) { - cache = result; - return cache.put(e.request, new Response(content)); - }) - - .then(function() { return cache.match(e.request); }) - .then(function(result) { return result.text(); }) - .then(function(text) { - assert_equals(text, content, 'Cache.match() body should match'); - }) - - .then(function() { return cache.matchAll(e.request); }) - .then(function(results) { - assert_equals(results.length, 1, 'Should have one response'); - return results[0].text(); - }) - .then(function(text) { - assert_equals(text, content, 'Cache.matchAll() body should match'); - }) - - .then(function() { return self.caches.match(e.request); }) - .then(function(result) { return result.text(); }) - .then(function(text) { - assert_equals(text, content, 'CacheStorage.match() body should match'); - }) - - .then(function() { - return new Response('dummy'); - }) - ); -}; - -self.onmessage = function(e) { - if (e.data === 'keys') { - self.caches.open(cache_name) - .then(function(cache) { return cache.keys(); }) - .then(function(requests) { - var urls = requests.map(function(request) { return request.url; }); - self.clients.matchAll().then(function(clients) { - clients.forEach(function(client) { - client.postMessage(urls); - }); - }); - }); - } -}; diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py b/testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py deleted file mode 100644 index 71f13ebc3..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/fetch-status.py +++ /dev/null @@ -1,2 +0,0 @@ -def main(request, response): - return int(request.GET["status"]), [], "" diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html b/testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html deleted file mode 100644 index a2f1e502b..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/iframe.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html> -<title>ok</title> -<script> -window.onmessage = function(e) { - var id = e.data.id; - try { - var name = 'checkallowed'; - self.caches.open(name).then(function (cache) { - self.caches.delete(name); - window.parent.postMessage({id: id, result: 'allowed'}, '*'); - }).catch(function(e) { - window.parent.postMessage({id: id, result: 'denied', name: e.name, message: e.message}, '*'); - }); - } catch (e) { - window.parent.postMessage({id: id, result: 'unexpecteddenied', name: e.name, message: e.message}, '*'); - } -}; -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt b/testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt deleted file mode 100644 index 9e3cb91fb..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/simple.txt +++ /dev/null @@ -1 +0,0 @@ -a simple text file diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js b/testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js deleted file mode 100644 index f4145e621..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/test-helpers.js +++ /dev/null @@ -1,237 +0,0 @@ -(function() { - var next_cache_index = 1; - - // Returns a promise that resolves to a newly created Cache object. The - // returned Cache will be destroyed when |test| completes. - function create_temporary_cache(test) { - var uniquifier = String(++next_cache_index); - var cache_name = self.location.pathname + '/' + uniquifier; - - test.add_cleanup(function() { - self.caches.delete(cache_name); - }); - - return self.caches.delete(cache_name) - .then(function() { - return self.caches.open(cache_name); - }); - } - - self.create_temporary_cache = create_temporary_cache; -})(); - -// Runs |test_function| with a temporary unique Cache passed in as the only -// argument. The function is run as a part of Promise chain owned by -// promise_test(). As such, it is expected to behave in a manner identical (with -// the exception of the argument) to a function passed into promise_test(). -// -// E.g.: -// cache_test(function(cache) { -// // Do something with |cache|, which is a Cache object. -// }, "Some Cache test"); -function cache_test(test_function, description) { - promise_test(function(test) { - return create_temporary_cache(test) - .then(test_function); - }, description); -} - -// A set of Request/Response pairs to be used with prepopulated_cache_test(). -var simple_entries = [ - { - name: 'a', - request: new Request('http://example.com/a'), - response: new Response('') - }, - - { - name: 'b', - request: new Request('http://example.com/b'), - response: new Response('') - }, - - { - name: 'a_with_query', - request: new Request('http://example.com/a?q=r'), - response: new Response('') - }, - - { - name: 'A', - request: new Request('http://example.com/A'), - response: new Response('') - }, - - { - name: 'a_https', - request: new Request('https://example.com/a'), - response: new Response('') - }, - - { - name: 'a_org', - request: new Request('http://example.org/a'), - response: new Response('') - }, - - { - name: 'cat', - request: new Request('http://example.com/cat'), - response: new Response('') - }, - - { - name: 'catmandu', - request: new Request('http://example.com/catmandu'), - response: new Response('') - }, - - { - name: 'cat_num_lives', - request: new Request('http://example.com/cat?lives=9'), - response: new Response('') - }, - - { - name: 'cat_in_the_hat', - request: new Request('http://example.com/cat/in/the/hat'), - response: new Response('') - }, - - { - name: 'non_2xx_response', - request: new Request('http://example.com/non2xx'), - response: new Response('', {status: 404, statusText: 'nope'}) - }, - - { - name: 'error_response', - request: new Request('http://example.com/error'), - response: Response.error() - }, -]; - -// A set of Request/Response pairs to be used with prepopulated_cache_test(). -// These contain a mix of test cases that use Vary headers. -var vary_entries = [ - { - name: 'vary_cookie_is_cookie', - request: new Request('http://example.com/c', - {headers: {'Cookies': 'is-for-cookie'}}), - response: new Response('', - {headers: {'Vary': 'Cookies'}}) - }, - - { - name: 'vary_cookie_is_good', - request: new Request('http://example.com/c', - {headers: {'Cookies': 'is-good-enough-for-me'}}), - response: new Response('', - {headers: {'Vary': 'Cookies'}}) - }, - - { - name: 'vary_cookie_absent', - request: new Request('http://example.com/c'), - response: new Response('', - {headers: {'Vary': 'Cookies'}}) - } -]; - -// Run |test_function| with a Cache object and a map of entries. Prior to the -// call, the Cache is populated by cache entries from |entries|. The latter is -// expected to be an Object mapping arbitrary keys to objects of the form -// {request: <Request object>, response: <Response object>}. There's no -// guarantee on the order in which entries will be added to the cache. -// -// |test_function| should return a Promise that can be used with promise_test. -function prepopulated_cache_test(entries, test_function, description) { - cache_test(function(cache) { - var p = Promise.resolve(); - var hash = {}; - return Promise.all(entries.map(function(entry) { - hash[entry.name] = entry; - return cache.put(entry.request.clone(), - entry.response.clone()) - .catch(function(e) { - assert_unreached( - 'Test setup failed for entry ' + entry.name + ': ' + e); - }); - })) - .then(function() { - assert_equals(Object.keys(hash).length, entries.length); - }) - .then(function() { - return test_function(cache, hash); - }); - }, description); -} - -// Helper for testing with Headers objects. Compares Headers instances -// by serializing |expected| and |actual| to arrays and comparing. -function assert_header_equals(actual, expected, description) { - assert_class_string(actual, "Headers", description); - var header; - var actual_headers = []; - var expected_headers = []; - for (header of actual) - actual_headers.push(header[0] + ": " + header[1]); - for (header of expected) - expected_headers.push(header[0] + ": " + header[1]); - assert_array_equals(actual_headers, expected_headers, - description + " Headers differ."); -} - -// Helper for testing with Response objects. Compares simple -// attributes defined on the interfaces, as well as the headers. It -// does not compare the response bodies. -function assert_response_equals(actual, expected, description) { - assert_class_string(actual, "Response", description); - ["type", "url", "status", "ok", "statusText"].forEach(function(attribute) { - assert_equals(actual[attribute], expected[attribute], - description + " Attributes differ: " + attribute + "."); - }); - assert_header_equals(actual.headers, expected.headers, description); -} - -// Assert that the two arrays |actual| and |expected| contain the same -// set of Responses as determined by assert_response_equals. The order -// is not significant. -// -// |expected| is assumed to not contain any duplicates. -function assert_response_array_equivalent(actual, expected, description) { - assert_true(Array.isArray(actual), description); - assert_equals(actual.length, expected.length, description); - expected.forEach(function(expected_element) { - // assert_response_in_array treats the first argument as being - // 'actual', and the second as being 'expected array'. We are - // switching them around because we want to be resilient - // against the |actual| array containing duplicates. - assert_response_in_array(expected_element, actual, description); - }); -} - -// Asserts that two arrays |actual| and |expected| contain the same -// set of Responses as determined by assert_response_equals(). The -// corresponding elements must occupy corresponding indices in their -// respective arrays. -function assert_response_array_equals(actual, expected, description) { - assert_true(Array.isArray(actual), description); - assert_equals(actual.length, expected.length, description); - actual.forEach(function(value, index) { - assert_response_equals(value, expected[index], - description + " : object[" + index + "]"); - }); -} - -// Equivalent to assert_in_array, but uses assert_response_equals. -function assert_response_in_array(actual, expected_array, description) { - assert_true(expected_array.some(function(element) { - try { - assert_response_equals(actual, element); - return true; - } catch (e) { - return false; - } - }), description); -} diff --git a/testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js b/testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js deleted file mode 100644 index e4885727b..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/resources/testharness-helpers.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * testharness-helpers contains various useful extensions to testharness.js to - * allow them to be used across multiple tests before they have been - * upstreamed. This file is intended to be usable from both document and worker - * environments, so code should for example not rely on the DOM. - */ - -// Returns a promise that fulfills after the provided |promise| is fulfilled. -// The |test| succeeds only if |promise| rejects with an exception matching -// |code|. Accepted values for |code| follow those accepted for assert_throws(). -// The optional |description| describes the test being performed. -// -// E.g.: -// assert_promise_rejects( -// new Promise(...), // something that should throw an exception. -// 'NotFoundError', -// 'Should throw NotFoundError.'); -// -// assert_promise_rejects( -// new Promise(...), -// new TypeError(), -// 'Should throw TypeError'); -function assert_promise_rejects(promise, code, description) { - return promise.then( - function() { - throw 'assert_promise_rejects: ' + description + ' Promise did not reject.'; - }, - function(e) { - if (code !== undefined) { - assert_throws(code, function() { throw e; }, description); - } - }); -} diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js deleted file mode 100644 index 01fd605ad..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js +++ /dev/null @@ -1,238 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -cache_test(function(cache) { - return assert_promise_rejects( - cache.add(), - new TypeError(), - 'Cache.add should throw a TypeError when no arguments are given.'); - }, 'Cache.add called with no arguments'); - -cache_test(function(cache) { - return cache.add('../resources/simple.txt') - .then(function(result) { - assert_equals(result, undefined, - 'Cache.add should resolve with undefined on success.'); - return cache.match('../resources/simple.txt'); - }) - .then(function(response) { - assert_class_string(response, 'Response', - 'Cache.add should put a resource in the cache.'); - return response.text(); - }) - .then(function(body) { - assert_equals(body, 'a simple text file\n', - 'Cache.add should retrieve the correct body.'); - }); - }, 'Cache.add called with relative URL specified as a string'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.add('javascript://this-is-not-http-mmkay'), - new TypeError(), - 'Cache.add should throw a TypeError for non-HTTP/HTTPS URLs.'); - }, 'Cache.add called with non-HTTP/HTTPS URL'); - -cache_test(function(cache) { - var request = new Request('../resources/simple.txt'); - return cache.add(request) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.add should resolve with undefined on success.'); - }); - }, 'Cache.add called with Request object'); - -cache_test(function(cache) { - var request = new Request('../resources/simple.txt', - {method: 'POST', body: 'This is a body.'}); - return assert_promise_rejects( - cache.add(request), - new TypeError(), - 'Cache.add should throw a TypeError for non-GET requests.'); - }, 'Cache.add called with POST request'); - -cache_test(function(cache) { - var request = new Request('../resources/simple.txt'); - return cache.add(request) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.add should resolve with undefined on success.'); - }) - .then(function() { - return cache.add(request); - }) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.add should resolve with undefined on success.'); - }); - }, 'Cache.add called twice with the same Request object'); - -cache_test(function(cache) { - var request = new Request('../resources/simple.txt'); - return request.text() - .then(function() { - assert_false(request.bodyUsed); - }) - .then(function() { - return cache.add(request); - }); - }, 'Cache.add with request with null body (not consumed)'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.add('this-does-not-exist-please-dont-create-it'), - new TypeError(), - 'Cache.add should reject if response is !ok'); - }, 'Cache.add with request that results in a status of 404'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.add('../resources/fetch-status.php?status=500'), - new TypeError(), - 'Cache.add should reject if response is !ok'); - }, 'Cache.add with request that results in a status of 500'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.addAll(), - new TypeError(), - 'Cache.addAll with no arguments should throw TypeError.'); - }, 'Cache.addAll with no arguments'); - -cache_test(function(cache) { - // Assumes the existence of ../resources/simple.txt and ../resources/blank.html - var urls = ['../resources/simple.txt', undefined, '../resources/blank.html']; - return assert_promise_rejects( - cache.addAll(), - new TypeError(), - 'Cache.addAll should throw TypeError for an undefined argument.'); - }, 'Cache.addAll with a mix of valid and undefined arguments'); - -cache_test(function(cache) { - return cache.addAll([]) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.addAll should resolve with undefined on ' + - 'success.'); - return cache.keys(); - }) - .then(function(result) { - assert_equals(result.length, 0, - 'There should be no entry in the cache.'); - }); - }, 'Cache.addAll with an empty array'); - -cache_test(function(cache) { - // Assumes the existence of ../resources/simple.txt and - // ../resources/blank.html - var urls = ['../resources/simple.txt', - self.location.href, - '../resources/blank.html']; - return cache.addAll(urls) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.addAll should resolve with undefined on ' + - 'success.'); - return Promise.all( - urls.map(function(url) { return cache.match(url); })); - }) - .then(function(responses) { - assert_class_string( - responses[0], 'Response', - 'Cache.addAll should put a resource in the cache.'); - assert_class_string( - responses[1], 'Response', - 'Cache.addAll should put a resource in the cache.'); - assert_class_string( - responses[2], 'Response', - 'Cache.addAll should put a resource in the cache.'); - return Promise.all( - responses.map(function(response) { return response.text(); })); - }) - .then(function(bodies) { - assert_equals( - bodies[0], 'a simple text file\n', - 'Cache.add should retrieve the correct body.'); - assert_equals( - bodies[2], '<!DOCTYPE html>\n<title>Empty doc</title>\n', - 'Cache.add should retrieve the correct body.'); - }); - }, 'Cache.addAll with string URL arguments'); - -cache_test(function(cache) { - // Assumes the existence of ../resources/simple.txt and - // ../resources/blank.html - var urls = ['../resources/simple.txt', - self.location.href, - '../resources/blank.html']; - var requests = urls.map(function(url) { - return new Request(url); - }); - return cache.addAll(requests) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.addAll should resolve with undefined on ' + - 'success.'); - return Promise.all( - urls.map(function(url) { return cache.match(url); })); - }) - .then(function(responses) { - assert_class_string( - responses[0], 'Response', - 'Cache.addAll should put a resource in the cache.'); - assert_class_string( - responses[1], 'Response', - 'Cache.addAll should put a resource in the cache.'); - assert_class_string( - responses[2], 'Response', - 'Cache.addAll should put a resource in the cache.'); - return Promise.all( - responses.map(function(response) { return response.text(); })); - }) - .then(function(bodies) { - assert_equals( - bodies[0], 'a simple text file\n', - 'Cache.add should retrieve the correct body.'); - assert_equals( - bodies[2], '<!DOCTYPE html>\n<title>Empty doc</title>\n', - 'Cache.add should retrieve the correct body.'); - }); - }, 'Cache.addAll with Request arguments'); - -cache_test(function(cache) { - // Assumes that ../resources/simple.txt and ../resources/blank.html exist. - // The second resource does not. - var urls = ['../resources/simple.txt', - 'this-resource-should-not-exist', - '../resources/blank.html']; - var requests = urls.map(function(url) { - return new Request(url); - }); - return assert_promise_rejects( - cache.addAll(requests), - new TypeError(), - 'Cache.addAll should reject with TypeError if any request fails') - .then(function() { - return Promise.all(urls.map(function(url) { return cache.match(url); })); - }) - .then(function(matches) { - assert_array_equals( - matches, - [undefined, undefined, undefined], - 'If any response fails, no response should be added to cache'); - }); - }, 'Cache.addAll with a mix of succeeding and failing requests'); - -cache_test(function(cache) { - var request = new Request('../resources/simple.txt'); - return assert_promise_rejects( - cache.addAll([request, request]), - 'InvalidStateError', - 'Cache.addAll should throw InvalidStateError if the same request is added ' + - 'twice.'); - }, 'Cache.addAll called with the same Request object specified twice'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js deleted file mode 100644 index 75a474c2b..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-delete.js +++ /dev/null @@ -1,96 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -var test_url = 'https://example.com/foo'; - -// Construct a generic Request object. The URL is |test_url|. All other fields -// are defaults. -function new_test_request() { - return new Request(test_url); -} - -// Construct a generic Response object. -function new_test_response() { - return new Response('Hello world!', { status: 200 }); -} - -cache_test(function(cache) { - return assert_promise_rejects( - cache.delete(), - new TypeError(), - 'Cache.delete should reject with a TypeError when called with no ' + - 'arguments.'); - }, 'Cache.delete with no arguments'); - -cache_test(function(cache) { - return cache.put(new_test_request(), new_test_response()) - .then(function() { - return cache.delete(test_url); - }) - .then(function(result) { - assert_true(result, - 'Cache.delete should resolve with "true" if an entry ' + - 'was successfully deleted.'); - return cache.match(test_url); - }) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.delete should remove matching entries from cache.'); - }); - }, 'Cache.delete called with a string URL'); - -cache_test(function(cache) { - var request = new Request(test_url); - return cache.put(request, new_test_response()) - .then(function() { - return cache.delete(request); - }) - .then(function(result) { - assert_true(result, - 'Cache.delete should resolve with "true" if an entry ' + - 'was successfully deleted.'); - }); - }, 'Cache.delete called with a Request object'); - -cache_test(function(cache) { - return cache.delete(test_url) - .then(function(result) { - assert_false(result, - 'Cache.delete should resolve with "false" if there ' + - 'are no matching entries.'); - }); - }, 'Cache.delete with a non-existent entry'); - -var cache_entries = { - a: { - request: new Request('http://example.com/abc'), - response: new Response('') - }, - - b: { - request: new Request('http://example.com/b'), - response: new Response('') - }, - - a_with_query: { - request: new Request('http://example.com/abc?q=r'), - response: new Response('') - } -}; - -function prepopulated_cache_test(test_function, description) { - cache_test(function(cache) { - return Promise.all(Object.keys(cache_entries).map(function(k) { - return cache.put(cache_entries[k].request.clone(), - cache_entries[k].response.clone()); - })) - .then(function() { - return test_function(cache); - }); - }, description); -} - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js deleted file mode 100644 index 716bfe5a6..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-match.js +++ /dev/null @@ -1,193 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match('not-present-in-the-cache') - .then(function(result) { - assert_equals(result, undefined, - 'Cache.match failures should resolve with undefined.'); - }); - }, 'Cache.match with no matching entries'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match(entries.a.request.url) - .then(function(result) { - assert_response_equals(result, entries.a.response, - 'Cache.match should match by URL.'); - }); - }, 'Cache.match with URL'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match(entries.a.request) - .then(function(result) { - assert_response_equals(result, entries.a.response, - 'Cache.match should match by Request.'); - }); - }, 'Cache.match with Request'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match(new Request(entries.a.request.url)) - .then(function(result) { - assert_response_equals(result, entries.a.response, - 'Cache.match should match by Request.'); - }); - }, 'Cache.match with new Request'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match(entries.a.request, - {ignoreSearch: true}) - .then(function(result) { - assert_response_in_array( - result, - [ - entries.a.response, - entries.a_with_query.response - ], - 'Cache.match with ignoreSearch should ignore the ' + - 'search parameters of cached request.'); - }); - }, - 'Cache.match with ignoreSearch option (request with no search ' + - 'parameters)'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match(entries.a_with_query.request, - {ignoreSearch: true}) - .then(function(result) { - assert_response_in_array( - result, - [ - entries.a.response, - entries.a_with_query.response - ], - 'Cache.match with ignoreSearch should ignore the ' + - 'search parameters of request.'); - }); - }, - 'Cache.match with ignoreSearch option (request with search parameter)'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match(entries.cat.request.url + '#mouse') - .then(function(result) { - assert_response_equals(result, entries.cat.response, - 'Cache.match should ignore URL fragment.'); - }); - }, 'Cache.match with URL containing fragment'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.match('http') - .then(function(result) { - assert_equals( - result, undefined, - 'Cache.match should treat query as a URL and not ' + - 'just a string fragment.'); - }); - }, 'Cache.match with string fragment "http" as query'); - -prepopulated_cache_test(vary_entries, function(cache, entries) { - return cache.match('http://example.com/c') - .then(function(result) { - assert_response_in_array( - result, - [ - entries.vary_cookie_absent.response - ], - 'Cache.match should honor "Vary" header.'); - }); - }, 'Cache.match with responses containing "Vary" header'); - -cache_test(function(cache) { - var request = new Request('http://example.com'); - var response; - var request_url = new URL('../resources/simple.txt', location.href).href; - return fetch(request_url) - .then(function(fetch_result) { - response = fetch_result; - assert_equals( - response.url, request_url, - '[https://fetch.spec.whatwg.org/#dom-response-url] ' + - 'Reponse.url should return the URL of the response.'); - return cache.put(request, response.clone()); - }) - .then(function() { - return cache.match(request.url); - }) - .then(function(result) { - assert_response_equals( - result, response, - 'Cache.match should return a Response object that has the same ' + - 'properties as the stored response.'); - return cache.match(response.url); - }) - .then(function(result) { - assert_equals( - result, undefined, - 'Cache.match should not match cache entry based on response URL.'); - }); - }, 'Cache.match with Request and Response objects with different URLs'); - -cache_test(function(cache) { - var request_url = new URL('../resources/simple.txt', location.href).href; - return fetch(request_url) - .then(function(fetch_result) { - return cache.put(new Request(request_url), fetch_result); - }) - .then(function() { - return cache.match(request_url); - }) - .then(function(result) { - return result.text(); - }) - .then(function(body_text) { - assert_equals(body_text, 'a simple text file\n', - 'Cache.match should return a Response object with a ' + - 'valid body.'); - }) - .then(function() { - return cache.match(request_url); - }) - .then(function(result) { - return result.text(); - }) - .then(function(body_text) { - assert_equals(body_text, 'a simple text file\n', - 'Cache.match should return a Response object with a ' + - 'valid body each time it is called.'); - }); - }, 'Cache.match invoked multiple times for the same Request/Response'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - var request = new Request(entries.a.request.clone(), {method: 'POST'}); - return cache.match(request) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.match should not find a match'); - }); - }, 'Cache.match with POST Request'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - var response = entries.non_2xx_response.response; - return cache.match(entries.non_2xx_response.request.url) - .then(function(result) { - assert_response_equals( - result, entries.non_2xx_response.response, - 'Cache.match should return a Response object that has the ' + - 'same properties as a stored non-2xx response.'); - }); - }, 'Cache.match with a non-2xx Response'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - var response = entries.error_response.response; - return cache.match(entries.error_response.request.url) - .then(function(result) { - assert_response_equals( - result, entries.error_response.response, - 'Cache.match should return a Response object that has the ' + - 'same properties as a stored network error response.'); - }); - }, 'Cache.match with a network error Response'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js deleted file mode 100644 index 2bc661a5c..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-matchAll.js +++ /dev/null @@ -1,154 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll('not-present-in-the-cache') - .then(function(result) { - assert_response_array_equivalent( - result, [], - 'Cache.matchAll should resolve with an empty array on failure.'); - }); - }, 'Cache.matchAll with no matching entries'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll(entries.a.request.url) - .then(function(result) { - assert_response_array_equals(result, [entries.a.response], - 'Cache.matchAll should match by URL.'); - }); - }, 'Cache.matchAll with URL'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll(entries.a.request) - .then(function(result) { - assert_response_array_equals( - result, [entries.a.response], - 'Cache.matchAll should match by Request.'); - }); - }, 'Cache.matchAll with Request'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll(new Request(entries.a.request.url)) - .then(function(result) { - assert_response_array_equals( - result, [entries.a.response], - 'Cache.matchAll should match by Request.'); - }); - }, 'Cache.matchAll with new Request'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll(entries.a.request, - {ignoreSearch: true}) - .then(function(result) { - assert_response_array_equivalent( - result, - [ - entries.a.response, - entries.a_with_query.response - ], - 'Cache.matchAll with ignoreSearch should ignore the ' + - 'search parameters of cached request.'); - }); - }, - 'Cache.matchAll with ignoreSearch option (request with no search ' + - 'parameters)'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll(entries.a_with_query.request, - {ignoreSearch: true}) - .then(function(result) { - assert_response_array_equivalent( - result, - [ - entries.a.response, - entries.a_with_query.response - ], - 'Cache.matchAll with ignoreSearch should ignore the ' + - 'search parameters of request.'); - }); - }, - 'Cache.matchAll with ignoreSearch option (request with search parameter)'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll(entries.cat.request.url + '#mouse') - .then(function(result) { - assert_response_array_equivalent( - result, - [ - entries.cat.response, - ], - 'Cache.matchAll should ignore URL fragment.'); - }); - }, 'Cache.matchAll with URL containing fragment'); - -prepopulated_cache_test(simple_entries, function(cache, entries) { - return cache.matchAll('http') - .then(function(result) { - assert_response_array_equivalent( - result, [], - 'Cache.matchAll should treat query as a URL and not ' + - 'just a string fragment.'); - }); - }, 'Cache.matchAll with string fragment "http" as query'); - -prepopulated_cache_test(vary_entries, function(cache, entries) { - return cache.matchAll('http://example.com/c') - .then(function(result) { - assert_response_array_equivalent( - result, - [ - entries.vary_cookie_absent.response - ], - 'Cache.matchAll should exclude matches if a vary header is ' + - 'missing in the query request, but is present in the cached ' + - 'request.'); - }) - - .then(function() { - return cache.matchAll( - new Request('http://example.com/c', - {headers: {'Cookies': 'none-of-the-above'}})); - }) - .then(function(result) { - assert_response_array_equivalent( - result, - [ - ], - 'Cache.matchAll should exclude matches if a vary header is ' + - 'missing in the cached request, but is present in the query ' + - 'request.'); - }) - - .then(function() { - return cache.matchAll( - new Request('http://example.com/c', - {headers: {'Cookies': 'is-for-cookie'}})); - }) - .then(function(result) { - assert_response_array_equivalent( - result, - [entries.vary_cookie_is_cookie.response], - 'Cache.matchAll should match the entire header if a vary header ' + - 'is present in both the query and cached requests.'); - }); - }, 'Cache.matchAll with responses containing "Vary" header'); - -prepopulated_cache_test(vary_entries, function(cache, entries) { - return cache.matchAll('http://example.com/c', - {ignoreVary: true}) - .then(function(result) { - assert_response_array_equivalent( - result, - [ - entries.vary_cookie_is_cookie.response, - entries.vary_cookie_is_good.response, - entries.vary_cookie_absent.response - ], - 'Cache.matchAll should honor "ignoreVary" parameter.'); - }); - }, 'Cache.matchAll with "ignoreVary" parameter'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js deleted file mode 100644 index bcc8541ad..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js +++ /dev/null @@ -1,305 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -var test_url = 'https://example.com/foo'; -var test_body = 'Hello world!'; - -cache_test(function(cache) { - var request = new Request(test_url); - var response = new Response(test_body); - return cache.put(request, response) - .then(function(result) { - assert_equals(result, undefined, - 'Cache.put should resolve with undefined on success.'); - }); - }, 'Cache.put called with simple Request and Response'); - -cache_test(function(cache) { - var test_url = new URL('../resources/simple.txt', location.href).href; - var request = new Request(test_url); - var response; - return fetch(test_url) - .then(function(fetch_result) { - response = fetch_result.clone(); - return cache.put(request, fetch_result); - }) - .then(function() { - return cache.match(test_url); - }) - .then(function(result) { - assert_response_equals(result, response, - 'Cache.put should update the cache with ' + - 'new request and response.'); - return result.text(); - }) - .then(function(body) { - assert_equals(body, 'a simple text file\n', - 'Cache.put should store response body.'); - }); - }, 'Cache.put called with Request and Response from fetch()'); - -cache_test(function(cache) { - var request = new Request(test_url); - var response = new Response(test_body); - assert_false(request.bodyUsed, - '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + - 'Request.bodyUsed should be initially false.'); - return cache.put(request, response) - .then(function() { - assert_false(request.bodyUsed, - 'Cache.put should not mark empty request\'s body used'); - }); - }, 'Cache.put with Request without a body'); - -cache_test(function(cache) { - var request = new Request(test_url); - var response = new Response(); - assert_false(response.bodyUsed, - '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + - 'Response.bodyUsed should be initially false.'); - return cache.put(request, response) - .then(function() { - assert_false(response.bodyUsed, - 'Cache.put should not mark empty response\'s body used'); - }); - }, 'Cache.put with Response without a body'); - -cache_test(function(cache) { - var request = new Request(test_url); - var response = new Response(test_body); - return cache.put(request, response.clone()) - .then(function() { - return cache.match(test_url); - }) - .then(function(result) { - assert_response_equals(result, response, - 'Cache.put should update the cache with ' + - 'new Request and Response.'); - }); - }, 'Cache.put with a Response containing an empty URL'); - -cache_test(function(cache) { - var request = new Request(test_url); - var response = new Response('', { - status: 200, - headers: [['Content-Type', 'text/plain']] - }); - return cache.put(request, response) - .then(function() { - return cache.match(test_url); - }) - .then(function(result) { - assert_equals(result.status, 200, 'Cache.put should store status.'); - assert_equals(result.headers.get('Content-Type'), 'text/plain', - 'Cache.put should store headers.'); - return result.text(); - }) - .then(function(body) { - assert_equals(body, '', - 'Cache.put should store response body.'); - }); - }, 'Cache.put with an empty response body'); - -cache_test(function(cache) { - var test_url = new URL('../resources/fetch-status.py?status=500', location.href).href; - var request = new Request(test_url); - var response; - return fetch(test_url) - .then(function(fetch_result) { - assert_equals(fetch_result.status, 500, - 'Test framework error: The status code should be 500.'); - response = fetch_result.clone(); - return cache.put(request, fetch_result); - }) - .then(function() { - return cache.match(test_url); - }) - .then(function(result) { - assert_response_equals(result, response, - 'Cache.put should update the cache with ' + - 'new request and response.'); - return result.text(); - }) - .then(function(body) { - assert_equals(body, '', - 'Cache.put should store response body.'); - }); - }, 'Cache.put with HTTP 500 response'); - -cache_test(function(cache) { - var alternate_response_body = 'New body'; - var alternate_response = new Response(alternate_response_body, - { statusText: 'New status' }); - return cache.put(new Request(test_url), - new Response('Old body', { statusText: 'Old status' })) - .then(function() { - return cache.put(new Request(test_url), alternate_response.clone()); - }) - .then(function() { - return cache.match(test_url); - }) - .then(function(result) { - assert_response_equals(result, alternate_response, - 'Cache.put should replace existing ' + - 'response with new response.'); - return result.text(); - }) - .then(function(body) { - assert_equals(body, alternate_response_body, - 'Cache put should store new response body.'); - }); - }, 'Cache.put called twice with matching Requests and different Responses'); - -cache_test(function(cache) { - var first_url = test_url; - var second_url = first_url + '#(O_o)'; - var alternate_response_body = 'New body'; - var alternate_response = new Response(alternate_response_body, - { statusText: 'New status' }); - return cache.put(new Request(first_url), - new Response('Old body', { statusText: 'Old status' })) - .then(function() { - return cache.put(new Request(second_url), alternate_response.clone()); - }) - .then(function() { - return cache.match(test_url); - }) - .then(function(result) { - assert_response_equals(result, alternate_response, - 'Cache.put should replace existing ' + - 'response with new response.'); - return result.text(); - }) - .then(function(body) { - assert_equals(body, alternate_response_body, - 'Cache put should store new response body.'); - }); - }, 'Cache.put called twice with request URLs that differ only by a fragment'); - -cache_test(function(cache) { - var url = 'http://example.com/foo'; - return cache.put(url, new Response('some body')) - .then(function() { return cache.match(url); }) - .then(function(response) { return response.text(); }) - .then(function(body) { - assert_equals(body, 'some body', - 'Cache.put should accept a string as request.'); - }); - }, 'Cache.put with a string request'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.put(new Request(test_url), '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( - cache.put(new Request('file:///etc/passwd'), - new Response(test_body)), - new TypeError(), - 'Cache.put should reject non-HTTP/HTTPS requests with a TypeError.'); - }, 'Cache.put with a non-HTTP/HTTPS request'); - -cache_test(function(cache) { - var response = new Response(test_body); - return cache.put(new Request('relative-url'), response.clone()) - .then(function() { - return cache.match(new URL('relative-url', location.href).href); - }) - .then(function(result) { - assert_response_equals(result, response, - 'Cache.put should accept a relative URL ' + - 'as the request.'); - }); - }, 'Cache.put with a relative URL'); - -cache_test(function(cache) { - var request = new Request('http://example.com/foo', { method: 'HEAD' }); - return assert_promise_rejects( - cache.put(request, new Response(test_body)), - new TypeError(), - 'Cache.put should throw a TypeError for non-GET requests.'); - }, 'Cache.put with a non-GET request'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.put(new Request(test_url), null), - new TypeError(), - 'Cache.put should throw a TypeError for a null response.'); - }, 'Cache.put with a null response'); - -cache_test(function(cache) { - var request = new Request(test_url, {method: 'POST', body: test_body}); - return assert_promise_rejects( - cache.put(request, new Response(test_body)), - new TypeError(), - 'Cache.put should throw a TypeError for a POST request.'); - }, 'Cache.put with a POST request'); - -cache_test(function(cache) { - var response = new Response(test_body); - assert_false(response.bodyUsed, - '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + - 'Response.bodyUsed should be initially false.'); - return response.text().then(function() { - assert_true( - response.bodyUsed, - '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' + - 'The text() method should make the body disturbed.'); - var request = new Request(test_url); - return cache.put(request, response).then(() => { - assert_unreached('cache.put should be rejected'); - }, () => {}); - }); - }, 'Cache.put with a used response body'); - -cache_test(function(cache) { - var response = new Response(test_body); - return cache.put(new Request(test_url), response) - .then(function() { - assert_throws(new TypeError(), () => response.body.getReader()); - }); - }, 'getReader() after Cache.put'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.put(new Request(test_url), - new Response(test_body, { headers: { VARY: '*' }})), - new TypeError(), - 'Cache.put should reject VARY:* Responses with a TypeError.'); - }, 'Cache.put with a VARY:* Response'); - -cache_test(function(cache) { - return assert_promise_rejects( - cache.put(new Request(test_url), - new Response(test_body, - { headers: { VARY: 'Accept-Language,*' }})), - new TypeError(), - 'Cache.put should reject Responses with an embedded VARY:* with a ' + - 'TypeError.'); - }, 'Cache.put with an embedded VARY:* Response'); - -cache_test(function(cache) { - var url = 'foo.html'; - var redirectURL = 'http://example.com/foo-bar.html'; - var redirectResponse = Response.redirect(redirectURL); - assert_equals(redirectResponse.headers.get('Location'), redirectURL, - 'Response.redirect() should set Location header.'); - return cache.put(url, redirectResponse.clone()) - .then(function() { - return cache.match(url); - }) - .then(function(response) { - assert_response_equals(response, redirectResponse, - 'Redirect response is reproduced by the Cache API'); - assert_equals(response.headers.get('Location'), redirectURL, - 'Location header is preserved by Cache API.'); - }); - }, 'Cache.put should store Response.redirect() correctly'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js deleted file mode 100644 index 4d7bc623f..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-keys.js +++ /dev/null @@ -1,36 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -var test_cache_list = - ['', 'example', 'Another cache name', 'A', 'a', 'ex ample']; - -promise_test(function(test) { - return self.caches.keys() - .then(function(keys) { - assert_true(Array.isArray(keys), - 'CacheStorage.keys should return an Array.'); - return Promise.all(keys.map(function(key) { - return self.caches.delete(key); - })); - }) - .then(function() { - return Promise.all(test_cache_list.map(function(key) { - return self.caches.open(key); - })); - }) - - .then(function() { return self.caches.keys(); }) - .then(function(keys) { - assert_true(Array.isArray(keys), - 'CacheStorage.keys should return an Array.'); - assert_array_equals(keys, - test_cache_list, - 'CacheStorage.keys should only return ' + - 'existing caches.'); - }); - }, 'CacheStorage keys'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js deleted file mode 100644 index 0052e43ca..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage-match.js +++ /dev/null @@ -1,124 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -(function() { - var next_index = 1; - - // Returns a transaction (request, response, and url) for a unique URL. - function create_unique_transaction(test) { - var uniquifier = String(next_index++); - var url = 'http://example.com/' + uniquifier; - - return { - request: new Request(url), - response: new Response('hello'), - url: url - }; - } - - self.create_unique_transaction = create_unique_transaction; -})(); - -cache_test(function(cache) { - var transaction = create_unique_transaction(); - - return cache.put(transaction.request.clone(), transaction.response.clone()) - .then(function() { - return self.caches.match(transaction.request); - }) - .then(function(response) { - assert_response_equals(response, transaction.response, - 'The response should not have changed.'); - }); -}, 'CacheStorageMatch with no cache name provided'); - -cache_test(function(cache) { - var transaction = create_unique_transaction(); - - var test_cache_list = ['a', 'b', 'c']; - return cache.put(transaction.request.clone(), transaction.response.clone()) - .then(function() { - return Promise.all(test_cache_list.map(function(key) { - return self.caches.open(key); - })); - }) - .then(function() { - return self.caches.match(transaction.request); - }) - .then(function(response) { - assert_response_equals(response, transaction.response, - 'The response should not have changed.'); - }); -}, 'CacheStorageMatch from one of many caches'); - -promise_test(function(test) { - var transaction = create_unique_transaction(); - - var test_cache_list = ['x', 'y', 'z']; - return Promise.all(test_cache_list.map(function(key) { - return self.caches.open(key); - })) - .then(function() { return caches.open('x'); }) - .then(function(cache) { - return cache.put(transaction.request.clone(), - transaction.response.clone()); - }) - .then(function() { - return self.caches.match(transaction.request, {cacheName: 'x'}); - }) - .then(function(response) { - assert_response_equals(response, transaction.response, - 'The response should not have changed.'); - }) - .then(function() { - return self.caches.match(transaction.request, {cacheName: 'y'}); - }) - .then(function(response) { - assert_equals(response, undefined, - 'Cache y should not have a response for the request.'); - }); -}, 'CacheStorageMatch from one of many caches by name'); - -cache_test(function(cache) { - var transaction = create_unique_transaction(); - return cache.put(transaction.url, transaction.response.clone()) - .then(function() { - return self.caches.match(transaction.request); - }) - .then(function(response) { - assert_response_equals(response, transaction.response, - 'The response should not have changed.'); - }); -}, 'CacheStorageMatch a string request'); - -promise_test(function(test) { - var transaction = create_unique_transaction(); - return self.caches.match(transaction.request) - .then(function(response) { - assert_equals(response, undefined, - 'The response should not be found.'); - }) -}, 'CacheStorageMatch with no cached entry'); - -promise_test(function(test) { - var transaction = create_unique_transaction(); - return self.caches.has('foo') - .then(function(has_foo) { - assert_false(has_foo, "The cache should not exist."); - return self.caches.match(transaction.request, {cacheName: 'foo'}); - }) - .then(function(response) { - assert_equals(response, undefined, - 'The match with bad cache name should resolve to ' + - 'undefined.'); - return self.caches.has('foo'); - }) - .then(function(has_foo) { - assert_false(has_foo, "The cache should still not exist."); - }) -}, 'CacheStorageMatch with no caches available but name provided'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js deleted file mode 100644 index 594b01b58..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-storage.js +++ /dev/null @@ -1,197 +0,0 @@ -if (self.importScripts) { - importScripts('/resources/testharness.js'); - importScripts('../resources/testharness-helpers.js'); - importScripts('../resources/test-helpers.js'); -} - -promise_test(function(t) { - var cache_name = 'cache-storage/foo'; - return self.caches.delete(cache_name) - .then(function() { - return self.caches.open(cache_name); - }) - .then(function(cache) { - assert_true(cache instanceof Cache, - 'CacheStorage.open should return a Cache.'); - }); - }, 'CacheStorage.open'); - -promise_test(function(t) { - // Note that this test may collide with other tests running in the same - // origin that also uses an empty cache name. - var cache_name = ''; - return self.caches.delete(cache_name) - .then(function() { - return self.caches.open(cache_name); - }) - .then(function(cache) { - assert_true(cache instanceof Cache, - 'CacheStorage.open should accept an empty name.'); - }); - }, 'CacheStorage.open with an empty name'); - -promise_test(function(t) { - return assert_promise_rejects( - self.caches.open(), - new TypeError(), - 'CacheStorage.open should throw TypeError if called with no arguments.'); - }, 'CacheStorage.open with no arguments'); - -promise_test(function(t) { - var test_cases = [ - { - name: 'cache-storage/lowercase', - should_not_match: - [ - 'cache-storage/Lowercase', - ' cache-storage/lowercase', - 'cache-storage/lowercase ' - ] - }, - { - name: 'cache-storage/has a space', - should_not_match: - [ - 'cache-storage/has' - ] - }, - { - name: 'cache-storage/has\000_in_the_name', - should_not_match: - [ - 'cache-storage/has', - 'cache-storage/has_in_the_name' - ] - } - ]; - return Promise.all(test_cases.map(function(testcase) { - var cache_name = testcase.name; - return self.caches.delete(cache_name) - .then(function() { - return self.caches.open(cache_name); - }) - .then(function() { - return self.caches.has(cache_name); - }) - .then(function(result) { - assert_true(result, - 'CacheStorage.has should return true for existing ' + - 'cache.'); - }) - .then(function() { - return Promise.all( - testcase.should_not_match.map(function(cache_name) { - return self.caches.has(cache_name) - .then(function(result) { - assert_false(result, - 'CacheStorage.has should only perform ' + - 'exact matches on cache names.'); - }); - })); - }) - .then(function() { - return self.caches.delete(cache_name); - }); - })); - }, 'CacheStorage.has with existing cache'); - -promise_test(function(t) { - return self.caches.has('cheezburger') - .then(function(result) { - assert_false(result, - 'CacheStorage.has should return false for ' + - 'nonexistent cache.'); - }); - }, 'CacheStorage.has with nonexistent cache'); - -promise_test(function(t) { - var cache_name = 'cache-storage/open'; - var cache; - return self.caches.delete(cache_name) - .then(function() { - return self.caches.open(cache_name); - }) - .then(function(result) { - cache = result; - }) - .then(function() { - return cache.add('../resources/simple.txt'); - }) - .then(function() { - return self.caches.open(cache_name); - }) - .then(function(result) { - assert_true(result instanceof Cache, - 'CacheStorage.open should return a Cache object'); - assert_not_equals(result, cache, - 'CacheStorage.open should return a new Cache ' + - 'object each time its called.'); - return Promise.all([cache.keys(), result.keys()]); - }) - .then(function(results) { - var expected_urls = results[0].map(function(r) { return r.url }); - var actual_urls = results[1].map(function(r) { return r.url }); - assert_array_equals(actual_urls, expected_urls, - 'CacheStorage.open should return a new Cache ' + - 'object for the same backing store.'); - }); - }, 'CacheStorage.open with existing cache'); - -promise_test(function(t) { - var cache_name = 'cache-storage/delete'; - - return self.caches.delete(cache_name) - .then(function() { - return self.caches.open(cache_name); - }) - .then(function() { return self.caches.delete(cache_name); }) - .then(function(result) { - assert_true(result, - 'CacheStorage.delete should return true after ' + - 'deleting an existing cache.'); - }) - - .then(function() { return self.caches.has(cache_name); }) - .then(function(cache_exists) { - assert_false(cache_exists, - 'CacheStorage.has should return false after ' + - 'fulfillment of CacheStorage.delete promise.'); - }); - }, 'CacheStorage.delete with existing cache'); - -promise_test(function(t) { - return self.caches.delete('cheezburger') - .then(function(result) { - assert_false(result, - 'CacheStorage.delete should return false for a ' + - 'nonexistent cache.'); - }); - }, 'CacheStorage.delete with nonexistent cache'); - -promise_test(function(t) { - var bad_name = 'unpaired\uD800'; - var converted_name = 'unpaired\uFFFD'; // Don't create cache with this name. - return self.caches.has(converted_name) - .then(function(cache_exists) { - assert_false(cache_exists, - 'Test setup failure: cache should not exist'); - }) - .then(function() { return self.caches.open(bad_name); }) - .then(function() { return self.caches.keys(); }) - .then(function(keys) { - assert_true(keys.indexOf(bad_name) !== -1, - 'keys should include cache with bad name'); - }) - .then(function() { return self.caches.has(bad_name); }) - .then(function(cache_exists) { - assert_true(cache_exists, - 'CacheStorage names should be not be converted.'); - }) - .then(function() { return self.caches.has(converted_name); }) - .then(function(cache_exists) { - assert_false(cache_exists, - 'CacheStorage names should be not be converted.'); - }); - }, 'CacheStorage names are DOMStrings not USVStrings'); - -done(); diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html deleted file mode 100644 index 232de668e..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-add.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>Cache.add and Cache.addAll</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-add"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-add.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html deleted file mode 100644 index 6ff27be30..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-delete.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>Cache.delete</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-delete"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-delete.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html deleted file mode 100644 index 81db70943..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-match.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>Cache.match</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-match"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-match.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html deleted file mode 100644 index f1a38ff07..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-matchAll.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>Cache.matchAll</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-matchall"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-matchAll.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html deleted file mode 100644 index 961602386..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-put.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>Cache.put</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-put"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-put.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html deleted file mode 100644 index adde95eb8..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>CacheStorage.keys</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-storage-keys.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html deleted file mode 100644 index fef14074d..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage-match.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>CacheStorage.match</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage-match"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-storage-match.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html deleted file mode 100644 index 3934258f2..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/cache-storage.https.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<title>CacheStorage</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<script> -service_worker_test('../script-tests/cache-storage.js'); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html b/testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html deleted file mode 100644 index 7bc494eb1..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/serviceworker/credentials.html +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE html> -<meta charset=utf-8> -<title>Cache Storage: Verify credentials are respected by Cache operations</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../../service-worker/resources/test-helpers.sub.js"></script> -<style>iframe { display: none; }</style> -<script> - -var worker = "../resources/credentials-worker.js"; -var scope = "../resources/credentials-iframe.html"; -promise_test(function(t) { - return self.caches.delete('credentials') - .then(function() { - return service_worker_unregister_and_register(t, worker, scope) - }) - .then(function(reg) { - return wait_for_state(t, reg.installing, 'activated'); - }) - .then(function() { - return with_iframe(scope); - }) - .then(function(frame) { - frame.contentWindow.postMessage([ - {name: 'file.txt', username: 'aa', password: 'bb'}, - {name: 'file.txt', username: 'cc', password: 'dd'}, - {name: 'file.txt'} - ], '*'); - return new Promise(function(resolve, reject) { - window.onmessage = t.step_func(function(e) { - resolve(e.data); - }); - }); - }) - .then(function(data) { - assert_equals(data.length, 3, 'three entries should be present'); - assert_equals(data.filter(function(url) { return /@/.test(url); }).length, 2, - 'two entries should contain credentials'); - assert_true(data.some(function(url) { return /aa:bb@/.test(url); }), - 'entry with credentials aa:bb should be present'); - assert_true(data.some(function(url) { return /cc:dd@/.test(url); }), - 'entry with credentials cc:dd should be present'); - }); -}, "Cache API matching includes credentials"); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html deleted file mode 100644 index d9945f9ae..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: Cache.add and Cache.addAll</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-add"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-add.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html deleted file mode 100644 index 735d2cdb4..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-delete.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: Cache.delete</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-delete"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-delete.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html deleted file mode 100644 index 0ff5c6799..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-match.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: Cache.match</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-match"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-match.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html deleted file mode 100644 index 372e641a5..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-matchAll.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache.matchAll</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-matchall"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-matchAll.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html deleted file mode 100644 index 1d9e02ba6..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: Cache.put</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-put"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-put.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html deleted file mode 100644 index b4f94bade..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-keys.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: CacheStorage.keys</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-storage-keys.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html deleted file mode 100644 index 72005f43a..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage-match.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: CacheStorage.match</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage-match"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-storage-match.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html deleted file mode 100644 index 6c4f4af7f..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-storage.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: CacheStorage</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script src="../resources/test-helpers.js"></script> -<script src="../script-tests/cache-storage.js"></script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html deleted file mode 100644 index 061858521..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/window/sandboxed-iframes.https.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<title>Cache Storage: Verify access in sandboxed iframes</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../resources/testharness-helpers.js"></script> -<script> - -function load_iframe(src, sandbox) { - return new Promise(function(resolve, reject) { - var iframe = document.createElement('iframe'); - iframe.onload = function() { resolve(iframe); }; - - iframe.sandbox = sandbox; - iframe.src = src; - - document.documentElement.appendChild(iframe); - }); -} - -function wait_for_message(id) { - return new Promise(function(resolve) { - self.addEventListener('message', function listener(e) { - if (e.data.id === id) { - resolve(e.data); - self.removeEventListener('message', listener); - } - }); - }); -} - -var counter = 0; - -promise_test(function(t) { - return load_iframe('../resources/iframe.html', - 'allow-scripts allow-same-origin') - .then(function(iframe) { - var id = ++counter; - iframe.contentWindow.postMessage({id: id}, '*'); - return wait_for_message(id); - }) - .then(function(message) { - assert_equals( - message.result, 'allowed', - 'Access should be allowed if sandbox has allow-same-origin'); - }); -}, 'Sandboxed iframe with allow-same-origin is allowed access'); - -promise_test(function(t) { - return load_iframe('../resources/iframe.html', - 'allow-scripts') - .then(function(iframe) { - var id = ++counter; - iframe.contentWindow.postMessage({id: id}, '*'); - return wait_for_message(id); - }) - .then(function(message) { - assert_equals( - message.result, 'denied', - 'Access should be denied if sandbox lacks allow-same-origin'); - assert_equals(message.name, 'SecurityError', - 'Failure should be a SecurityError'); - }); -}, 'Sandboxed iframe without allow-same-origin is denied access'); - -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html deleted file mode 100644 index 2658e1e50..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-add.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache.add and Cache.addAll</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-add"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-add.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html deleted file mode 100644 index 3d63a2f7f..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-delete.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache.delete</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-delete"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-delete.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html deleted file mode 100644 index 479a29d1e..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-match.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache.match</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-match"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-match.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html deleted file mode 100644 index c7e893a23..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-matchAll.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache.matchAll</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-matchall"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-matchAll.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html deleted file mode 100644 index 20aeb2351..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-put.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>Cache.put</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-put"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-put.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html deleted file mode 100644 index 71d995bc9..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-keys.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>CacheStorage.keys</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-storage-keys.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html deleted file mode 100644 index cd93410d2..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage-match.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>CacheStorage.match</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage-match"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-storage-match.js')); -</script> diff --git a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html b/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html deleted file mode 100644 index 0899609e4..000000000 --- a/testing/web-platform/tests/service-workers/cache-storage/worker/cache-storage.https.html +++ /dev/null @@ -1,9 +0,0 @@ -<!DOCTYPE html> -<title>CacheStorage</title> -<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-storage"> -<meta name="timeout" content="long"> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script> -fetch_tests_from_worker(new Worker('../script-tests/cache-storage.js')); -</script> |