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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html

Issue 695643002: Add terminateServiceWorker method for layout tests - blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 6 years, 1 month 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 | LayoutTests/http/tests/serviceworker/chromium/resources/ping-worker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html b/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html
new file mode 100644
index 0000000000000000000000000000000000000000..cda38abf2531b4587d4404ffad8901a140fa4a06
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<title>Tests that postMessage works during and after terminating a service worker</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../resources/testharness-helpers.js"></script>
+<script src="../resources/test-helpers.js"></script>
+<script>
+
dominicc (has gone to gerrit) 2014/11/20 05:48:08 Delete this and the trailing blank line.
Marijn Kruisselbrink 2014/11/20 19:28:22 Done.
+function sendPing(worker) {
+ return new Promise(function(resolve) {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = function(message) {
+ resolve(message.data);
+ };
+ worker.postMessage({port: channel.port2}, [channel.port2]);
+ });
+}
+
+promise_test(function(test) {
+ var worker = 'resources/ping-worker.js';
+ var scope = 'resources/blank.html';
+ var sw;
+ return service_worker_unregister_and_register(test, worker, scope)
+ .then(function(registration) {
+ return wait_for_update(test, registration);
+ })
+ .then(function(worker) {
+ sw = worker;
+ return sendPing(sw);
+ })
+ .then(function(reply) {
+ assert_equals(reply, 1);
+ return internals.terminateServiceWorker(sw);
+ })
+ .then(function() {
+ return sendPing(sw);
+ })
+ .then(function(reply) {
+ assert_equals(reply, 1);
+ return sendPing(sw);
+ })
+ .then(function(reply) {
+ assert_equals(reply, 2);
+ return service_worker_unregister_and_done(test, scope);
+ });
+ }, 'Terminate terminates the worker.');
+
+</script>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/ping-worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698