OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <script> | |
8 description("Tests RTCDataChannel."); | |
9 | |
10 var pc = null; | |
11 var dc = null; | |
12 var data; | |
13 var array; | |
14 | |
15 function dc_onclose() { | |
16 testPassed("dc_onclose was called"); | |
17 shouldBe("dc.readyState", "'closed'"); | |
18 | |
19 finishJSTest(); | |
20 } | |
21 | |
22 function dc_onmessage_dataview(e) { | |
23 testPassed("dc_onmessage_dataview was called"); | |
24 data = e.data; | |
25 shouldBe("data.byteLength", "10"); | |
26 array = new Int8Array(e.data); | |
27 shouldBe("array[0]", "1"); | |
28 shouldBe("array[9]", "10"); | |
29 | |
30 dc.onclose = dc_onclose; | |
31 dc.close(); | |
32 } | |
33 | |
34 function dc_onmessage_arraybuffer(e) { | |
35 testPassed("dc_onmessage_arraybuffer was called"); | |
36 data = e.data; | |
37 shouldBe("data.byteLength", "2"); | |
38 array = new Int8Array(e.data); | |
39 shouldBe("array[0]", "17"); | |
40 shouldBe("array[1]", "19"); | |
41 | |
42 data = new ArrayBuffer(12); | |
43 array = new Int8Array(data); | |
44 array[1]=1; | |
45 array[10]=10; | |
46 | |
47 shouldBe("data.byteLength", "12"); | |
48 | |
49 shrunkView = new DataView(data, 1, 10); | |
50 | |
51 dc.onmessage = dc_onmessage_dataview; | |
52 shouldNotThrow("dc.send(shrunkView);"); | |
53 } | |
54 | |
55 function dc_onmessage_string(e) { | |
56 testPassed("dc_onmessage_string was called"); | |
57 data = e.data; | |
58 shouldBe("data", "'xyzzy'"); | |
59 | |
60 dc.binaryType = "arraybuffer"; | |
61 buffer = new ArrayBuffer(2); | |
62 var array = new Int8Array(buffer); | |
63 array[0] = 17; | |
64 array[1] = 19; | |
65 dc.onmessage = dc_onmessage_arraybuffer; | |
66 shouldNotThrow("dc.send(buffer);"); | |
67 } | |
68 | |
69 function dc_onopen() { | |
70 testPassed("dc_onopen was called"); | |
71 shouldBe("dc.readyState", "'open'"); | |
72 shouldBe("dc.label", "'label'"); | |
73 | |
74 dc.onmessage = dc_onmessage_string; | |
75 shouldNotThrow("dc.send('xyzzy');"); | |
76 } | |
77 | |
78 function pc_ondatachannel(e) { | |
79 testPassed("pc_ondatachannel was called"); | |
80 } | |
81 | |
82 function pc_onicechange() { | |
83 if (pc.iceConnectionState === "completed") { | |
84 testPassed("pc is connected"); | |
85 shouldNotThrow('dc = pc.createDataChannel("label");'); | |
86 shouldBe("dc.readyState", "'connecting'"); | |
87 dc.onopen = dc_onopen; | |
88 } | |
89 } | |
90 | |
91 pc = new webkitRTCPeerConnection(null, null); | |
92 shouldNotThrow('dc = pc.createDataChannel("label1");'); | |
93 shouldBe("dc.reliable", "true"); | |
94 shouldNotThrow('dc = pc.createDataChannel("label2", {});'); | |
95 shouldBe("dc.reliable", "true"); | |
96 shouldNotThrow('dc = pc.createDataChannel("label3", {ordered:true});'); | |
97 shouldBe("dc.reliable", "true"); | |
98 shouldNotThrow('dc = pc.createDataChannel("label3", {ordered:false});'); | |
99 shouldBe("dc.reliable", "false"); | |
100 shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmits:0});'); | |
101 shouldBe("dc.reliable", "false"); | |
102 shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmitTime:0});'); | |
103 shouldBe("dc.reliable", "false"); | |
104 | |
105 pc = new webkitRTCPeerConnection(null, null); | |
106 pc.oniceconnectionstatechange = pc_onicechange; | |
107 pc.ondatachannel = pc_ondatachannel; | |
108 | |
109 window.jsTestIsAsync = true; | |
110 window.successfullyParsed = true; | |
111 </script> | |
112 </body> | |
113 </html> | |
OLD | NEW |