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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/fetch/referrer/serviceworker-echo-referrer-from-default-document.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/fetch/referrer/serviceworker-echo-referrer-from-default-document.html b/third_party/WebKit/LayoutTests/http/tests/fetch/referrer/serviceworker-echo-referrer-from-default-document.html
index 2e974649812152bda2a99298c8dcc2ef9580ea8a..c3b883f9d760af9b536c8d2adcac437be342619b 100644
--- a/third_party/WebKit/LayoutTests/http/tests/fetch/referrer/serviceworker-echo-referrer-from-default-document.html
+++ b/third_party/WebKit/LayoutTests/http/tests/fetch/referrer/serviceworker-echo-referrer-from-default-document.html
@@ -3,8 +3,55 @@
<title>Echo referrer in ServiceWorker: from a document with the default referrer policy</title>
<script src = "/resources/testharness.js"></script>
<script src = "/resources/testharnessreport.js"></script>
+<script src = "/serviceworker/resources/test-helpers.js"></script>
+<script src = "/fetch/resources/fetch-test-helpers.js"></script>
+<script src = "/fetch/resources/fetch-test-options.js"></script>
<script>
-location =
- '/fetch/referrer/resources/serviceworker-echo-referrer-from-default-document.html';
+const SCRIPT = '/fetch/referrer/resources/echo-referrer.js';
+const SCOPE = '/fetch/referrer/resources/empty.html';
+const URL = BASE_ORIGIN + '/fetch/resources/echo';
+const REFERRER_SOURCE = BASE_ORIGIN + SCOPE;
+
+const TESTS = [
+ [URL, 'about:client',
+ '', REFERRER_SOURCE, 'no-referrer-when-downgrade'],
+ [URL, 'about:client', 'no-referrer',
+ '', 'no-referrer'],
+ [URL, 'about:client', 'no-referrer-when-downgrade',
+ REFERRER_SOURCE, 'no-referrer-when-downgrade'],
+ [URL, 'about:client', 'origin',
+ BASE_ORIGIN + '/', 'origin'],
+ [URL, 'about:client', 'origin-when-cross-origin',
+ REFERRER_SOURCE, 'origin-when-cross-origin'],
+ [URL, 'about:client', 'unsafe-url',
+ REFERRER_SOURCE, 'unsafe-url'],
+];
+
+promise_test(t => {
+ return service_worker_unregister_and_register(t, SCRIPT, SCOPE).then(r => {
+ add_completion_callback(() => r.unregister());
nhiroki 2016/07/29 06:55:13 Just for clarification: In this case, both add_res
+ return wait_for_state(t, r.installing, 'activated');
+ }).then(() => {
+ return with_iframe(SCOPE);
+ }).then(frame => {
+ add_completion_callback(() => frame.remove());
+ for (const [url, referrer, referrer_policy, expected_referrer,
+ expected_referrer_policy] of TESTS) {
+ promise_test(t => {
+ // Use |frame.contentWindow.fetch| so that the fetch request
+ // is intercepted by the service worker.
+ return frame.contentWindow.fetch(url,
+ {referrer: referrer, referrerPolicy: referrer_policy})
+ .then(res => res.text())
+ .then(text => {
+ assert_equals(text, JSON.stringify({
+ referrer: expected_referrer,
+ referrerPolicy: expected_referrer_policy,
+ }));
+ });
+ }, `url = ${url}, referrer = ${referrer}, policy = ${referrer_policy}`);
+ }
+ });
+ });
</script>
</html>

Powered by Google App Engine
This is Rietveld 408576698