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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/request-worker.js

Issue 721103003: [ServiceWorker] Serialize request.referrer to "about:client" when it's client. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 1 month 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 importScripts('worker-testharness.js'); 1 importScripts('worker-testharness.js');
2 importScripts('../../resources/testharness-helpers.js'); 2 importScripts('../../resources/testharness-helpers.js');
3 importScripts('test-helpers.js'); 3 importScripts('test-helpers.js');
4 4
5 var URL = 'https://www.example.com/test.html'; 5 var URL = 'https://www.example.com/test.html';
6 6
7 function size(headers) { 7 function size(headers) {
8 var count = 0; 8 var count = 0;
9 for (var header of headers) { 9 for (var header of headers) {
10 ++count; 10 ++count;
11 } 11 }
12 return count; 12 return count;
13 } 13 }
14 14
15 test(function() { 15 test(function() {
16 var headers = new Headers; 16 var headers = new Headers;
17 headers.set('User-Agent', 'Mozilla/5.0'); 17 headers.set('User-Agent', 'Mozilla/5.0');
18 headers.set('Accept', 'text/html'); 18 headers.set('Accept', 'text/html');
19 headers.set('X-ServiceWorker-Test', 'request test field'); 19 headers.set('X-ServiceWorker-Test', 'request test field');
20 20
21 var request = new Request(URL, {method: 'GET', headers: headers}); 21 var request = new Request(URL, {method: 'GET', headers: headers});
22 22
23 assert_equals(request.url, URL, 'Request.url should match'); 23 assert_equals(request.url, URL, 'Request.url should match');
24 assert_equals(request.method, 'GET', 'Request.method should match'); 24 assert_equals(request.method, 'GET', 'Request.method should match');
25 assert_equals(request.referrer, location.href, 25 assert_equals(request.referrer, 'about:client',
26 'Request.referrer should match'); 26 'Request.referrer should be about:client');
27 assert_true(request.headers instanceof Headers, 27 assert_true(request.headers instanceof Headers,
28 'Request.headers should be Headers'); 28 'Request.headers should be Headers');
29 29
30 // 'User-Agent' is a forbidden header. 30 // 'User-Agent' is a forbidden header.
31 assert_equals(size(request.headers), 2, 31 assert_equals(size(request.headers), 2,
32 'Request.headers size should match'); 32 'Request.headers size should match');
33 // Note: detailed behavioral tests for Headers are in another test, 33 // Note: detailed behavioral tests for Headers are in another test,
34 // http/tests/serviceworker/headers.html. 34 // http/tests/serviceworker/headers.html.
35 35
36 request.url = 'http://localhost/'; 36 request.url = 'http://localhost/';
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 result, expected_body, 486 result, expected_body,
487 'Creating a Request with FormData body should success.'); 487 'Creating a Request with FormData body should success.');
488 }) 488 })
489 .then(function() { 489 .then(function() {
490 t.done(); 490 t.done();
491 }) 491 })
492 .catch(unreached_rejection(t)); 492 .catch(unreached_rejection(t));
493 assert_true(request.bodyUsed, 493 assert_true(request.bodyUsed,
494 'bodyUsed must be true after calling text()'); 494 'bodyUsed must be true after calling text()');
495 }, 'Request body test in ServiceWorkerGlobalScope'); 495 }, 'Request body test in ServiceWorkerGlobalScope');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698