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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-foreign-fetch-service-worker.html

Issue 2770213002: Add LayoutTest for a bug of Suborigin and MemoryCache and ForeignFetch
Patch Set: Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/sw-scope/test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-foreign-fetch-service-worker.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-foreign-fetch-service-worker.html b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-foreign-fetch-service-worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..1e58f2a54bbf9d5922d92071bd7f74cfe06df5aa
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-foreign-fetch-service-worker.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>ff</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../serviceworker/resources/test-helpers.js"></script>
+<script src = "/resources/get-host-info.js?pipe=sub"></script>
+<body>
+<script>
+var run;
+
+promise_test(t => {
+ var host_info = get_host_info();
+ var frame_url = host_info['HTTP_REMOTE_ORIGIN'] +
+ '/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.html';
+ var unregisteredPromise;
+ var frame;
+ var port;
+ return with_iframe(frame_url)
+ .then(f => {
+ frame = f;
+ var resolveActivated;
+ var activatedPromise = new Promise(r => { resolveActivated = r;});
+ var resolveUnregistered;
+ unregisteredPromise = new Promise(r => { resolveUnregistered = r;});
+ var channel = new MessageChannel();
+ port = channel.port1;
+ channel.port1.onmessage = function(e) {
+ if (e.data === 'activated') {
+ resolveActivated(e.data);
+ } else if (e.data === 'unregistered') {
+ resolveUnregistered(e.data);
+ }
+ };
+ frame.contentWindow.postMessage('register', '*', [channel.port2]);
+ return activatedPromise;
+ })
+ .then(data => {
+ assert_equals(data, 'activated');
+ var script = document.createElement('script');
+ script.src = host_info['HTTP_REMOTE_ORIGIN'] +
+ '/security/suborigins/resources/sw-scope/test.js';
+ var resolve;
+ var p = new Promise(r => { run = r; });
+ document.body.appendChild(script);
+ return p;
+ })
+ .then(data => {
+ assert_equals(data, 'from foreignfetch');
+ var resolve;
+ var p = new Promise(r => { resolve = r; });
+ window.onmessage = event => { resolve(event.data); };
+ with_iframe('./resources/suborigin-foreign-fetch-service-worker-iframe.php');
+ return p;
+ })
+ .then(data => {
+ // Suborigin is set for suborigin-foreign-fetch-service-worker-iframe.php.
+ // So the script loaded in the iframe must be served from server.
+ assert_equals(data, 'from server');
+ port.postMessage('unregister');
+ return unregisteredPromise;
+ })
+ .then(data => {
+ assert_equals(data, 'unregistered');
+ });
+}, 'a.');
+</script>
+</body>
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/sw-scope/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698