summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser_service_workers_not_compatible.js
blob: 6221230b556ed9dbe8078f2073f2e7c6766ff224 (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
56
57
58
59
60
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that Service Worker section should show warning message in
// about:debugging if any of following conditions is met:
// 1. service worker is disabled
// 2. the about:debugging pannel is openned in private browsing mode
// 3. the about:debugging pannel is openned in private content window

var imgClass = ".service-worker-disabled .warning";

add_task(function* () {
  yield new Promise(done => {
    info("disable service workers");
    let options = {"set": [
      ["dom.serviceWorkers.enabled", false],
    ]};
    SpecialPowers.pushPrefEnv(options, done);
  });

  let { tab, document } = yield openAboutDebugging("workers");
  // Check that the warning img appears in the UI
  let img = document.querySelector(imgClass);
  ok(img, "warning message is rendered");

  yield closeAboutDebugging(tab);
});

add_task(function* () {
  yield new Promise(done => {
    info("set private browsing mode as default");
    let options = {"set": [
      ["browser.privatebrowsing.autostart", true],
    ]};
    SpecialPowers.pushPrefEnv(options, done);
  });

  let { tab, document } = yield openAboutDebugging("workers");
  // Check that the warning img appears in the UI
  let img = document.querySelector(imgClass);
  ok(img, "warning message is rendered");

  yield closeAboutDebugging(tab);
});

add_task(function* () {
  info("Opening a new private window");
  let win = OpenBrowserWindow({private: true});
  yield waitForDelayedStartupFinished(win);

  let { tab, document } = yield openAboutDebugging("workers", win);
  // Check that the warning img appears in the UI
  let img = document.querySelector(imgClass);
  ok(img, "warning message is rendered");

  yield closeAboutDebugging(tab);
  win.close();
});