blob: 9a7195fc5bda04e4de95ba43bd2123a79685449a [file] [log] [blame]
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);
assert_true(url != null);
assert_true(url.match(/^blob:.+/) != null);
}, "URL.createObjectURL(mediaSource) in DedicatedWorker returns a Blob URI");
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();