Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

  • This WPT test may be referenced by the following Test IDs:
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=cross-origin&frame=direct&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=cross-origin&frame=direct&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=cross-origin&frame=direct&visibility=zero-size - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=cross-origin&frame=nested&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=cross-origin&frame=nested&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=cross-origin&frame=nested&visibility=zero-size - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=same-origin&frame=direct&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=same-origin&frame=direct&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=same-origin&frame=direct&visibility=zero-size - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=same-origin&frame=nested&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=same-origin&frame=nested&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/suspended-hide-show.tentative.sub.html?origin=same-origin&frame=nested&visibility=zero-size - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>
Suspended AudioContext does not change state when its iframe is hidden/shown
(media-playback-while-not-visible permission policy)
</title>
<meta name="variant" content="?origin=same-origin&frame=direct&visibility=display">
<meta name="variant" content="?origin=same-origin&frame=direct&visibility=visibility">
<meta name="variant" content="?origin=same-origin&frame=direct&visibility=zero-size">
<meta name="variant" content="?origin=same-origin&frame=nested&visibility=display">
<meta name="variant" content="?origin=same-origin&frame=nested&visibility=visibility">
<meta name="variant" content="?origin=same-origin&frame=nested&visibility=zero-size">
<meta name="variant" content="?origin=cross-origin&frame=direct&visibility=display">
<meta name="variant" content="?origin=cross-origin&frame=direct&visibility=visibility">
<meta name="variant" content="?origin=cross-origin&frame=direct&visibility=zero-size">
<meta name="variant" content="?origin=cross-origin&frame=nested&visibility=display">
<meta name="variant" content="?origin=cross-origin&frame=nested&visibility=visibility">
<meta name="variant" content="?origin=cross-origin&frame=nested&visibility=zero-size">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/media-playback-while-not-visible-utils.js"></script>
<body>
<script>
const SAME_ORIGIN_BASE = new URL('resources/', location.href).href;
const CROSS_ORIGIN_BASE =
'media-playback-while-not-visible-permission-policy/resources/';
const params = new URLSearchParams(location.search);
const origin = params.get('origin');
const visibility = params.get('visibility');
const frame = params.get('frame');
const base = origin === 'cross-origin' ? CROSS_ORIGIN_BASE : SAME_ORIGIN_BASE;
// Scenario: a suspended AudioContext should not change state when its iframe is
// hidden and shown - there should be no observable state changes.
promise_test(
async t => {
const iframe = await createIframe(t, frame, base);
assert_equals(
await setUpIframeAudioContextInitialState(t, iframe, 'suspended'),
'suspended');
// No state change should be observed when hiding.
let statechange_promise =
expectIframeAudioContextStateChangeEvent(t, /*timeout=*/ 500);
hideFrame(iframe, visibility);
assert_equals(await statechange_promise, 'no state change');
// No state change should be observed when showing.
statechange_promise =
expectIframeAudioContextStateChangeEvent(t, /*timeout=*/ 500);
showFrame(iframe, visibility);
assert_equals(await statechange_promise, 'no state change');
},
`${origin} ${frame}: hide/show an iframe with a suspended AudioContext ` +
`(visibility=${visibility})`);
</script>
</body>