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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html

Issue 1969403004: Expose and check origin of request in response for foreign fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@set-request-and-credentials-mode
Patch Set: update layouttests Created 4 years, 7 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/serviceworker/foreign-fetch-basics.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
index 0107c3288fe438053403aafc3cdf849a4908d996..4c97bdcb84fb63dc5da1e991a0aa8eed5e9cbb6a 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
@@ -3,6 +3,7 @@
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/get-host-info.js"></script>
<script src="resources/test-helpers.js"></script>
+<script src="resources/foreign-fetch-helpers.js"></script>
<body>
<script>
var host_info = get_host_info();
@@ -19,22 +20,6 @@ function worker_for_scopes(relative_scopes) {
return worker + encodeURIComponent(JSON.stringify(params));
}
-function install_cross_origin_worker(t, worker, scope) {
- return with_iframe(host_info.HTTPS_REMOTE_ORIGIN +
- '/serviceworker/resources/install-worker-helper.html')
- .then(frame => new Promise((resolve, reject) => {
- var channel = new MessageChannel();
- frame.contentWindow.postMessage({worker: worker,
- options: {scope: scope},
- port: channel.port1},
- '*', [channel.port1]);
- channel.port2.onmessage = reply => {
- if (reply.data == 'success') resolve();
- else reject(reply.data);
- };
- }));
-}
-
function intercepted_url(scope) {
return host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' +
scope + '/intercept/foo?basic';
@@ -146,5 +131,31 @@ promise_test(t => {
});
}, 'Foreign fetch can intercept requests from SW controlled pages.');
+promise_test(t => {
+ var scope = 'simple.txt?meta';
+ var remote_url =
+ host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope;
+ return install_cross_origin_worker(t, worker_for_scopes(['']), scope)
+ .then(() => fetch(remote_url, {mode: 'no-cors'}))
+ .then(response => response.json())
+ .then(response_data => {
+ assert_equals(self.location.href, response_data.referrer);
+ assert_equals(self.location.origin, response_data.origin);
+ })
+ .then(() => with_iframe('resources/blank.html'))
+ .then(frame => {
+ var meta = frame.contentDocument.createElement('meta');
+ meta.setAttribute('name', 'referrer');
+ meta.setAttribute('content', 'no-referrer');
+ frame.contentDocument.head.appendChild(meta);
+ return frame.contentWindow.fetch(remote_url, {mode: 'no-cors'});
+ })
+ .then(response => response.json())
+ .then(response_data => {
+ assert_equals('', response_data.referrer);
+ assert_equals('null', response_data.origin);
+ });
+ }, 'Referrer and origin are set correctly in ForeignFetchEvent.');
+
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698