Commit 2c5b0abf authored by jsbell@chromium.org's avatar jsbell@chromium.org

Update Cache.put() test to accept string as request

Per spec, the method signature is:

Promise<Response> put((Request or USVString) request, Response response);

So passing a string for request is perfectly valid. And thanks to the
wonders of Web IDL + JavaScript, anything else passed in other than a
Request will be coerced to a string, too.

R=asanka@chromium.org
BUG=374802

Review URL: https://codereview.chromium.org/677533002

git-svn-id: svn://svn.chromium.org/blink/trunk@184371 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7c4f0080
......@@ -7,7 +7,7 @@ FAIL Cache.put with a Response containing an empty URL assert_equals: Cache.put
PASS Cache.put with an empty response body
PASS Cache.put with HTTP 500 response
FAIL Cache.put called twice with same Request and different Responses Entry already exists.
FAIL Cache.put with an invalid request assert_promise_rejects: Cache.put should only accept a Request object as the request. Promise did not reject.
PASS Cache.put with an string request
PASS Cache.put with an invalid response
PASS Cache.put with a non-HTTP/HTTPS request
FAIL Cache.put with a relative URL assert_equals: Cache.put should accept a relative URL as the request. :[object].url expected "" but got "http://127.0.0.1:8000/serviceworker/resources/relative-url"
......
......@@ -154,11 +154,15 @@ cache_test(function(cache) {
}, 'Cache.put called twice with same Request and different Responses');
cache_test(function(cache) {
return assert_promise_rejects(
cache.put('http://example.com/foo', new_test_response()),
new TypeError(),
'Cache.put should only accept a Request object as the request.');
}, 'Cache.put with an invalid request');
var url = 'http://example.com/foo';
return cache.put(url, new_test_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 an string request');
cache_test(function(cache) {
return assert_promise_rejects(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment