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

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_result_callback(() => r.unregister());
33 return wait_for_state(t, r.installing, 'activated');
34 }).then(() => {
nhiroki 2016/07/29 03:54:46 Can you put "})" and ".then" to separate lines: r
35 return with_iframe(SCOPE);
36 }).then(frame => {
nhiroki 2016/07/29 03:54:46 Can you add "add_completion_callback(() => frame.r
yhirano 2016/07/29 05:50:19 Adding it breaks the test: Maybe it's executed whe
nhiroki 2016/07/29 06:21:21 I suspect you used add_result_callback() instead o
yhirano 2016/07/29 06:26:43 Ah, sorry, you're right. Fixed.
37 for (const [url, referrer, referrer_policy, expected_referrer,
38 expected_referrer_policy] of TESTS) {
39 promise_test(t => {
40 // Use |frame.contentWindow.fetch| so that the fetch request
41 // is intercepted by the service worker.
42 return frame.contentWindow.fetch(url,
43 {referrer: referrer, referrerPolicy: referrer_policy})
44 .then(res => res.text())
45 .then(text => {
46 assert_equals(text, JSON.stringify({
47 referrer: expected_referrer,
48 referrerPolicy: expected_referrer_policy,
49 }));
50 });
51 }, `url = ${url}, referrer = ${referrer}, policy = ${referrer_policy }`);
52 }
53 done();
nhiroki 2016/07/29 03:54:46 "done()" might not be necessary because outer prom
yhirano 2016/07/29 05:50:19 Done.
54 });
55 });
9 </script> 56 </script>
10 </html> 57 </html>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/referrer/resources/serviceworker-echo-referrer-from-default-document.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698