summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/in-content/tests/browser_bug795764_cachedisabled.js
blob: 21f92db8d09c18227260fe7d5c6ddf21430dcff1 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");

function test() {
  waitForExplicitFinish();

  let prefs = [
    "browser.cache.offline.enable",
    "browser.cache.disk.enable",
    "browser.cache.memory.enable",
  ];

  registerCleanupFunction(function() {
    for (let pref of prefs) {
      Services.prefs.clearUserPref(pref);
    }
  });

  for (let pref of prefs) {
    Services.prefs.setBoolPref(pref, false);
  }

  open_preferences(runTest);
}

function runTest(win) {
  is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded");

  let tab = win.document;
  let elements = tab.getElementById("mainPrefPane").children;

  // Test if advanced pane is opened correctly
  win.gotoPref("paneAdvanced");
  for (let element of elements) {
    if (element.nodeName == "preferences") {
      continue;
    }
    let attributeValue = element.getAttribute("data-category");
    if (attributeValue == "paneAdvanced") {
      is_element_visible(element, "Advanced elements should be visible");
    } else {
      is_element_hidden(element, "Non-Advanced elements should be hidden");
    }
  }

  gBrowser.removeCurrentTab();
  win.close();
  finish();
}