blob: 3fba0b2c6fcd2e3be6b9aec95dd45a4f47011f82 (
plain)
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
53
54
55
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
/**
* Associate with the given networks but don't connect to it.
*
* Issue a association-only request, which will not have us connect
* to the network. Instead, the network config will be added as the
* known networks. After calling the "associate" API, we will wait
* a while to make sure the "connected" event is not received.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @param aNetwork
* MozWifiNetwork object.
*
* @return A deferred promise.
*/
function associateButDontConnect(aNetwork) {
log('Associating with ' + aNetwork.ssid);
aNetwork.dontConnect = true;
let promises = [];
promises.push(gTestSuite.waitForTimeout(10 * 1000)
.then(() => { throw 'timeout'; }));
promises.push(gTestSuite.testAssociate(aNetwork));
return Promise.all(promises)
.then(() => { throw 'unexpected state'; },
function(aReason) {
is(typeof aReason, 'string', 'typeof aReason');
is(aReason, 'timeout', aReason);
});
}
gTestSuite.doTest(function() {
let firstNetwork;
return gTestSuite.ensureWifiEnabled(true)
.then(gTestSuite.requestWifiScan)
.then(function(aNetworks) {
firstNetwork = aNetworks[0];
return associateButDontConnect(firstNetwork);
})
.then(gTestSuite.getKnownNetworks)
.then(function(aKnownNetworks) {
is(1, aKnownNetworks.length, 'There should be only one known network!');
is(aKnownNetworks[0].ssid, firstNetwork.ssid,
'The only one known network should be ' + firstNetwork.ssid)
});
});
|