summaryrefslogtreecommitdiff
path: root/dom/base/test/test_audioWindowUtils.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commitad18d877ddd2a44d98fa12ccd3dbbcf4d0ac4299 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/base/test/test_audioWindowUtils.html
parent15477ed9af4859dacb069040b5d4de600803d3bc (diff)
downloaduxp-ad18d877ddd2a44d98fa12ccd3dbbcf4d0ac4299.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_audioWindowUtils.html')
-rw-r--r--dom/base/test/test_audioWindowUtils.html107
1 files changed, 107 insertions, 0 deletions
diff --git a/dom/base/test/test_audioWindowUtils.html b/dom/base/test/test_audioWindowUtils.html
new file mode 100644
index 0000000000..a6067cfd6b
--- /dev/null
+++ b/dom/base/test/test_audioWindowUtils.html
@@ -0,0 +1,107 @@
+<!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() {
+ var utils = SpecialPowers.wrap(window).
+ QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+ getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+ 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;
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
+ utils.audioMuted = true;
+ is(utils.audioMuted, true, "utils.audioMuted is true");
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
+ 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");
+
+ utils = SpecialPowers.wrap(iframe.contentWindow).
+ QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+ getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+ 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;
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
+ utils.audioMuted = true;
+ is(utils.audioMuted, true, "utils.audioMuted is true");
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
+ 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 = 0.6;
+ is(utils.audioVolume.toFixed(2), "0.60", "utils.audioVolume is ok");
+ utils.audioMuted = true;
+
+ // Navigate the iframe to another URL, and verify that the volume and muted
+ // information is preserved.
+ iframe.onload = function() {
+ utils = SpecialPowers.wrap(iframe.contentWindow).
+ QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+ getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+ 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";
+}
+
+onload = runTest;
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</body>
+</html>