OLD | NEW |
---|---|
(Empty) | |
1 var ExtendableMessageEventUtils = {}; | |
falken
2017/03/21 14:42:56
This file seems to be using a four space indent mo
mike3
2017/03/21 17:15:29
There's some inconsistency in the WPT tests, but I
| |
2 | |
3 // Create a representation of a given ExtendableMessageEvent that is suitable | |
4 // for transmission via the `postMessage` API. | |
5 ExtendableMessageEventUtils.serialize = function(event) { | |
6 var ports = event.ports.map(function(port) { | |
7 return { constructor: { name: port.constructor.name } }; | |
8 }); | |
falken
2017/03/21 14:42:56
I think according to our style guide this is inden
mike3
2017/03/21 17:15:29
Acknowledged.
| |
9 return { | |
10 constructor: { | |
11 name: event.constructor.name | |
12 }, | |
13 origin: event.origin, | |
14 lastEventId: event.lastEventId, | |
15 source: { | |
16 constructor: { | |
17 name: event.source.constructor.name | |
18 }, | |
19 url: event.source.url, | |
20 frameType: event.source.frameType, | |
21 visibilityState: event.source.visibilityState, | |
22 focused: event.source.focused | |
23 }, | |
24 ports: ports | |
25 }; | |
falken
2017/03/21 14:42:56
I think according to our style guide lines 10-24 s
mike3
2017/03/21 17:15:29
Acknowledged.
| |
26 }; | |
27 | |
28 // Compare the actual and expected values of an ExtendableMessageEvent that has | |
29 // been transformed using the `serialize` function defined in this file. | |
30 ExtendableMessageEventUtils.assert_equals = function(actual, expected) { | |
31 assert_equals( | |
32 actual.constructor.name, expected.constructor.name, 'event constructor' | |
33 ); | |
34 assert_equals(actual.origin, expected.origin, 'event `origin` property'); | |
35 assert_equals( | |
36 actual.lastEventId, | |
37 expected.lastEventId, | |
38 'event `lastEventId` property' | |
39 ); | |
40 | |
41 assert_equals( | |
42 actual.source.constructor.name, | |
43 expected.source.constructor.name, | |
44 'event `source` property constructor' | |
45 ); | |
46 assert_equals( | |
47 actual.source.url, expected.source.url, 'event `source` property `url`' | |
48 ); | |
49 assert_equals( | |
50 actual.source.frameType, | |
51 expected.source.frameType, | |
52 'event `source` property `frameType`' | |
53 ); | |
54 assert_equals( | |
55 actual.source.visibilityState, | |
56 expected.source.visibilityState, | |
57 'event `source` property `visibilityState`' | |
58 ); | |
59 assert_equals( | |
60 actual.source.focused, | |
61 expected.source.focused, | |
62 'event `source` property `focused`' | |
63 ); | |
64 | |
65 assert_equals( | |
66 actual.ports.length, | |
67 expected.ports.length, | |
68 'event `ports` property length' | |
69 ); | |
70 | |
71 for (var idx = 0; idx < expected.ports.length; ++idx) { | |
72 assert_equals( | |
73 actual.ports[idx].constructor.name, | |
74 expected.ports[idx].constructor.name, | |
75 'MessagePort #' + idx + ' constructor' | |
76 ); | |
77 } | |
78 }; | |
OLD | NEW |