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

Side by Side Diff: LayoutTests/http/tests/cachestorage/script-tests/cache-add.js

Issue 1032623008: Expose Cache Storage API in global window/worker scope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update webexposed expectations Created 5 years, 8 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
1 importScripts('worker-testharness.js'); 1 if (self.importScripts) {
2 importScripts('/resources/testharness-helpers.js'); 2 importScripts('/resources/testharness.js');
3 importScripts('/resources/testharness-helpers.js');
4 importScripts('../resources/test-helpers.js');
5 }
3 6
4 cache_test(function(cache) { 7 cache_test(function(cache) {
5 return assert_promise_rejects( 8 return assert_promise_rejects(
6 cache.add(), 9 cache.add(),
7 new TypeError(), 10 new TypeError(),
8 'Cache.add should throw a TypeError when no arguments are given.'); 11 'Cache.add should throw a TypeError when no arguments are given.');
9 }, 'Cache.add called with no arguments'); 12 }, 'Cache.add called with no arguments');
10 13
11 cache_test(function(cache) { 14 cache_test(function(cache) {
12 return cache.add('simple.txt') 15 return cache.add('../resources/simple.txt')
13 .then(function(result) { 16 .then(function(result) {
14 assert_equals(result, undefined, 17 assert_equals(result, undefined,
15 'Cache.add should resolve with undefined on success.'); 18 'Cache.add should resolve with undefined on success.');
16 }); 19 });
17 }, 'Cache.add called with relative URL specified as a string'); 20 }, 'Cache.add called with relative URL specified as a string');
18 21
19 cache_test(function(cache) { 22 cache_test(function(cache) {
20 return assert_promise_rejects( 23 return assert_promise_rejects(
21 cache.add('javascript://this-is-not-http-mmkay'), 24 cache.add('javascript://this-is-not-http-mmkay'),
22 'NetworkError', 25 'NetworkError',
23 'Cache.add should throw a NetworkError for non-HTTP/HTTPS URLs.'); 26 'Cache.add should throw a NetworkError for non-HTTP/HTTPS URLs.');
24 }, 'Cache.add called with non-HTTP/HTTPS URL'); 27 }, 'Cache.add called with non-HTTP/HTTPS URL');
25 28
26 cache_test(function(cache) { 29 cache_test(function(cache) {
27 var request = new Request('simple.txt', {method: 'POST', body: 'Hello'}); 30 var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
28 return cache.add(request) 31 return cache.add(request)
29 .then(function(result) { 32 .then(function(result) {
30 assert_equals(result, undefined, 33 assert_equals(result, undefined,
31 'Cache.add should resolve with undefined on success.'); 34 'Cache.add should resolve with undefined on success.');
32 }); 35 });
33 }, 'Cache.add called with Request object'); 36 }, 'Cache.add called with Request object');
34 37
35 cache_test(function(cache) { 38 cache_test(function(cache) {
36 var request = new Request('simple.txt', {method: 'POST', body: 'Hello'}); 39 var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
37 return request.text() 40 return request.text()
38 .then(function() { 41 .then(function() {
39 assert_true(request.bodyUsed); 42 assert_true(request.bodyUsed);
40 }) 43 })
41 .then(function() { 44 .then(function() {
42 return assert_promise_rejects( 45 return assert_promise_rejects(
43 cache.add(request), 46 cache.add(request),
44 new TypeError(), 47 new TypeError(),
45 'Cache.add with a Request object with a used body should reject ' + 48 'Cache.add with a Request object with a used body should reject ' +
46 'with a TypeError.'); 49 'with a TypeError.');
47 }); 50 });
48 }, 'Cache.add called with Request object with a used body'); 51 }, 'Cache.add called with Request object with a used body');
49 52
50 cache_test(function(cache) { 53 cache_test(function(cache) {
51 var request = new Request('simple.txt', {method: 'POST', body: 'Hello'}); 54 var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
52 return cache.add(request) 55 return cache.add(request)
53 .then(function(result) { 56 .then(function(result) {
54 assert_equals(result, undefined, 57 assert_equals(result, undefined,
55 'Cache.add should resolve with undefined on success.'); 58 'Cache.add should resolve with undefined on success.');
56 }) 59 })
57 .then(function() { 60 .then(function() {
58 return assert_promise_rejects( 61 return assert_promise_rejects(
59 cache.add(request), 62 cache.add(request),
60 new TypeError(), 63 new TypeError(),
61 'Cache.add should throw TypeError if same request is added twice.'); 64 'Cache.add should throw TypeError if same request is added twice.');
62 }); 65 });
63 }, 'Cache.add called twice with the same Request object'); 66 }, 'Cache.add called twice with the same Request object');
64 67
65 cache_test(function(cache) { 68 cache_test(function(cache) {
66 return cache.add('this-does-not-exist-please-dont-create-it') 69 return cache.add('this-does-not-exist-please-dont-create-it')
67 .then(function(result) { 70 .then(function(result) {
68 assert_equals(result, undefined, 71 assert_equals(result, undefined,
69 'Cache.add should resolve with undefined on success.'); 72 'Cache.add should resolve with undefined on success.');
70 }); 73 });
71 }, 'Cache.add with request that results in a status of 404'); 74 }, 'Cache.add with request that results in a status of 404');
72 75
73 cache_test(function(cache) { 76 cache_test(function(cache) {
74 return cache.add('fetch-status.php?status=500') 77 return cache.add('../resources/fetch-status.php?status=500')
75 .then(function(result) { 78 .then(function(result) {
76 assert_equals(result, undefined, 79 assert_equals(result, undefined,
77 'Cache.add should resolve with undefined on success.'); 80 'Cache.add should resolve with undefined on success.');
78 }); 81 });
79 }, 'Cache.add with request that results in a status of 500'); 82 }, 'Cache.add with request that results in a status of 500');
80 83
81 cache_test(function(cache) { 84 cache_test(function(cache) {
82 return assert_promise_rejects( 85 return assert_promise_rejects(
83 cache.addAll(), 86 cache.addAll(),
84 new TypeError(), 87 new TypeError(),
85 'Cache.addAll with no arguments should throw TypeError.'); 88 'Cache.addAll with no arguments should throw TypeError.');
86 }, 'Cache.addAll with no arguments'); 89 }, 'Cache.addAll with no arguments');
87 90
88 cache_test(function(cache) { 91 cache_test(function(cache) {
89 // Assumes the existence of simple.txt and blank.html in the same directory 92 // Assumes the existence of ../resources/simple.txt and ../resources/blank.h tml
90 // as this test script. 93 var urls = ['../resources/simple.txt', undefined, '../resources/blank.html'] ;
91 var urls = ['simple.txt', undefined, 'blank.html'];
92 return assert_promise_rejects( 94 return assert_promise_rejects(
93 cache.addAll(), 95 cache.addAll(),
94 new TypeError(), 96 new TypeError(),
95 'Cache.addAll should throw TypeError for an undefined argument.'); 97 'Cache.addAll should throw TypeError for an undefined argument.');
96 }, 'Cache.addAll with a mix of valid and undefined arguments'); 98 }, 'Cache.addAll with a mix of valid and undefined arguments');
97 99
98 cache_test(function(cache) { 100 cache_test(function(cache) {
99 // Assumes the existence of simple.txt and blank.html in the same directory 101 // Assumes the existence of ../resources/simple.txt and ../resources/blank.h tml
100 // as this test script. 102 var urls = ['../resources/simple.txt', self.location.href, '../resources/bla nk.html'];
101 var urls = ['simple.txt', self.location.href, 'blank.html'];
102 return cache.addAll(urls) 103 return cache.addAll(urls)
103 .then(function(result) { 104 .then(function(result) {
104 assert_equals(result, undefined, 105 assert_equals(result, undefined,
105 'Cache.addAll should resolve with undefined on ' + 106 'Cache.addAll should resolve with undefined on ' +
106 'success.'); 107 'success.');
107 }); 108 });
108 }, 'Cache.addAll with string URL arguments'); 109 }, 'Cache.addAll with string URL arguments');
109 110
110 cache_test(function(cache) { 111 cache_test(function(cache) {
111 // Assumes the existence of simple.txt and blank.html in the same directory 112 // Assumes the existence of ../resources/simple.txt and ../resources/blank.h tml
112 // as this test script. 113 var urls = ['../resources/simple.txt', self.location.href, '../resources/bla nk.html'];
113 var urls = ['simple.txt', self.location.href, 'blank.html'];
114 var requests = urls.map(function(url) { 114 var requests = urls.map(function(url) {
115 return new Request(url); 115 return new Request(url);
116 }); 116 });
117 return cache.addAll(requests) 117 return cache.addAll(requests)
118 .then(function(result) { 118 .then(function(result) {
119 assert_equals(result, undefined, 119 assert_equals(result, undefined,
120 'Cache.addAll should resolve with undefined on ' + 120 'Cache.addAll should resolve with undefined on ' +
121 'success.'); 121 'success.');
122 }); 122 });
123 }, 'Cache.addAll with Request arguments'); 123 }, 'Cache.addAll with Request arguments');
124 124
125 cache_test(function(cache) { 125 cache_test(function(cache) {
126 // Assumes that simple.txt and blank.html exist. The second 126 // Assumes that ../resources/simple.txt and ../resources/blank.html exist. T he second
127 // resource does not. 127 // resource does not.
128 var urls = ['simple.txt', 'this-resource-should-not-exist', 'blank.html']; 128 var urls = ['../resources/simple.txt', 'this-resource-should-not-exist', '.. /resources/blank.html'];
129 var requests = urls.map(function(url) { 129 var requests = urls.map(function(url) {
130 return new Request(url); 130 return new Request(url);
131 }); 131 });
132 return cache.addAll(requests) 132 return cache.addAll(requests)
133 .then(function(result) { 133 .then(function(result) {
134 assert_equals(result, undefined, 134 assert_equals(result, undefined,
135 'Cache.addAll should resolve with undefined on ' + 135 'Cache.addAll should resolve with undefined on ' +
136 'success.'); 136 'success.');
137 }); 137 });
138 }, 'Cache.addAll with a mix of succeeding and failing requests'); 138 }, 'Cache.addAll with a mix of succeeding and failing requests');
139 139
140 cache_test(function(cache) { 140 cache_test(function(cache) {
141 var request = new Request('simple.txt'); 141 var request = new Request('../resources/simple.txt');
142 return assert_promise_rejects( 142 return assert_promise_rejects(
143 cache.addAll([request, request]), 143 cache.addAll([request, request]),
144 new TypeError(), 144 new TypeError(),
145 'Cache.addAll should throw TypeError if the same request is added ' + 145 'Cache.addAll should throw TypeError if the same request is added ' +
146 'twice.'); 146 'twice.');
147 }, 'Cache.addAll called with the same Request object specified twice'); 147 }, 'Cache.addAll called with the same Request object specified twice');
148
149 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698