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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ServiceWorkerGlobalScope/resources/extendable-message-event.js

Issue 2751113005: Upstream service worker message event tests to WPT (Closed)
Patch Set: Simplify expectations Created 3 years, 9 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 var wptEME = {};
falken 2017/03/17 15:37:48 nit: This name is a bit inscrutable. Should we jus
mike3 2017/03/17 16:31:41 Yeah, probably developer ergonomics need to take a
2
3 /**
4 * Create a representation of a given ExtendableMessageEvent that is suitable
5 * for transmission via the `postMessage` API.
6 */
falken 2017/03/17 15:37:48 nit: /* */ style comments are rare in Chromium and
mike3 2017/03/17 16:31:41 Acknowledged.
7 wptEME.serialize = function(event) {
8 var ports = event.ports.map(function(port) {
9 return { constructor: { name: port.constructor.name } };
10 });
11 return {
12 constructor: {
13 name: event.constructor.name
14 },
15 origin: event.origin,
16 lastEventId: event.lastEventId,
17 source: {
18 constructor: {
19 name: event.source.constructor.name
20 },
21 url: event.source.url,
22 frameType: event.source.frameType,
23 visibilityState: event.source.visibilityState,
24 focused: event.source.focused
25 },
26 ports: ports
27 };
28 };
29
30 /**
31 * Compare the actual and expected values of an ExtendableMessageEvent that has
32 * been transformed using the `serialize` function defined in this file.
33 */
34 wptEME.assert_equals = function(actual, expected) {
35 assert_equals(
36 actual.constructor.name, expected.constructor.name, 'event constructor'
37 );
38 assert_equals(actual.origin, expected.origin, 'event `origin` property');
39 assert_equals(
40 actual.lastEventId,
41 expected.lastEventId,
42 'event `lastEventId` property'
43 );
44
45 assert_equals(
46 actual.source.constructor.name,
47 expected.source.constructor.name,
48 'event `source` property constructor'
49 );
50 assert_equals(
51 actual.source.url, expected.source.url, 'event `source` property `url`'
52 );
53 assert_equals(
54 actual.source.frameType,
55 expected.source.frameType,
56 'event `source` property `frameType`'
57 );
58 assert_equals(
59 actual.source.visibilityState,
60 expected.source.visibilityState,
61 'event `source` property `visibilityState`'
62 );
63 assert_equals(
64 actual.source.focused,
65 expected.source.focused,
66 'event `source` property `focused`'
67 );
68
69 assert_equals(
70 actual.ports.length,
71 expected.ports.length,
72 'event `ports` property length'
73 );
74
75 for (var idx = 0; idx < expected.ports.length; ++idx) {
76 assert_equals(
77 actual.ports[idx].constructor.name,
78 expected.ports[idx].constructor.name,
79 'MessagePort #' + idx + ' constructor'
80 );
81 }
82 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698