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

Side by Side Diff: third_party/WebKit/LayoutTests/broadcastchannel/interface.html

Issue 2004643002: Implement BroadcastChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address dcheng's comments Created 4 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 <meta charset=utf-8>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6
7 test(() => assert_throws(new TypeError(), () => new BroadcastChannel()),
8 'Should throw if no name is provided');
9
10 test(() => {
11 let c = new BroadcastChannel(null);
12 assert_equals(c.name, 'null');
13 }, 'Null name should not throw');
14
15 test(() => {
16 let c = new BroadcastChannel(undefined);
17 assert_equals(c.name, 'undefined');
18 }, 'Undefined name should not throw');
19
20 test(() => {
21 let c = new BroadcastChannel('fooBar');
22 assert_equals(c.name, 'fooBar');
23 }, 'Non-empty name should not throw');
24
25 test(() => {
26 let c = new BroadcastChannel(123);
27 assert_equals(c.name, '123');
28 }, 'Non-string name should not throw');
29
30 test(() => {
31 let c = new BroadcastChannel('');
32 assert_throws(new TypeError(), () => c.postMessage());
33 }, 'postMessage without parameters should throw');
34
35 test(() => {
36 let c = new BroadcastChannel('');
37 c.postMessage(null);
38 }, 'postMessage with null should not throw');
39
40 test(() => {
41 let c = new BroadcastChannel('');
42 c.close();
43 }, 'close should not throw');
44
45 test(() => {
46 let c = new BroadcastChannel('');
47 c.close();
48 c.close();
49 }, 'close should not throw when called multiple times');
50
51 test(() => {
52 let c = new BroadcastChannel('');
53 c.close();
54 assert_throws('InvalidStateError', () => c.postMessage(''));
55 }, 'postMessage after close should throw');
56
57 test(() => {
58 let c = new BroadcastChannel('');
59 assert_not_equals(c.onmessage, undefined);
60 }, 'BroadcastChannel should have an onmessage event');
61
62 test(() => {
63 let c = new BroadcastChannel('');
64 assert_throws('DataCloneError', () => c.postMessage(Symbol()));
65 }, 'postMessage should throw with uncloneable data');
66
67 test(() => {
68 let c = new BroadcastChannel('');
69 c.close();
70 assert_throws('InvalidStateError', () => c.postMessage(Symbol()));
71 }, 'postMessage should throw InvalidStateError after close, even with unclonea ble data');
72
73 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698