gecko-dev/dom/base/test/test_pluginAudioNotificatio...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 строки
2.1 KiB
HTML
Исходник Обычный вид История

<!DOCTYPE HTML>
<html>
<head>
<title>Test for audio controller in windows</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<pre id="test">
</pre>
<iframe></iframe>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var iframe = null;
function waitForObserver(expectedNotification) {
return new Promise(resolve => {
let observe = function(subject, topic, data) {
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, `${expectedNotification} is the right notification`);
SpecialPowers.removeObserver(observe, "audio-playback");
resolve();
}
SpecialPowers.addObserver(observe, "audio-playback");
});
}
var tests = [
async function() {
iframe = document.querySelector("iframe");
let observerPromise = waitForObserver('active');
iframe.src = "file_pluginAudio.html";
await observerPromise;
},
async function() {
info("=== Mute plugin ===");
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
let observerPromise = waitForObserver('inactive-nonaudible');
iframe.contentWindow.toggleMuteState(true);
await observerPromise;
ok(iframe.contentWindow.pluginMuted(), "Plugin should be muted");
},
async function() {
info("=== unmute plugin ==");
ok(iframe.contentWindow.pluginMuted(), "Plugin should be muted");
let observerPromise = waitForObserver('active');
iframe.contentWindow.toggleMuteState(false);
await observerPromise;
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
},
async function() {
info("=== stop audio ==");
let observerPromise = waitForObserver('inactive-pause');
iframe.contentWindow.stopAudio();
await observerPromise;
},
];
async function runTest() {
for (let test of tests) {
await test();
}
SimpleTest.finish();
}
onload = runTest;
</script>
</body>
</html>