-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MSE-in-Workers: Enable experimental proactive feature detection
Adds a readonly, boolean-valued, static attribute named `canConstructInDedicatedWorker` to the MediaSource interface. Currently, this attribute is only visible to web apps if the RunTimeEnabledFeature "MediaSourceInWorkers" is enabled. When visible, this attribute always returns true. The primary goal of having this attribute is to enable web app's main thread to proactively determine whether or not MSE is supported from a dedicated worker context *before* deciding whether or not to create or try using MSE from such a context. As an initial example of this use case, the existing MSE-in-Workers web_tests are updated to use this new attribute's existence and value to fail-fast rather than potentially flakily fail (e.g. previously, the ...worker-terminate test might flakily pass/fail some of its test cases on implementations lacking MSE-in-Workers support if the test completed before handling receipt of error message from worker.) A further test is added to ensure that, if the attribute is missing or exists but is not `true`, a dedicated worker does not have ability to construct a MediaSource instance. See also w3c/media-source#175 for further discussion which led to this new attribute. BUG=878133 Change-Id: I697ca6adc5b5dc65d5c5084ff67a541430a9237b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487834 Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Reviewed-by: Will Cassella <cassew@google.com> Cr-Commit-Position: refs/heads/master@{#819564} GitOrigin-RevId: 27d63ac81be017698d0b799365cd2ef4cbdd8813
- Loading branch information
1 parent
3681209
commit c825c3e
Showing
11 changed files
with
90 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...external/wpt/media-source/dedicated-worker/mediasource-worker-must-fail-if-unsupported.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
importScripts("/resources/testharness.js"); | ||
|
||
test(t => { | ||
// The Window test html conditionally fetches and runs these tests only if the | ||
// implementation does not have a true-valued static | ||
// canConstructInDedicatedWorker property on MediaSource in the Window | ||
// context. So, the implementation must agree on lack of 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(self.MediaSource === undefined, "MediaSource is undefined in DedicatedWorker"); | ||
assert_throws_js(ReferenceError, | ||
function() { var ms = new MediaSource(); }, | ||
"MediaSource construction in DedicatedWorker throws exception"); | ||
}, "MediaSource construction in DedicatedWorker context must fail if Window context did not claim MSE supported in DedicatedWorker"); | ||
|
||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 18 additions & 6 deletions
24
blink/web_tests/external/wpt/media-source/dedicated-worker/mediasource-worker-objecturl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
importScripts("/resources/testharness.js"); | ||
|
||
test((t) => { | ||
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 dedicated worker"); | ||
}, "MediaSource construction succeeds with initial closed readyState in DedicatedWorker"); | ||
|
||
test((t) => { | ||
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 dedicated worker returns a Blob URI"); | ||
}, "URL.createObjectURL(mediaSource) in DedicatedWorker returns a Blob URI"); | ||
|
||
test((t) => { | ||
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 dedicated worker with two url for same MediaSource"); | ||
}, "URL.revokeObjectURL(mediaSource) in DedicatedWorker with two url for same MediaSource"); | ||
|
||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters