Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 <pre id="test">
10 </pre>
12 <script type="application/javascript">
14 SimpleTest.waitForExplicitFinish();
16 var expectedNotification = null;
18 var observer = {
19 observe: function(subject, topic, data) {
20 is(topic, "media-playback", "media-playback received");
21 is(data, expectedNotification, "This is the right notification");
22 runTest();
23 }
24 };
26 var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
27 .getService(SpecialPowers.Ci.nsIObserverService);
29 var audio = new Audio();
30 audio.src = "audio.ogg";
32 var tests = [
33 function() {
34 SpecialPowers.pushPrefEnv({"set": [["media.useAudioChannelService", true]]}, runTest);
35 },
37 function() {
38 observerService.addObserver(observer, "media-playback", false);
39 ok(true, "Observer set");
40 runTest();
41 },
43 function() {
44 expectedNotification = 'active';
45 audio.play();
46 },
48 function() {
49 expectedNotification = 'inactive';
50 audio.pause();
51 },
53 function() {
54 observerService.removeObserver(observer, "media-playback");
55 ok(true, "Observer removed");
56 runTest();
57 }
58 ];
60 function runTest() {
61 if (!tests.length) {
62 SimpleTest.finish();
63 return;
64 }
66 var test = tests.shift();
67 test();
68 }
70 runTest();
72 </script>
73 </body>
74 </html>