Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for audio controller in windows</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <iframe src="about:blank" id="iframe"></iframe> |
michael@0 | 10 | <script type="application/javascript"> |
michael@0 | 11 | |
michael@0 | 12 | function runTest() { |
michael@0 | 13 | var utils = SpecialPowers.wrap(window). |
michael@0 | 14 | QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). |
michael@0 | 15 | getInterface(SpecialPowers.Ci.nsIDOMWindowUtils); |
michael@0 | 16 | ok(utils, "nsIDOMWindowUtils"); |
michael@0 | 17 | |
michael@0 | 18 | is(utils.audioMuted, false, "By default utils.audioMuted is false"); |
michael@0 | 19 | utils.audioMuted = true; |
michael@0 | 20 | is(utils.audioMuted, true, "utils.audioMuted is true"); |
michael@0 | 21 | utils.audioMuted = false; |
michael@0 | 22 | is(utils.audioMuted, false, "utils.audioMuted is true"); |
michael@0 | 23 | |
michael@0 | 24 | is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0"); |
michael@0 | 25 | utils.audioVolume = 0.4; |
michael@0 | 26 | is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok"); |
michael@0 | 27 | utils.audioMuted = true; |
michael@0 | 28 | is(utils.audioMuted, true, "utils.audioMuted is true"); |
michael@0 | 29 | is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok"); |
michael@0 | 30 | utils.audioMuted = false; |
michael@0 | 31 | |
michael@0 | 32 | utils.audioVolume = 2.0; |
michael@0 | 33 | is(utils.audioVolume, 2.0, "utils.audioVolume is ok"); |
michael@0 | 34 | |
michael@0 | 35 | try { |
michael@0 | 36 | utils.audioVolume = -42; |
michael@0 | 37 | ok(false, "This should throw"); |
michael@0 | 38 | } catch(e) { |
michael@0 | 39 | ok(true, "This should throw"); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | utils.audioVolume = 0; |
michael@0 | 43 | is(utils.audioVolume, 0.0, "utils.audioVolume is ok"); |
michael@0 | 44 | utils.audioVolume = 1.0; |
michael@0 | 45 | is(utils.audioVolume, 1.0, "utils.audioVolume is ok"); |
michael@0 | 46 | |
michael@0 | 47 | var iframe = document.getElementById("iframe"); |
michael@0 | 48 | ok(iframe, "IFrame exists"); |
michael@0 | 49 | |
michael@0 | 50 | utils = SpecialPowers.wrap(iframe.contentWindow). |
michael@0 | 51 | QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). |
michael@0 | 52 | getInterface(SpecialPowers.Ci.nsIDOMWindowUtils); |
michael@0 | 53 | ok(utils, "nsIDOMWindowUtils"); |
michael@0 | 54 | |
michael@0 | 55 | is(utils.audioMuted, false, "By default utils.audioMuted is false"); |
michael@0 | 56 | utils.audioMuted = true; |
michael@0 | 57 | is(utils.audioMuted, true, "utils.audioMuted is true"); |
michael@0 | 58 | utils.audioMuted = false; |
michael@0 | 59 | is(utils.audioMuted, false, "utils.audioMuted is true"); |
michael@0 | 60 | |
michael@0 | 61 | is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0"); |
michael@0 | 62 | utils.audioVolume = 0.4; |
michael@0 | 63 | is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok"); |
michael@0 | 64 | utils.audioMuted = true; |
michael@0 | 65 | is(utils.audioMuted, true, "utils.audioMuted is true"); |
michael@0 | 66 | is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok"); |
michael@0 | 67 | utils.audioMuted = false; |
michael@0 | 68 | |
michael@0 | 69 | utils.audioVolume = 2.0; |
michael@0 | 70 | is(utils.audioVolume, 2.0, "utils.audioVolume is ok"); |
michael@0 | 71 | |
michael@0 | 72 | try { |
michael@0 | 73 | utils.audioVolume = -42; |
michael@0 | 74 | ok(false, "This should throw"); |
michael@0 | 75 | } catch(e) { |
michael@0 | 76 | ok(true, "This should throw"); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | utils.audioVolume = 0; |
michael@0 | 80 | is(utils.audioVolume, 0.0, "utils.audioVolume is ok"); |
michael@0 | 81 | utils.audioVolume = 1.0; |
michael@0 | 82 | is(utils.audioVolume, 1.0, "utils.audioVolume is ok"); |
michael@0 | 83 | |
michael@0 | 84 | SimpleTest.finish(); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | SpecialPowers.pushPrefEnv({ "set": [["media.useAudioChannelService", true]]}, runTest); |
michael@0 | 88 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 89 | |
michael@0 | 90 | </script> |
michael@0 | 91 | </body> |
michael@0 | 92 | </html> |