Index: LayoutTests/http/tests/serviceworker/resources/frame-for-getregistrations.html |
diff --git a/LayoutTests/http/tests/serviceworker/resources/frame-for-getregistrations.html b/LayoutTests/http/tests/serviceworker/resources/frame-for-getregistrations.html |
index 511bd972090cc01e0bed798a2b2e6ac65b37ebc2..474004ff0a959c95372fe0ca29941ebad0bad092 100644 |
--- a/LayoutTests/http/tests/serviceworker/resources/frame-for-getregistrations.html |
+++ b/LayoutTests/http/tests/serviceworker/resources/frame-for-getregistrations.html |
@@ -4,16 +4,27 @@ |
var scope = 'scope-for-getregistrations'; |
var script = 'empty-worker.js'; |
var registration; |
- |
-navigator.serviceWorker.register(script, { scope: scope }) |
- .then(function(r) { registration = r; }); |
+var port; |
self.onmessage = function(e) { |
- if (e.data == 'unregister') { |
- registration.unregister() |
- .then(function() { |
- e.ports[0].postMessage('unregistered'); |
- }); |
+ if (e.data == 'register') { |
+ port = e.ports[0]; |
+ port.onmessage = function(e) { |
+ if (e.data == 'unregister') { |
+ registration.unregister() |
+ .then(function() { |
+ port.postMessage('unregistered'); |
+ }); |
+ } |
+ }; |
} |
+ |
+ // Frame registers a registration scoped |
+ // http://localhost:8000/serviceworker/resources/scope-for-getregistrations |
+ navigator.serviceWorker.register(script, { scope: scope }) |
+ .then(function(r) { |
+ registration = r; |
+ e.ports[0].postMessage('registered'); |
+ }); |
}; |
</script> |