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"/>
9 <iframe src=
"about:blank" id=
"iframe"></iframe>
10 <script type=
"application/javascript">
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");
36 utils.audioVolume = -
42;
37 ok(false,
"This should throw");
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");
73 utils.audioVolume = -
42;
74 ok(false,
"This should throw");
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");
87 SpecialPowers.pushPrefEnv({
"set": [[
"media.useAudioChannelService", true]]}, runTest);
88 SimpleTest.waitForExplicitFinish();