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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/postmessage-to-client.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: postMessage to Client</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="resources/get-host-info.sub.js"></script>
6 <script src="resources/test-helpers.sub.js"></script>
7 <script>
8 var frame;
9 var t = async_test('postMessage from ServiceWorker to Client');
10 t.step(function() {
11 var scope = 'resources/blank.html';
12 var host_info = get_host_info();
13 var sw;
14 service_worker_unregister_and_register(
15 t, 'resources/postmessage-to-client-worker.js', scope)
16 .then(function(registration) {
17 return wait_for_state(t, registration.installing, 'activated');
18 })
19 .then(function() { return with_iframe(scope); })
20 .then(function(f) {
21 frame = f;
22 sw = frame.contentWindow.navigator.serviceWorker;
23 sw.onmessage = t.step_func(onMessage);
24 sw.controller.postMessage('ping');
25 })
26 .catch(unreached_rejection(t));
27
28 var result = [];
29 var expected = ['Sending message via clients'];
30
31 function onMessage(e) {
32 assert_equals(e.bubbles, false, 'message events should not bubble.');
33 assert_equals(e.cancelable, false, 'message events should not be cancelabl e.');
34 assert_equals(e.origin, host_info['HTTPS_ORIGIN'], 'message event\'s origi n should be set correctly.');
35 // XXXkhuey fixme!
36 // assert_equals(e.source, sw.controller, 'source should be ServiceWorker.' );
37
38 var message = e.data;
39 if (message === 'quit') {
40 assert_array_equals(result, expected,
41 'Worker should post back expected messages.');
42 frame.remove();
43 service_worker_unregister_and_done(t, scope);
44 } else {
45 result.push(message);
46 }
47 }
48 });
49 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698