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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html

Issue 730543005: Add a test for cross process service worker messaging. (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/postmessage-cross-process-helper.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html b/LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html
new file mode 100644
index 0000000000000000000000000000000000000000..d20366c3aa4781d892736063a04c6839f9c03515
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/postmessage-cross-process.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<title>Service Worker: postMessage across processes</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../resources/test-helpers.js"></script>
+<script>
+if (window.testRunner) {
+ testRunner.setCanOpenWindows();
+}
+
+function open_url_in_new_window(url) {
+ var a = document.createElement('a');
+ a.href = url;
+ // rel=noreferrer causes chrome to open the link in a new renderer process.
+ a.setAttribute('rel', 'noreferrer');
+ a.target = '_blank';
+ a.click();
+}
+
+async_test(function(t) {
+ var scope = 'resources/simple.html';
+ var registration;
+ service_worker_unregister_and_register(
+ t, 'resources/postmessage-cross-process-worker.js', scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_activated(t, registration);
+ })
+ .then(function() {
+ var worker = registration.active;
+ open_url_in_new_window(
+ 'resources/postmessage-cross-process-helper.html');
+ var messageChannel = new MessageChannel();
+ messageChannel.port1.onmessage = t.step_func(onMessage);
+ worker.postMessage({resultport: messageChannel.port2},
+ [messageChannel.port2]);
+ })
+ .catch(unreached_rejection(t));
+
+ var expected = [
+ 'Acking value: 1',
+ 'Acking value: 2',
+ ];
+
+ function onMessage(e) {
+ var result = e.data;
+ assert_array_equals(result, expected,
+ 'Worker should ack values posted by new window in order.');
+ t.done();
+ }
+ }, 'postMessage MessagePorts from client to SW in a different process');
+</script>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/postmessage-cross-process-helper.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698