dom/speakermanager/tests/test_speakermanager.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta charset="utf-8">
michael@0 5 <title>Test MozSpeakerManager API</title>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 8 </head>
michael@0 9 <body>
michael@0 10 <p id="display"></p>
michael@0 11 <div id="content" style="display: none"></div>
michael@0 12 <pre id="test">
michael@0 13 <script type="application/javascript">
michael@0 14
michael@0 15 "use strict";
michael@0 16
michael@0 17 function testObject() {
michael@0 18 var mgr = new MozSpeakerManager();
michael@0 19 var spkforced = false;
michael@0 20 mgr.onspeakerforcedchange = function() {
michael@0 21 if (spkforced) {
michael@0 22 is(mgr.speakerforced, true, 'speaker should be true');
michael@0 23 spkforced = false;
michael@0 24 mgr.forcespeaker = false;
michael@0 25 } else {
michael@0 26 is(mgr.speakerforced, false, 'speaker should be false');
michael@0 27 SimpleTest.finish();
michael@0 28 }
michael@0 29 }
michael@0 30 spkforced = true;
michael@0 31 mgr.forcespeaker = true;
michael@0 32 }
michael@0 33
michael@0 34 function startTests() {
michael@0 35 // Currently applicable only on FxOS
michael@0 36 if (navigator.userAgent.indexOf("Mobile") != -1 &&
michael@0 37 navigator.appVersion.indexOf("Android") == -1) {
michael@0 38 testObject();
michael@0 39 } else {
michael@0 40 ok(true, "mozAlarms on Firefox OS only.");
michael@0 41 SimpleTest.finish();
michael@0 42 }
michael@0 43 }
michael@0 44
michael@0 45 SimpleTest.waitForExplicitFinish();
michael@0 46 SpecialPowers.pushPermissions(
michael@0 47 [{ "type": "speaker-control", "allow": 1, "context": document }],
michael@0 48 startTests);
michael@0 49
michael@0 50 </script>
michael@0 51 </pre>
michael@0 52 </body>
michael@0 53 </html>

mercurial