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.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 MARIONETTE_TIMEOUT = 10000;
6 SpecialPowers.addPermission("fmradio", true, document);
8 let FMRadio = window.navigator.mozFMRadio;
10 function verifyInitialState() {
11 log("Verifying initial state.");
12 ok(FMRadio);
13 is(FMRadio.enabled, false);
14 setUp();
15 }
17 function setUp() {
18 let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
19 FMRadio.enable(frequency);
20 FMRadio.onenabled = seek;
21 }
23 function seek() {
24 log("Seek up");
25 var request = FMRadio.seekUp();
26 ok(request);
28 var seekUpIsCancelled = false;
29 request.onerror = function() {
30 seekUpIsCancelled = true;
31 };
33 var seekUpCompleted = false;
34 request.onsuccess = function() {
35 ok(!seekUpIsCancelled);
36 seekUpCompleted = true;
37 };
39 log("Seek up");
40 var cancelSeekReq = FMRadio.cancelSeek();
41 ok(cancelSeekReq);
43 // There are two possibilities which depends on the system
44 // process scheduling (bug 911063 comment 0):
45 // - seekup action is canceled
46 // - seekup's onsuccess fires before cancelSeek's onerror
48 cancelSeekReq.onsuccess = function() {
49 ok(seekUpIsCancelled, "Seekup request failed.");
50 cleanUp();
51 };
53 cancelSeekReq.onerror = function() {
54 ok(seekUpCompleted);
55 cleanUp();
56 };
57 }
59 function cleanUp() {
60 FMRadio.disable();
61 FMRadio.ondisabled = function() {
62 FMRadio.ondisabled = null;
63 ok(!FMRadio.enabled);
64 finish();
65 };
66 }
68 verifyInitialState();