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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.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 | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.php » ('j') | 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/resources/suborigin-foreign-fetch-service-worker-iframe.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.html b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..0beda1d03d4c5f0b0e5a2f6cb01164954d744125
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<script>
+var scope = './sw-scope/';
+var script = 'suborigin-foreign-fetch-service-worker-worker.js';
+var registration;
+var port;
+
+function wait_for_activated(worker) {
+ var state = 'activated';
+ if (!worker)
+ return Promise.reject(new Error('No ServiceWorker'));
+ if (worker.state === 'redundant')
+ return Promise.reject(new Error('Worker is redundant'));
+ if (worker.state === state)
+ return Promise.resolve(state);
+ return new Promise(resolve => {
+ worker.addEventListener('statechange', _ => {
+ if (worker.state === state)
+ resolve(state);
+ });
+ });
+}
+
+self.onmessage = function(e) {
+ if (e.data == 'register') {
+ port = e.ports[0];
+ port.onmessage = function(e) {
+ if (e.data == 'unregister') {
+ registration.unregister()
+ .then(function() {
+ port.postMessage('unregistered');
+ });
+ }
+ };
+ }
+
+ navigator.serviceWorker.register(script, { scope: scope })
+ .then(function(r) {
+ registration = r;
+ var worker = registration.active;
+ if (!worker) {
+ worker = registration.installing;
+ }
+ return wait_for_activated(worker);
+ })
+ .then(function() {
+ e.ports[0].postMessage('activated');
+ });
+};
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/suborigins/resources/suborigin-foreign-fetch-service-worker-iframe.php » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698