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

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: address #4, #14 Created 5 years, 7 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('evenType', {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(e instanceof w.ServiceWorkerMessageEvent,
29 'Instance type should be ServiceWorkerMessageEvent');
30 assert_true(e.source instanceof w.ServiceWorker,
31 'Source type should be ServiceWorker');
32 assert_equals(e.type, 'message',
33 'Event type should be "message"');
34 assert_equals(e.source, worker,
35 'Source worker should equal to the controller');
36 resolve();
37 });
38 worker.postMessage('PING');
39 });
40 })
41 .then(function() {
42 return service_worker_unregister_and_done(t, scope);
43 });
44 }, 'Test ServiceWorkerMessageEvent type.');
45
46 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698