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

Side by Side Diff: LayoutTests/http/tests/serviceworker/serviceworker-message-event.html

Issue 1130113006: ServiceWorker: Introduce ServiceWorkerMessageEvent to replace MessageEvent (3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: make more tests pass Created 5 years, 5 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: ServiceWorkerMessageEvent</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharness-helpers.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script src="resources/test-helpers.js"></script>
7 <script>
8
9 promise_test(function(t) {
10 var scope = 'resources/blank.html';
11 var url = 'resources/postmessage-to-client-worker.js';
12 return service_worker_unregister_and_register(t, url, scope)
13 .then(function(r) {
14 return wait_for_state(t, r.installing, 'activated');
15 })
16 .then(function() {
17 return with_iframe(scope);
18 })
19 .then(function(frame) {
20 var w = frame.contentWindow;
21 var worker = w.navigator.serviceWorker.controller;
22 // Test constructor with ServiceWorker object as source.
23 var e = new ServiceWorkerMessageEvent('eventType', {source: worker});
24 assert_equals(e.source, worker,
25 'Source should equal to the passing service worker');
26 return new Promise(function(resolve) {
27 w.navigator.serviceWorker.onmessage = t.step_func(function(e) {
28 assert_true(
29 e instanceof w.ServiceWorkerMessageEvent,
30 'Instance type should be ServiceWorkerMessageEvent');
31 assert_true(e.source instanceof w.ServiceWorker,
32 'Source type should be ServiceWorker');
33 assert_equals(e.type, 'message',
34 'Event type should be "message"');
35 assert_equals(e.source, worker,
36 'Source worker should equal to the controller');
37 resolve();
38 });
39 worker.postMessage('PING');
40 });
41 })
42 .then(function() {
43 return service_worker_unregister_and_done(t, scope);
44 });
45 }, 'Test ServiceWorkerMessageEvent type.');
46
47 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698