File: mediasource-worker-handle.js

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (70 lines) | stat: -rw-r--r-- 3,165 bytes parent folder | download | duplicates (18)
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
importScripts("/resources/testharness.js");

test(t => {
  // The Window test html conditionally fetches and runs these tests only if the
  // implementation exposes a true-valued static canConstructInDedicatedWorker
  // attribute on MediaSource in the Window context. So, the implementation must
  // agree on support here in the dedicated worker context.

  // Ensure we're executing in a dedicated worker context.
  assert_true(self instanceof DedicatedWorkerGlobalScope, "self instanceof DedicatedWorkerGlobalScope");
  assert_true(MediaSource.hasOwnProperty("canConstructInDedicatedWorker", "DedicatedWorker MediaSource hasOwnProperty 'canConstructInDedicatedWorker'"));
  assert_true(MediaSource.canConstructInDedicatedWorker, "DedicatedWorker MediaSource.canConstructInDedicatedWorker");
}, "MediaSource in DedicatedWorker context must have true-valued canConstructInDedicatedWorker if Window context had it");

test(t => {
  assert_true(
      'handle' in MediaSource.prototype,
      'dedicated worker MediaSource must have handle in prototype');
  assert_true(self.hasOwnProperty("MediaSourceHandle"), "dedicated worker must have MediaSourceHandle visibility");
}, 'MediaSource prototype in DedicatedWorker context must have \'handle\', and worker must have MediaSourceHandle');

test(t => {
  const ms = new MediaSource();
  assert_equals(ms.readyState, "closed");
}, "MediaSource construction succeeds with initial closed readyState in DedicatedWorker");

test(t => {
  const ms = new MediaSource();
  const handle = ms.handle;
  assert_not_equals(handle, null, 'must have a non-null \'handle\' attribute');
  assert_true(handle instanceof MediaSourceHandle, "must be a MediaSourceHandle");
}, 'mediaSource.handle in DedicatedWorker returns a MediaSourceHandle');

test(t => {
  const msA = new MediaSource();
  const msB = new MediaSource();
  const handleA1 = msA.handle;
  const handleA2 = msA.handle;
  const handleA3 = msA['handle'];
  const handleB1 = msB.handle;
  const handleB2 = msB.handle;
  assert_true(
      handleA1 === handleA2 && handleB1 === handleB2 && handleA1 != handleB1,
      'SameObject is observed for mediaSource.handle, and different MediaSource instances have different handles');
  assert_true(
      handleA1 === handleA3,
      'SameObject is observed even when accessing handle differently');
  assert_true(
      handleA1 instanceof MediaSourceHandle &&
          handleB1 instanceof MediaSourceHandle,
      'handle property returns MediaSourceHandles');
}, 'mediaSource.handle observes SameObject property correctly');

test(t => {
  const ms1 = new MediaSource();
  const handle1 = ms1.handle;
  const ms2 = new MediaSource();
  const handle2 = ms2.handle;
  assert_true(
      handle1 !== handle2,
      'distinct MediaSource instances must have distinct handles');

  // Verify attempt to change value of the handle property does not succeed.
  ms1.handle = handle2;
  assert_true(
      ms1.handle === handle1 && ms2.handle === handle2,
      'MediaSource handle is readonly, so should not have changed');
}, 'Attempt to set MediaSource handle property should fail to change it, since it is readonly');

done();