Bumping manifests a=b2g-bump
[gecko.git] / dom / base / test / test_audioWindowUtils.html
blob4018ce6aef43b496bdd68d62469835ab9968816c
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for audio controller in windows</title>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
7 </head>
8 <body>
9 <iframe src="about:blank" id="iframe"></iframe>
10 <script type="application/javascript">
12 function runTest() {
13 var utils = SpecialPowers.wrap(window).
14 QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
15 getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
16 ok(utils, "nsIDOMWindowUtils");
18 is(utils.audioMuted, false, "By default utils.audioMuted is false");
19 utils.audioMuted = true;
20 is(utils.audioMuted, true, "utils.audioMuted is true");
21 utils.audioMuted = false;
22 is(utils.audioMuted, false, "utils.audioMuted is true");
24 is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
25 utils.audioVolume = 0.4;
26 is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
27 utils.audioMuted = true;
28 is(utils.audioMuted, true, "utils.audioMuted is true");
29 is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
30 utils.audioMuted = false;
32 utils.audioVolume = 2.0;
33 is(utils.audioVolume, 2.0, "utils.audioVolume is ok");
35 try {
36 utils.audioVolume = -42;
37 ok(false, "This should throw");
38 } catch(e) {
39 ok(true, "This should throw");
42 utils.audioVolume = 0;
43 is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
44 utils.audioVolume = 1.0;
45 is(utils.audioVolume, 1.0, "utils.audioVolume is ok");
47 var iframe = document.getElementById("iframe");
48 ok(iframe, "IFrame exists");
50 utils = SpecialPowers.wrap(iframe.contentWindow).
51 QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
52 getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
53 ok(utils, "nsIDOMWindowUtils");
55 is(utils.audioMuted, false, "By default utils.audioMuted is false");
56 utils.audioMuted = true;
57 is(utils.audioMuted, true, "utils.audioMuted is true");
58 utils.audioMuted = false;
59 is(utils.audioMuted, false, "utils.audioMuted is true");
61 is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
62 utils.audioVolume = 0.4;
63 is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
64 utils.audioMuted = true;
65 is(utils.audioMuted, true, "utils.audioMuted is true");
66 is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
67 utils.audioMuted = false;
69 utils.audioVolume = 2.0;
70 is(utils.audioVolume, 2.0, "utils.audioVolume is ok");
72 try {
73 utils.audioVolume = -42;
74 ok(false, "This should throw");
75 } catch(e) {
76 ok(true, "This should throw");
79 utils.audioVolume = 0;
80 is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
81 utils.audioVolume = 1.0;
82 is(utils.audioVolume, 1.0, "utils.audioVolume is ok");
84 SimpleTest.finish();
87 SpecialPowers.pushPrefEnv({ "set": [["media.useAudioChannelService", true]]}, runTest);
88 SimpleTest.waitForExplicitFinish();
90 </script>
91 </body>
92 </html>