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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/cache-put-test-worker.js

Issue 425413002: [ServiceWorker] Tests for Cache (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 importScripts('worker-test-harness.js');
2
3 promise_test(function(t) {
4 var request = new Request('http://example.com/foo', {method: 'GET'});
5 var response = new Response(
6 'Hello, world!', {
jsbell 2014/08/01 00:02:25 This line break is weird.
asanka 2014/08/13 03:30:04 Indeed. Fixed.
7 status: 200,
8 statusText: 'OK',
9 headers: [['Content-Type', 'text/plain']]
10 });
11 return new Cache().put(request, response)
12 .then(t.step_func(function(result) {
13 assert_equals(result,
14 response,
15 'Cache.put should resolve with the response ' +
16 'parameter.');
17 }));
18 }, 'Cache.put with a valid request');
19
20 promise_test(function(t) {
21 var request = new Request('http://example.com/foo', {method: 'HEAD'});
22 var response = new Response('Hello, world!', {
23 status: 200,
24 statusText: 'OK',
25 headers: [['Content-Type', 'text/plain']]
26 });
27 return new Cache().put(request, response)
28 .then(t.unreached_func('Cache.put should not accept non-GET requests.'))
29 .catch(t.step_func(function(e) {
30 assert_true(e instanceof TypeError,
31 'Cache.put should throw a TypeError for non-GET ' +
32 'requests');
33 }));
34 }, 'Cache.put with a non-GET request');
35
36 promise_test(function(t) {
37 var request = new Request('http://example.com/foo', {method: 'HEAD'});
38 return new Cache().put(request, null)
39 .then(t.unreached_func('Cache.put should not accept empty responses.'))
40 .catch(t.step_func(function(e) {
41 assert_true(e instanceof TypeError,
42 'Cache.put should throw a TypeError for an empty ' +
43 'response');
44 }));
45 }, 'Cache.put with an empty response');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698