fune/dom/base/test/test_pluginAudioNotification.html
Abdoulaye O. Ly 55e51c578b Bug 1562990 - Remove 'audioMuted' and 'audioVolume' properties from nsIDOMWindowUtils. r=NeilDeakin,alwu,farre
While working on porting the (audio-playback indicators) bug 1562990 to fission, we saw the potential to delete some methods in nsIDOMWindowUtils because they were not used anymore in our codebase except in a couple of tests files. So now, we should only mute/unmute or change the volume in the parent process. As such, interfaces are added in SpecialPowers to change media muted or volume state from content processes.

Differential Revision: https://phabricator.services.mozilla.com/D41782

--HG--
extra : moz-landing-system : lando
2019-08-19 21:17:21 +00:00

78 lines
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>