Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 3 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /permissions-policy/speaker-selection-allowed-by-permissions-policy.https.sub.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
"use strict";
const same_origin_src =
"/permissions-policy/resources/permissions-policy-speaker-selection.html";
const cross_origin_src =
const header = 'permissions policy header "speaker-selection=*';
// Test that AudioContext.setSinkId() is allowed (fails with NotFoundError
// instead of NotAllowedError for fake device ID) when the
// speaker-selection policy is enabled in the top-level document.
promise_test((t) => {
const ctx = new AudioContext();
return promise_rejects_dom(
t,
"NotFoundError",
ctx.setSinkId("fake_device_id")
);
}, 'allows setSinkId in top-level document');
// Test that AudioContext.setSinkId() is allowed in same-origin iframes
// when the speaker-selection policy is enabled in the parent document.
promise_test((test) => {
return test_feature_availability({
feature_description: "AudioContext.setSinkId()",
test,
src: same_origin_src,
expect_feature_available: expect_feature_available_default,
is_promise_test: true,
});
}, 'allows setSinkId in same-origin iframe');
// Test that AudioContext.setSinkId() is disallowed in cross-origin iframes
// when the speaker-selection policy is enabled in the parent document
// but not delegated to the iframe via allow="speaker-selection".
promise_test((test) => {
return test_feature_availability({
feature_description: "AudioContext.setSinkId()",
test,
src: cross_origin_src,
expect_feature_available: expect_feature_unavailable_default,
is_promise_test: true,
});
}, 'disallows setSinkId in cross-origin iframe without allow');
// Test that AudioContext.setSinkId() is allowed in cross-origin iframes
// when the speaker-selection policy is enabled in the parent document
// and explicitly delegated via allow="speaker-selection".
promise_test((test) => {
return test_feature_availability({
feature_description: "AudioContext.setSinkId()",
test,
src: cross_origin_src,
expect_feature_available: expect_feature_available_default,
feature_name: "speaker-selection",
is_promise_test: true,
});
}, 'allows setSinkId in cross-origin iframe with allow');
</script>
</body>