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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/referrer/serviceworker-echo-referrer-from-default-document.html

Issue 2192743002: Rewrite Fetch API referrer layout tests with service worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 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 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <title>Echo referrer in ServiceWorker: from a document with the default referrer policy</title> 3 <title>Echo referrer in ServiceWorker: from a document with the default referrer policy</title>
4 <script src = "/resources/testharness.js"></script> 4 <script src = "/resources/testharness.js"></script>
5 <script src = "/resources/testharnessreport.js"></script> 5 <script src = "/resources/testharnessreport.js"></script>
6 <script src = "/serviceworker/resources/test-helpers.js"></script>
7 <script src = "/fetch/resources/fetch-test-helpers.js"></script>
8 <script src = "/fetch/resources/fetch-test-options.js"></script>
6 <script> 9 <script>
7 location = 10 const SCRIPT = '/fetch/referrer/resources/echo-referrer.js';
8 '/fetch/referrer/resources/serviceworker-echo-referrer-from-default-document.h tml'; 11 const SCOPE = '/fetch/referrer/resources/empty.html';
12 const URL = BASE_ORIGIN + '/fetch/resources/echo';
13 const REFERRER_SOURCE = BASE_ORIGIN + SCOPE;
14
15 const TESTS = [
16 [URL, 'about:client',
17 '', REFERRER_SOURCE, 'no-referrer-when-downgrade'],
18 [URL, 'about:client', 'no-referrer',
19 '', 'no-referrer'],
20 [URL, 'about:client', 'no-referrer-when-downgrade',
21 REFERRER_SOURCE, 'no-referrer-when-downgrade'],
22 [URL, 'about:client', 'origin',
23 BASE_ORIGIN + '/', 'origin'],
24 [URL, 'about:client', 'origin-when-cross-origin',
25 REFERRER_SOURCE, 'origin-when-cross-origin'],
26 [URL, 'about:client', 'unsafe-url',
27 REFERRER_SOURCE, 'unsafe-url'],
28 ];
29
30 promise_test(t => {
31 return service_worker_unregister_and_register(t, SCRIPT, SCOPE).then(r => {
32 add_completion_callback(() => r.unregister());
nhiroki 2016/07/29 06:55:13 Just for clarification: In this case, both add_res
33 return wait_for_state(t, r.installing, 'activated');
34 }).then(() => {
35 return with_iframe(SCOPE);
36 }).then(frame => {
37 add_completion_callback(() => frame.remove());
38 for (const [url, referrer, referrer_policy, expected_referrer,
39 expected_referrer_policy] of TESTS) {
40 promise_test(t => {
41 // Use |frame.contentWindow.fetch| so that the fetch request
42 // is intercepted by the service worker.
43 return frame.contentWindow.fetch(url,
44 {referrer: referrer, referrerPolicy: referrer_policy})
45 .then(res => res.text())
46 .then(text => {
47 assert_equals(text, JSON.stringify({
48 referrer: expected_referrer,
49 referrerPolicy: expected_referrer_policy,
50 }));
51 });
52 }, `url = ${url}, referrer = ${referrer}, policy = ${referrer_policy }`);
53 }
54 });
55 });
9 </script> 56 </script>
10 </html> 57 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698