2015-07-27 07:11:21 +03:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for audio controller in windows</title>
|
2019-04-16 06:53:28 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2017-02-09 04:03:22 +03:00
|
|
|
<script type="application/javascript" src="plugin.js"></script>
|
2015-07-27 07:11:21 +03:00
|
|
|
<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;
|
|
|
|
|
2019-08-20 00:17:21 +03:00
|
|
|
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");
|
|
|
|
});
|
|
|
|
}
|
2015-07-27 07:11:21 +03:00
|
|
|
|
|
|
|
var tests = [
|
2019-08-20 00:17:21 +03:00
|
|
|
async function() {
|
2015-07-27 07:11:21 +03:00
|
|
|
iframe = document.querySelector("iframe");
|
2019-08-20 00:17:21 +03:00
|
|
|
let observerPromise = waitForObserver('active');
|
2015-07-27 07:11:21 +03:00
|
|
|
iframe.src = "file_pluginAudio.html";
|
2019-08-20 00:17:21 +03:00
|
|
|
await observerPromise;
|
2015-07-27 07:11:21 +03:00
|
|
|
},
|
|
|
|
|
2019-08-20 00:17:21 +03:00
|
|
|
async function() {
|
2016-12-16 12:12:41 +03:00
|
|
|
info("=== Mute plugin ===");
|
2015-07-27 07:11:21 +03:00
|
|
|
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
|
2019-08-20 00:17:21 +03:00
|
|
|
let observerPromise = waitForObserver('inactive-nonaudible');
|
2015-07-27 07:11:21 +03:00
|
|
|
iframe.contentWindow.toggleMuteState(true);
|
2019-08-20 00:17:21 +03:00
|
|
|
await observerPromise;
|
2015-07-27 07:11:21 +03:00
|
|
|
ok(iframe.contentWindow.pluginMuted(), "Plugin should be muted");
|
2016-12-16 12:12:41 +03:00
|
|
|
},
|
|
|
|
|
2019-08-20 00:17:21 +03:00
|
|
|
async function() {
|
2016-12-16 12:12:41 +03:00
|
|
|
info("=== unmute plugin ==");
|
|
|
|
ok(iframe.contentWindow.pluginMuted(), "Plugin should be muted");
|
2019-08-20 00:17:21 +03:00
|
|
|
let observerPromise = waitForObserver('active');
|
2015-07-27 07:11:21 +03:00
|
|
|
iframe.contentWindow.toggleMuteState(false);
|
2019-08-20 00:17:21 +03:00
|
|
|
await observerPromise;
|
2015-07-27 07:11:21 +03:00
|
|
|
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
|
|
|
|
},
|
|
|
|
|
2019-08-20 00:17:21 +03:00
|
|
|
async function() {
|
2016-12-16 12:12:41 +03:00
|
|
|
info("=== stop audio ==");
|
2019-08-20 00:17:21 +03:00
|
|
|
let observerPromise = waitForObserver('inactive-pause');
|
2015-07-27 07:11:21 +03:00
|
|
|
iframe.contentWindow.stopAudio();
|
2019-08-20 00:17:21 +03:00
|
|
|
await observerPromise;
|
2015-07-27 07:11:21 +03:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2019-08-20 00:17:21 +03:00
|
|
|
async function runTest() {
|
|
|
|
for (let test of tests) {
|
|
|
|
await test();
|
2015-07-27 07:11:21 +03:00
|
|
|
}
|
2019-08-20 00:17:21 +03:00
|
|
|
SimpleTest.finish();
|
2015-07-27 07:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onload = runTest;
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|