summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/test_ext_captivePortal_url.js
blob: 7bd83b057283aef53371e623e12ceb274a384b48 (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
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";

add_task(async function test_url_get_without_set() {
  async function background() {
    browser.captivePortal.canonicalURL.onChange.addListener(details => {
      browser.test.sendMessage("url", details);
    });
    let url = await browser.captivePortal.canonicalURL.get({});
    browser.test.sendMessage("url", url);
  }

  let extension = ExtensionTestUtils.loadExtension({
    background,
    manifest: {
      permissions: ["captivePortal"],
    },
  });

  let defaultURL = Services.prefs.getStringPref("captivedetect.canonicalURL");

  await extension.startup();
  let url = await extension.awaitMessage("url");
  equal(
    url.value,
    defaultURL,
    "The canonicalURL setting has the expected value."
  );
  equal(
    url.levelOfControl,
    "not_controllable",
    "The canonicalURL setting has the expected levelOfControl."
  );

  Services.prefs.setStringPref(
    "captivedetect.canonicalURL",
    "http://example.com"
  );
  url = await extension.awaitMessage("url");
  equal(
    url.value,
    "http://example.com",
    "The canonicalURL setting has the expected value."
  );
  equal(
    url.levelOfControl,
    "not_controllable",
    "The canonicalURL setting has the expected levelOfControl."
  );

  await extension.unload();
});