-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't reject for setSinkId() on media element because of MediaElement…
…AudioSourceNode Differential Revision: https://phabricator.services.mozilla.com/D181974 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1829068 gecko-commit: b7a1bac16bce7d318c0dd06502f830bb18dac825 gecko-reviewers: padenot
- Loading branch information
1 parent
ac877c6
commit 8700524
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...diaelementaudiosourcenode-interface/setSinkId-with-MediaElementAudioSourceNode.https.html
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,49 @@ | ||
<!doctype html> | ||
<head> | ||
<title>Test HTMLMediaElement.setSinkId() with MediaElementAudioSourceNode</title> | ||
<link rel="help" href="https://webaudio.github.io/web-audio-api/#MediaElementAudioSourceNode"> | ||
</head> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src=/resources/testdriver.js></script> | ||
<script src=/resources/testdriver-vendor.js></script> | ||
<script> | ||
"use strict"; | ||
/* | ||
MediaElementAudioSourceNode silences HTMLMediaElement output to underlying | ||
devices but setSinkId() should still function as if there were no | ||
MediaElementAudioSourceNode according to | ||
"The HTMLMediaElement MUST behave in an identical fashion after the | ||
MediaElementAudioSourceNode has been created, except that the rendered audio | ||
will no longer be heard directly, but instead will be heard as a consequence | ||
of the MediaElementAudioSourceNode being connected through the routing graph." | ||
*/ | ||
|
||
let audio; | ||
promise_setup(async () => { | ||
audio = new Audio(); | ||
audio.src = "/media/sound_5.oga"; | ||
audio.autoplay = true; | ||
audio.loop = true; | ||
new AudioContext().createMediaElementSource(audio); | ||
await new Promise(r => audio.onplay = r); | ||
}); | ||
|
||
promise_test(t => audio.setSinkId(""), "setSinkId on default audio output should always work"); | ||
|
||
promise_test(t => promise_rejects_dom(t, "NotFoundError", audio.setSinkId("nonexistent_device_id")), | ||
"setSinkId fails with NotFoundError on made up deviceid"); | ||
|
||
promise_test(async t => { | ||
await test_driver.bless('transient activation for selectAudioOutput()'); | ||
const {deviceId} = await navigator.mediaDevices.selectAudioOutput(); | ||
assert_greater_than(deviceId.length, 0, "deviceId.length"); | ||
const p1 = audio.setSinkId(deviceId); | ||
assert_equals(audio.sinkId, "", "before it resolves, setSinkId is unchanged"); | ||
await p1; | ||
assert_equals(audio.sinkId, deviceId, "setSinkId updates sinkId to the requested deviceId"); | ||
await audio.setSinkId(""); | ||
assert_equals(audio.sinkId, "", "resetting sink ID to default audio output should always work"); | ||
}, "setSinkId() with output device ID exposed by selectAudioOutput() should resolve"); | ||
|
||
</script> |