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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel.html

Issue 2501163002: RTCPeerConnection: match createDataChannel signature in spec (Closed)
Patch Set: expand id tests Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>RTCPeerConnection createDataChannel method</title>
4 <script src=/resources/testharness.js></script>
5 <script src=/resources/testharnessreport.js></script>
6 <script>
7 'use strict';
8
9 test(() => {
10 const pc = new RTCPeerConnection;
11 assert_equals(pc.createDataChannel.length, 1);
12 assert_throws(new TypeError, () => pc.createDataChannel());
13 }, 'createDataChannel required arguments');
14
15 test(() => {
16 const pc = new RTCPeerConnection;
17 pc.close();
18 assert_equals(pc.signalingState, 'closed', 'signaling state');
19 assert_throws('InvalidStateError', () => pc.createDataChannel(''));
20 }, 'createDataChannel with closed connection');
21
22 test(() => {
23 const pc = new RTCPeerConnection;
24 const channel = pc.createDataChannel('');
25 assert_true(channel instanceof RTCDataChannel, 'is RTCDataChannel');
26 assert_equals(channel.label, '', 'label');
27 assert_equals(channel.ordered, true, 'ordered');
28 assert_equals(channel.maxPacketLifeTime, null, 'maxPacketLifeTime');
29 assert_equals(channel.maxRetransmits, null, 'maxRetransmits');
30 assert_equals(channel.protocol, '', 'protocol');
31 assert_equals(channel.negotiated, false, 'negotiated');
32 // Initial id value is not defined.
33 assert_equals(typeof channel.id, 'number', 'id type');
34 assert_equals(channel.priority, 'low', 'priority');
35 }, 'createDataChannel defaults');
36
37 const labels = [
38 ['"foo"', 'foo', 'foo'],
39 ['null', null, 'null'],
40 ['undefined', undefined, 'undefined'],
41 ['lone surrogate', '\uD800', '\uFFFD'],
42 ];
43 for (const [description, label, expected] of labels) {
44 test(() => {
45 const pc = new RTCPeerConnection;
46 const channel = pc.createDataChannel(label);
47 assert_equals(channel.label, expected);
48 }, 'createDataChannel with label ' + description);
49 }
50
51 test(() => {
52 const pc = new RTCPeerConnection;
53 const channel = pc.createDataChannel('', { ordered: false });
54 assert_equals(channel.ordered, false);
55 }, 'createDataChannel with ordered false');
56
57 // true as the default value of a boolean is confusing because null is converted
58 // to false while undefined is converted to true.
59 test(() => {
60 const pc = new RTCPeerConnection;
61 const channel1 = pc.createDataChannel('', { ordered: null });
62 assert_equals(channel1.ordered, false);
63 const channel2 = pc.createDataChannel('', { ordered: undefined });
64 assert_equals(channel2.ordered, true);
65 }, 'createDataChannel with ordered null/undefined');
66
67 test(() => {
68 const pc = new RTCPeerConnection;
69 const channel = pc.createDataChannel('', { maxPacketLifeTime: 0 });
70 assert_equals(channel.maxPacketLifeTime, 0);
71 }, 'createDataChannel with maxPacketLifeTime 0');
72
73 test(() => {
74 const pc = new RTCPeerConnection;
75 const channel = pc.createDataChannel('', { maxRetransmits: 0 });
76 assert_equals(channel.maxRetransmits, 0);
77 }, 'createDataChannel with maxRetransmits 0');
78
79 test(() => {
80 const pc = new RTCPeerConnection;
81 assert_throws('SyntaxError', () => pc.createDataChannel('', {
82 maxPacketLifeTime: 0,
83 maxRetransmits: 0
84 }));
85 }, 'createDataChannel with both maxPacketLifeTime and maxRetransmits');
86
87 const protocols = [
88 ['"foo"', 'foo', 'foo'],
89 ['null', null, 'null'],
90 ['undefined', undefined, ''],
91 ['lone surrogate', '\uD800', '\uFFFD'],
92 ];
93 for (const [description, protocol, expected] of protocols) {
94 test(() => {
95 const pc = new RTCPeerConnection;
96 const channel = pc.createDataChannel('', { protocol: protocol });
97 assert_equals(channel.protocol, expected);
98 }, 'createDataChannel with protocol ' + description);
99 }
100
101 test(() => {
102 const pc = new RTCPeerConnection;
103 const channel = pc.createDataChannel('', { negotiated: true });
104 assert_equals(channel.negotiated, true);
105 }, 'createDataChannel with negotiated true');
106
107 // |id| is an unsigned short using [EnforceRange]. Additionally,
108 // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createdatachannel
109 // says: "If id is equal to 65535, which is greater than the maximum allowed ID
110 // of 65534 but still qualifies as an unsigned short, throw a TypeError."
111 for (const id of [-1, 0, 1, 65534, 65535, 65536]) {
112 test(() => {
113 const pc = new RTCPeerConnection;
114 if (id >= 0 && id <= 65534) {
115 const channel = pc.createDataChannel('', { id: id });
116 assert_equals(channel.id, id);
117 } else {
118 assert_throws(new TypeError, () => pc.createDataChannel('', { id: id }));
119 }
120 }, 'createDataChannel with id ' + id);
121 }
122
123 test(() => {
124 const pc = new RTCPeerConnection;
125 const channel = pc.createDataChannel('', { priority: "high" });
126 assert_equals(channel.priority, "high");
127 }, 'createDataChannel with priority "high"');
128 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698