summaryrefslogtreecommitdiffstats
path: root/dom/wifi/test/marionette/test_wifi_auto_connect.js
blob: 7add9f03dce894ab6707767a45ccd20da131c566 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const TESTING_HOSTAPD = [{ ssid: 'ap0' }];

gTestSuite.doTestWithoutStockAp(function() {
  let firstNetwork;
  return gTestSuite.ensureWifiEnabled(true)
    // Start custom hostapd for testing.
    .then(() => gTestSuite.startHostapds(TESTING_HOSTAPD))
    .then(() => gTestSuite.verifyNumOfProcesses('hostapd', TESTING_HOSTAPD.length))

    // Request the first scan.
    .then(gTestSuite.requestWifiScan)
    .then(function(networks) {
      firstNetwork = networks[0];
      return gTestSuite.testAssociate(firstNetwork);
    })

    // Note that due to Bug 1168285, we need to re-start testing hostapd
    // after wifi has been re-enabled.

    // Disable wifi and kill running hostapd.
    .then(() => gTestSuite.requestWifiEnabled(false))
    .then(gTestSuite.killAllHostapd)
    .then(() => gTestSuite.verifyNumOfProcesses('hostapd', 0))

    // Re-enable wifi.
    .then(() => gTestSuite.requestWifiEnabled(true))

    // Restart hostapd.
    .then(() => gTestSuite.startHostapds(TESTING_HOSTAPD))
    .then(() => gTestSuite.verifyNumOfProcesses('hostapd', TESTING_HOSTAPD.length))

    // Wait for connection automatically.
    .then(() => gTestSuite.waitForConnected(firstNetwork))

    // Kill running hostapd.
    .then(gTestSuite.killAllHostapd)
    .then(() => gTestSuite.verifyNumOfProcesses('hostapd', 0))
});