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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-match.js

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Created 4 years, 2 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/imported/wpt/service-workers/cache-storage/script-tests/cache-match.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-match.js
similarity index 65%
copy from third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js
copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-match.js
index 30d9f5b7f3f55130d0479fdd8e55fecb1d91d558..716bfe5a69804114693b6c93665db78bdfeca9c9 100644
--- a/third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-match.js
@@ -1,5 +1,6 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
+ importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
@@ -28,23 +29,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- var alt_response = new Response('', {status: 201});
-
- return self.caches.open('second_matching_cache')
- .then(function(cache) {
- return cache.put(entries.a.request, alt_response.clone());
- })
- .then(function() {
- return cache.match(entries.a.request)
- })
- .then(function(result) {
- assert_response_equals(
- result, entries.a.response,
- 'Cache.match should match the first cache.');
- });
- }, 'Cache.match with multiple cache hits');
-
-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,
@@ -53,14 +37,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with new Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.match(new Request(entries.a.request.url, {method: 'HEAD'}))
- .then(function(result) {
- assert_equals(result, undefined,
- 'Cache.match should not match HEAD Request.');
- });
- }, 'Cache.match with HEAD');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request,
{ignoreSearch: true})
.then(function(result) {
@@ -93,56 +69,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
},
'Cache.match with ignoreSearch option (request with search parameter)');
-cache_test(function(cache) {
- var request = new Request('http://example.com/');
- var head_request = new Request('http://example.com/', {method: 'HEAD'});
- var response = new Response('foo');
- return cache.put(request.clone(), response.clone())
- .then(function() {
- return cache.match(head_request.clone());
- })
- .then(function(result) {
- assert_equals(
- result, undefined,
- 'Cache.match should resolve as undefined with a ' +
- 'mismatched method.');
- return cache.match(head_request.clone(),
- {ignoreMethod: true});
- })
- .then(function(result) {
- assert_response_equals(
- result, response,
- 'Cache.match with ignoreMethod should ignore the ' +
- 'method of request.');
- });
- }, 'Cache.match supports ignoreMethod');
-
-cache_test(function(cache) {
- var vary_request = new Request('http://example.com/c',
- {headers: {'Cookies': 'is-for-cookie'}});
- var vary_response = new Response('', {headers: {'Vary': 'Cookies'}});
- var mismatched_vary_request = new Request('http://example.com/c');
-
- return cache.put(vary_request.clone(), vary_response.clone())
- .then(function() {
- return cache.match(mismatched_vary_request.clone());
- })
- .then(function(result) {
- assert_equals(
- result, undefined,
- 'Cache.match should resolve as undefined with a ' +
- 'mismatched vary.');
- return cache.match(mismatched_vary_request.clone(),
- {ignoreVary: true});
- })
- .then(function(result) {
- assert_response_equals(
- result, vary_response,
- 'Cache.match with ignoreVary should ignore the ' +
- 'vary of request.');
- });
- }, 'Cache.match supports ignoreVary');
-
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.cat.request.url + '#mouse')
.then(function(result) {
@@ -233,36 +159,6 @@ cache_test(function(cache) {
});
}, 'Cache.match invoked multiple times for the same Request/Response');
-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.blob();
- })
- .then(function(blob) {
- sliced = blob.slice(2,8);
-
- return new Promise(function (resolve, reject) {
- reader = new FileReader();
- reader.onloadend = function(event) {
- resolve(event.target.result);
- }
- reader.readAsText(sliced);
- });
- })
- .then(function(text) {
- assert_equals(text, 'simple',
- 'A Response blob returned by Cache.match should be ' +
- 'sliceable.' );
- });
- }, 'Cache.match blob should be sliceable');
-
prepopulated_cache_test(simple_entries, function(cache, entries) {
var request = new Request(entries.a.request.clone(), {method: 'POST'});
return cache.match(request)

Powered by Google App Engine
This is Rietveld 408576698