2014-03-11 14:46:55 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for audio controller in windows</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<iframe src="about:blank" id="iframe"></iframe>
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
function runTest() {
|
2018-07-25 02:47:41 +03:00
|
|
|
var utils = SpecialPowers.getDOMWindowUtils(window);
|
2014-03-11 14:46:55 +04:00
|
|
|
ok(utils, "nsIDOMWindowUtils");
|
|
|
|
|
|
|
|
is(utils.audioMuted, false, "By default utils.audioMuted is false");
|
|
|
|
utils.audioMuted = true;
|
|
|
|
is(utils.audioMuted, true, "utils.audioMuted is true");
|
|
|
|
utils.audioMuted = false;
|
|
|
|
is(utils.audioMuted, false, "utils.audioMuted is true");
|
|
|
|
|
|
|
|
is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
|
|
|
|
utils.audioVolume = 0.4;
|
2015-04-14 16:28:13 +03:00
|
|
|
is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
|
2014-03-11 14:46:55 +04:00
|
|
|
utils.audioMuted = true;
|
|
|
|
is(utils.audioMuted, true, "utils.audioMuted is true");
|
2015-04-14 16:28:13 +03:00
|
|
|
is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
|
2014-03-11 14:46:55 +04:00
|
|
|
utils.audioMuted = false;
|
|
|
|
|
|
|
|
utils.audioVolume = 2.0;
|
|
|
|
is(utils.audioVolume, 2.0, "utils.audioVolume is ok");
|
|
|
|
|
|
|
|
try {
|
|
|
|
utils.audioVolume = -42;
|
|
|
|
ok(false, "This should throw");
|
|
|
|
} catch(e) {
|
|
|
|
ok(true, "This should throw");
|
|
|
|
}
|
|
|
|
|
|
|
|
utils.audioVolume = 0;
|
|
|
|
is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
|
|
|
|
utils.audioVolume = 1.0;
|
|
|
|
is(utils.audioVolume, 1.0, "utils.audioVolume is ok");
|
|
|
|
|
|
|
|
var iframe = document.getElementById("iframe");
|
|
|
|
ok(iframe, "IFrame exists");
|
|
|
|
|
2018-07-25 02:47:41 +03:00
|
|
|
utils = SpecialPowers.getDOMWindowUtils(iframe.contentWindow);
|
2014-03-11 14:46:55 +04:00
|
|
|
ok(utils, "nsIDOMWindowUtils");
|
|
|
|
|
|
|
|
is(utils.audioMuted, false, "By default utils.audioMuted is false");
|
|
|
|
utils.audioMuted = true;
|
|
|
|
is(utils.audioMuted, true, "utils.audioMuted is true");
|
|
|
|
utils.audioMuted = false;
|
|
|
|
is(utils.audioMuted, false, "utils.audioMuted is true");
|
|
|
|
|
|
|
|
is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
|
|
|
|
utils.audioVolume = 0.4;
|
2015-04-14 16:28:13 +03:00
|
|
|
is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
|
2014-03-11 14:46:55 +04:00
|
|
|
utils.audioMuted = true;
|
|
|
|
is(utils.audioMuted, true, "utils.audioMuted is true");
|
2015-04-14 16:28:13 +03:00
|
|
|
is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
|
2014-03-11 14:46:55 +04:00
|
|
|
utils.audioMuted = false;
|
|
|
|
|
|
|
|
utils.audioVolume = 2.0;
|
|
|
|
is(utils.audioVolume, 2.0, "utils.audioVolume is ok");
|
|
|
|
|
|
|
|
try {
|
|
|
|
utils.audioVolume = -42;
|
|
|
|
ok(false, "This should throw");
|
|
|
|
} catch(e) {
|
|
|
|
ok(true, "This should throw");
|
|
|
|
}
|
|
|
|
|
|
|
|
utils.audioVolume = 0;
|
|
|
|
is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
|
2015-07-05 22:18:34 +03:00
|
|
|
utils.audioVolume = 0.6;
|
|
|
|
is(utils.audioVolume.toFixed(2), "0.60", "utils.audioVolume is ok");
|
|
|
|
utils.audioMuted = true;
|
2014-03-11 14:46:55 +04:00
|
|
|
|
2015-07-05 22:18:34 +03:00
|
|
|
// Navigate the iframe to another URL, and verify that the volume and muted
|
|
|
|
// information is preserved.
|
|
|
|
iframe.onload = function() {
|
2018-07-25 02:47:41 +03:00
|
|
|
utils = SpecialPowers.getDOMWindowUtils(iframe.contentWindow);
|
2015-07-05 22:18:34 +03:00
|
|
|
ok(utils, "nsIDOMWindowUtils");
|
|
|
|
|
|
|
|
ok(utils.audioMuted, "Audio should still be muted");
|
|
|
|
utils.audioMuted = false;
|
|
|
|
ok(utils.audioVolume.toFixed(2), "0.60", "Volume should be preserved");
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
};
|
|
|
|
iframe.src = "data:text/html,page";
|
2014-03-11 14:46:55 +04:00
|
|
|
}
|
|
|
|
|
2015-08-20 00:52:22 +03:00
|
|
|
onload = runTest;
|
2014-03-11 14:46:55 +04:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|