Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/postmessage-cross-process.html |
| diff --git a/LayoutTests/http/tests/serviceworker/postmessage-cross-process.html b/LayoutTests/http/tests/serviceworker/postmessage-cross-process.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..13b28f72b18339120be4f842b968eb14565b0287 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/postmessage-cross-process.html |
| @@ -0,0 +1,48 @@ |
| +<!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) { |
|
jsbell
2014/11/18 00:24:14
Since this is validating chrome-specific behavior
Marijn Kruisselbrink
2014/11/18 01:16:13
Yeah, I guess this is kind of on the edge between
Marijn Kruisselbrink
2014/11/20 20:41:12
And I've convinced myself that even though the tes
|
| + testRunner.setCanOpenWindows(); |
| +} |
| + |
| +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() { |
| + return get_newest_worker(registration); |
| + }) |
| + .then(function(worker) { |
| + var a = document.createElement('a'); |
|
jsbell
2014/11/18 00:24:14
Maybe factor this out into a helper function?
Marijn Kruisselbrink
2014/11/18 01:16:13
Done.
|
| + a.href = 'resources/postmessage-cross-process-helper.html'; |
| + a.setAttribute('rel', 'noreferrer'); |
|
jsbell
2014/11/18 00:24:14
I assume this is the magic that effectively forces
Marijn Kruisselbrink
2014/11/18 01:16:13
Yes.
|
| + a.target = '_blank'; |
| + a.click(); |
| + |
| + var messageChannel = new MessageChannel(); |
| + messageChannel.port1.onmessage = t.step_func(onMessage); |
| + worker.postMessage({resultport: messageChannel.port2}, [messageChannel.port2]); |
|
jsbell
2014/11/18 00:24:14
wrap at 80 columns
Marijn Kruisselbrink
2014/11/18 01:16:13
Done.
|
| + }) |
| + .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 post back expected values.'); |
|
jsbell
2014/11/18 00:24:14
Can you explain more than the assertion already do
Marijn Kruisselbrink
2014/11/18 01:16:13
Done.
|
| + t.done(); |
| + } |
| + }, 'postMessage MessagePorts from client to SW in a different process'); |
| +</script> |