File: RTCDataChannelInit-maxPacketLifeTime-enforce-range.html

package info (click to toggle)
firefox 148.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,719,544 kB
  • sloc: cpp: 7,618,291; javascript: 6,701,749; ansic: 3,781,787; python: 1,418,389; xml: 638,647; asm: 438,962; java: 186,285; sh: 62,894; makefile: 19,011; objc: 13,092; perl: 12,763; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (101 lines) | stat: -rw-r--r-- 3,366 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<meta charset="utf-8">
<title>RTCDataChannelInit maxPacketLifeTime [EnforceRange] unsigned short tests</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';

// Helper to create a basic RTCPeerConnection
function createPC() {
  return new RTCPeerConnection();
}

// Test valid values within unsigned short range (0-65535)
test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 0 });
  assert_equals(channel.maxPacketLifeTime, 0);
  pc.close();
}, 'maxPacketLifeTime with value 0 should succeed');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 1 });
  assert_equals(channel.maxPacketLifeTime, 1);
  pc.close();
}, 'maxPacketLifeTime with value 1 should succeed');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 1000 });
  assert_equals(channel.maxPacketLifeTime, 1000);
  pc.close();
}, 'maxPacketLifeTime with value 1000 should succeed');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 65535 });
  assert_equals(channel.maxPacketLifeTime, 65535);
  pc.close();
}, 'maxPacketLifeTime with maximum value 65535 should succeed');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 65534 });
  assert_equals(channel.maxPacketLifeTime, 65534);
  pc.close();
}, 'maxPacketLifeTime with value 65534 (max-1) should succeed');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 3 });
  assert_equals(channel.maxPacketLifeTime, 3);
  pc.close();
}, 'maxPacketLifeTime with value 3 should succeed');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: 10 });
  assert_equals(channel.maxPacketLifeTime, 10);
  pc.close();
}, 'maxPacketLifeTime with value 10 should succeed');

// Test [EnforceRange] behavior - values outside range should throw TypeError
const badValues = [
  { value: -1, description: 'value -1' },
  { value: -100, description: 'value -100' },
  { value: 65536, description: 'value 65536' },
  { value: 100000, description: 'value 100000' },
  { value: Infinity, description: 'Infinity' },
  { value: -Infinity, description: '-Infinity' },
  { value: NaN, description: 'NaN' },
  { value: "65536", description: 'string "65536"' }
];

badValues.forEach(({ value, description }) => {
  test(() => {
    const pc = createPC();
    assert_throws_js(TypeError, () => {
      pc.createDataChannel('test', { maxPacketLifeTime: value });
    });
    pc.close();
  }, `maxPacketLifeTime with ${description} should throw TypeError`);
});

// Test numeric strings (should be converted to numbers)
test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', { maxPacketLifeTime: "100" });
  assert_equals(channel.maxPacketLifeTime, 100);
  pc.close();
}, 'maxPacketLifeTime with numeric string "100" should be converted to 100');

test(() => {
  const pc = createPC();
  const channel = pc.createDataChannel('test', {});
  assert_equals(channel.maxPacketLifeTime, null);
  pc.close();
}, 'maxPacketLifeTime when omitted should be null');

</script>