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

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/fetch.js

Issue 1292503002: [Fetch] Unship Request.context (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 5 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
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('../resources/fetch-test-helpers.js'); 2 importScripts('../resources/fetch-test-helpers.js');
3 } 3 }
4 4
5 promise_test(function(t) { 5 promise_test(function(t) {
6 return fetch('http://') 6 return fetch('http://')
7 .then( 7 .then(
8 t.unreached_func('fetch of invalid URL must fail'), 8 t.unreached_func('fetch of invalid URL must fail'),
9 function() {}); 9 function() {});
10 }, 'Fetch invalid URL'); 10 }, 'Fetch invalid URL');
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 }, 'Fetch result of 404 response'); 48 }, 'Fetch result of 404 response');
49 49
50 promise_test(function(t) { 50 promise_test(function(t) {
51 var request = new Request( 51 var request = new Request(
52 '/fetch/resources/fetch-status.php?status=200#fragment'); 52 '/fetch/resources/fetch-status.php?status=200#fragment');
53 53
54 // The url attribute's getter must return request's url, 54 // The url attribute's getter must return request's url,
55 // serialized with the exclude fragment flag set. 55 // serialized with the exclude fragment flag set.
56 assert_equals(request.url, 56 assert_equals(request.url,
57 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200'); 57 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200');
58 assert_equals(request.context, '');
59 58
60 return fetch(request) 59 return fetch(request)
61 .then(function(response) { 60 .then(function(response) {
62 assert_equals(response.status, 200); 61 assert_equals(response.status, 200);
63 assert_equals(response.statusText, 'OK'); 62 assert_equals(response.statusText, 'OK');
64 // The url attribute's getter must return the empty string 63 // The url attribute's getter must return the empty string
65 // if response's url is null and response's url, 64 // if response's url is null and response's url,
66 // serialized with the exclude fragment flag set, otherwise. 65 // serialized with the exclude fragment flag set, otherwise.
67 assert_equals(response.url, 66 assert_equals(response.url,
68 BASE_ORIGIN + 67 BASE_ORIGIN +
69 '/fetch/resources/fetch-status.php?status=200'); 68 '/fetch/resources/fetch-status.php?status=200');
70 assert_equals(request.context, '');
71 }); 69 });
72 }, 'Request/response url attribute getter with fragment'); 70 }, 'Request/response url attribute getter with fragment');
73 71
74 promise_test(function(t) { 72 promise_test(function(t) {
75 var redirect_target_url = 73 var redirect_target_url =
76 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200'; 74 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200';
77 var redirect_original_url = 75 var redirect_original_url =
78 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' + 76 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' +
79 redirect_target_url; 77 redirect_target_url;
80 78
81 var request = new Request(redirect_original_url); 79 var request = new Request(redirect_original_url);
82 assert_equals(request.url, redirect_original_url, 80 assert_equals(request.url, redirect_original_url,
83 'Request\'s url is the original URL'); 81 'Request\'s url is the original URL');
84 assert_equals(request.context, '');
85 assert_equals(request.redirect, 'follow'); 82 assert_equals(request.redirect, 'follow');
86 83
87 return fetch(request) 84 return fetch(request)
88 .then(function(response) { 85 .then(function(response) {
89 assert_equals(response.status, 200); 86 assert_equals(response.status, 200);
90 assert_equals(response.statusText, 'OK'); 87 assert_equals(response.statusText, 'OK');
91 assert_equals(response.url, redirect_target_url, 88 assert_equals(response.url, redirect_target_url,
92 'Response\'s url is locationURL'); 89 'Response\'s url is locationURL');
93 assert_equals(request.url, redirect_original_url, 90 assert_equals(request.url, redirect_original_url,
94 'Request\'s url remains the original URL'); 91 'Request\'s url remains the original URL');
95 assert_equals(request.context, '');
96 }); 92 });
97 }, 'Request/response url attribute getter with redirect'); 93 }, 'Request/response url attribute getter with redirect');
98 94
99 promise_test(function(t) { 95 promise_test(function(t) {
100 var redirect_target_url = 96 var redirect_target_url =
101 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200'; 97 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200';
102 var redirect_original_url = 98 var redirect_original_url =
103 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' + 99 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' +
104 redirect_target_url; 100 redirect_target_url;
105 101
106 var request = new Request(redirect_original_url, {redirect: 'manual'}); 102 var request = new Request(redirect_original_url, {redirect: 'manual'});
107 assert_equals(request.url, redirect_original_url, 103 assert_equals(request.url, redirect_original_url,
108 'Request\'s url is the original URL'); 104 'Request\'s url is the original URL');
109 assert_equals(request.context, '');
110 assert_equals(request.redirect, 'manual'); 105 assert_equals(request.redirect, 'manual');
111 106
112 return fetch(request) 107 return fetch(request)
113 .then(function(response) { 108 .then(function(response) {
114 assert_equals(response.status, 0); 109 assert_equals(response.status, 0);
115 assert_equals(response.type, 'opaqueredirect'); 110 assert_equals(response.type, 'opaqueredirect');
116 assert_equals(response.url, ''); 111 assert_equals(response.url, '');
117 }); 112 });
118 }, 'Manual redirect fetch returns opaque redirect response'); 113 }, 'Manual redirect fetch returns opaque redirect response');
119 114
120 promise_test(function(t) { 115 promise_test(function(t) {
121 var redirect_target_url = 116 var redirect_target_url =
122 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200'; 117 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200';
123 var redirect_original_url = 118 var redirect_original_url =
124 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' + 119 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' +
125 redirect_target_url; 120 redirect_target_url;
126 121
127 var request = new Request(redirect_original_url, {redirect: 'error'}); 122 var request = new Request(redirect_original_url, {redirect: 'error'});
128 assert_equals(request.url, redirect_original_url, 123 assert_equals(request.url, redirect_original_url,
129 'Request\'s url is the original URL'); 124 'Request\'s url is the original URL');
130 assert_equals(request.context, '');
131 assert_equals(request.redirect, 'error'); 125 assert_equals(request.redirect, 'error');
132 126
133 return fetch(request) 127 return fetch(request)
134 .then( 128 .then(
135 t.unreached_func('Redirect response must cause an error when redirct' + 129 t.unreached_func('Redirect response must cause an error when redirct' +
136 ' mode is error.'), 130 ' mode is error.'),
137 function() {}); 131 function() {});
138 }, 'Redirect response must cause an error when redirct mode is error.'); 132 }, 'Redirect response must cause an error when redirct mode is error.');
139 133
140 promise_test(function(test) { 134 promise_test(function(test) {
(...skipping 28 matching lines...) Expand all
169 }); 163 });
170 } 164 }
171 165
172 promise_test(function(t) { 166 promise_test(function(t) {
173 var request = 167 var request =
174 new Request('/serviceworker/resources/fetch-access-control.php', 168 new Request('/serviceworker/resources/fetch-access-control.php',
175 { 169 {
176 method: 'POST', 170 method: 'POST',
177 body: new Blob(['Test Blob'], {type: 'test/type'}) 171 body: new Blob(['Test Blob'], {type: 'test/type'})
178 }); 172 });
179 assert_equals(request.context, '');
180 return fetch(request) 173 return fetch(request)
181 .then(function(response) { return response.text(); }) 174 .then(function(response) { return response.text(); })
182 .then(evalJsonp) 175 .then(evalJsonp)
183 .then(function(result) { 176 .then(function(result) {
184 assert_equals(result.method, 'POST'); 177 assert_equals(result.method, 'POST');
185 assert_equals(result.body, 'Test Blob'); 178 assert_equals(result.body, 'Test Blob');
186 assert_equals(request.context, '');
187 }); 179 });
188 }, 'Fetch with Blob body test'); 180 }, 'Fetch with Blob body test');
189 181
190 promise_test(function(t) { 182 promise_test(function(t) {
191 var request = new Request( 183 var request = new Request(
192 '/serviceworker/resources/fetch-access-control.php', 184 '/serviceworker/resources/fetch-access-control.php',
193 {method: 'POST', body: 'Test String'}); 185 {method: 'POST', body: 'Test String'});
194 return fetch(request) 186 return fetch(request)
195 .then(function(response) { return response.text(); }) 187 .then(function(response) { return response.text(); })
196 .then(evalJsonp) 188 .then(evalJsonp)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 function runInfiniteFetchLoop() { 266 function runInfiniteFetchLoop() {
275 fetch('dummy.html') 267 fetch('dummy.html')
276 .then(function() { runInfiniteFetchLoop(); }); 268 .then(function() { runInfiniteFetchLoop(); });
277 } 269 }
278 runInfiniteFetchLoop(); 270 runInfiniteFetchLoop();
279 }, 271 },
280 'Destroying the execution context while fetch is happening should not ' + 272 'Destroying the execution context while fetch is happening should not ' +
281 'cause a crash.'); 273 'cause a crash.');
282 274
283 done(); 275 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698