Index: third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-add.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-add.js |
similarity index 84% |
copy from third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js |
copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-add.js |
index c3039b13deab2dc01b8b7b831fd4f9440cc9c25d..01fd605ad3637e898b3da83a57685921c4441254 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js |
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-add.js |
@@ -1,13 +1,13 @@ |
if (self.importScripts) { |
importScripts('/resources/testharness.js'); |
+ importScripts('../resources/testharness-helpers.js'); |
importScripts('../resources/test-helpers.js'); |
} |
-cache_test(function(cache, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
+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'); |
@@ -29,11 +29,10 @@ cache_test(function(cache) { |
}); |
}, 'Cache.add called with relative URL specified as a string'); |
-cache_test(function(cache, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
+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'); |
@@ -46,13 +45,12 @@ cache_test(function(cache) { |
}); |
}, 'Cache.add called with Request object'); |
-cache_test(function(cache, test) { |
+cache_test(function(cache) { |
var request = new Request('../resources/simple.txt', |
{method: 'POST', body: 'This is a body.'}); |
- return promise_rejects( |
- test, |
- new TypeError(), |
+ 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'); |
@@ -81,56 +79,35 @@ cache_test(function(cache) { |
.then(function() { |
return cache.add(request); |
}); |
- }, 'Cache.add called with Request object with a used body'); |
+ }, 'Cache.add with request with null body (not consumed)'); |
-cache_test(function(cache, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
+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, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
+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, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
- cache.add('../resources/fetch-status.php?status=206'), |
- 'Cache.add should reject on partial response'); |
- }, 'Cache.add with request that results in a status of 206'); |
- |
-cache_test(function(cache, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
- cache.addAll(['../resources/simple.txt', |
- '../resources/fetch-status.php?status=206']), |
- 'Cache.addAll should reject on partial response'); |
- }, 'Cache.addAll with request that results in a status of 206'); |
- |
-cache_test(function(cache, test) { |
- return promise_rejects( |
- test, |
- new TypeError(), |
+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, test) { |
+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 promise_rejects( |
- test, |
- new TypeError(), |
+ 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'); |
@@ -225,7 +202,7 @@ cache_test(function(cache) { |
}); |
}, 'Cache.addAll with Request arguments'); |
-cache_test(function(cache, test) { |
+cache_test(function(cache) { |
// Assumes that ../resources/simple.txt and ../resources/blank.html exist. |
// The second resource does not. |
var urls = ['../resources/simple.txt', |
@@ -234,30 +211,26 @@ cache_test(function(cache, test) { |
var requests = urls.map(function(url) { |
return new Request(url); |
}); |
- return promise_rejects( |
- test, |
- new TypeError(), |
+ 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); |
- })); |
- }) |
+ 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, test) { |
+cache_test(function(cache) { |
var request = new Request('../resources/simple.txt'); |
- return promise_rejects( |
- test, |
- 'InvalidStateError', |
+ 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'); |