forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_bug862672.js
53 lines (41 loc) · 1.28 KB
/
test_bug862672.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 10000;
SpecialPowers.addPermission("fmradio", true, document);
let FMRadio = window.navigator.mozFMRadio;
function verifyInitialState() {
log("Verifying initial state.");
ok(FMRadio);
is(FMRadio.enabled, false);
enableThenDisable();
}
function enableThenDisable() {
log("Enable FM Radio and disable it immediately.");
var frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
var request = FMRadio.enable(frequency);
ok(request);
var failedToEnable = false;
request.onerror = function() {
failedToEnable = true;
};
var enableCompleted = false;
request.onsuccess = function() {
ok(!failedToEnable);
enableCompleted = true;
};
var disableReq = FMRadio.disable();
ok(disableReq);
disableReq.onsuccess = function() {
// There are two possibilities which depends on the system
// process scheduling (bug 911063 comment 0):
// - enable fails
// - enable's onsuccess fires before disable's onsucess
ok(failedToEnable || enableCompleted);
ok(!FMRadio.enabled);
finish();
};
disableReq.onerror = function() {
ok(false, "Disable request should not fail.");
};
}
verifyInitialState();