summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/media-source/dedicated-worker/mediasource-worker-objecturl.js
blob: 2e70d99418173d5ade9347c38e1a77ed0e44709a (plain)
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
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 => {
  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 url = URL.createObjectURL(ms);
}, "URL.createObjectURL(mediaSource) in DedicatedWorker does not throw exception");

test(t => {
  const ms = new MediaSource();
  const url1 = URL.createObjectURL(ms);
  const url2 = URL.createObjectURL(ms);
  URL.revokeObjectURL(url1);
  URL.revokeObjectURL(url2);
}, "URL.revokeObjectURL(mediaSource) in DedicatedWorker with two url for same MediaSource");

done();