summaryrefslogtreecommitdiffstats
path: root/devtools/client/commandline/test/browser_cmd_pref1.js
blob: 4dc34f7aeddd2a182c938819b51074b79f87e17a (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that the pref commands work

var prefBranch = Cc["@mozilla.org/preferences-service;1"]
                    .getService(Ci.nsIPrefService).getBranch(null)
                    .QueryInterface(Ci.nsIPrefBranch2);

const TEST_URI = "data:text/html;charset=utf-8,gcli-pref1";

function test() {
  return Task.spawn(spawnTest).then(finish, helpers.handleError);
}

function* spawnTest() {
  let options = yield helpers.openTab(TEST_URI);
  yield helpers.openToolbar(options);

  let netmonEnabledOrig = prefBranch.getBoolPref("devtools.netmonitor.enabled");
  info("originally: devtools.netmonitor.enabled = " + netmonEnabledOrig);

  yield helpers.audit(options, [
    {
      setup: "pref",
      check: {
        input:  "pref",
        hints:      " reset",
        markup: "IIII",
        status: "ERROR"
      },
    },
    {
      setup: "pref s",
      check: {
        input:  "pref s",
        hints:        "et",
        markup: "IIIIVI",
        status: "ERROR"
      },
    },
    {
      setup: "pref sh",
      check: {
        input:  "pref sh",
        hints:         "ow",
        markup: "IIIIVII",
        status: "ERROR"
      },
    },
    {
      setup: "pref show ",
      check: {
        input:  "pref show ",
        markup: "VVVVVVVVVV",
        status: "ERROR"
      },
    },
    {
      setup: "pref show usetexttospeech",
      check: {
        input:  "pref show usetexttospeech",
        hints:                           " -> accessibility.usetexttospeech",
        markup: "VVVVVVVVVVIIIIIIIIIIIIIII",
        status: "ERROR"
      },
    },
    {
      setup: "pref show devtools.netmoni",
      check: {
        input:  "pref show devtools.netmoni",
        hints:                        "tor.enabled",
        markup: "VVVVVVVVVVIIIIIIIIIIIIIIII",
        status: "ERROR",
        tooltipState: "true:importantFieldFlag",
        args: {
          setting: { value: undefined, status: "INCOMPLETE" },
        }
      },
    },
    {
      setup: "pref reset devtools.netmonitor.enabled",
      check: {
        input:  "pref reset devtools.netmonitor.enabled",
        hints:                                  "",
        markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
        status: "VALID"
      },
    },
    {
      setup: "pref show devtools.netmonitor.enabled 4",
      check: {
        input:  "pref show devtools.netmonitor.enabled 4",
        hints:                                   "",
        markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVE",
        status: "ERROR"
      },
    },
    {
      setup: "pref set devtools.netmonitor.enabled 4",
      check: {
        input:  "pref set devtools.netmonitor.enabled 4",
        hints:                                  "",
        markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVE",
        status: "ERROR",
        args: {
          setting: { arg: " devtools.netmonitor.enabled" },
          value: { status: "ERROR", message: "Can\u2019t use \u20184\u2019." },
        }
      },
    },
    {
      setup: "pref set devtools.editor.tabsize 4",
      check: {
        input:  "pref set devtools.editor.tabsize 4",
        hints:                                    "",
        markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
        status: "VALID",
        args: {
          setting: { arg: " devtools.editor.tabsize" },
          value: { value: 4 },
        }
      },
    },
    {
      setup: "pref list",
      check: {
        input:  "pref list",
        hints:           " -> pref set",
        markup: "IIIIVIIII",
        status: "ERROR"
      },
    },
    {
      setup: "pref show devtools.netmonitor.enabled",
      check: {
        args: {
          setting: {
            value: options.requisition.system.settings.get("devtools.netmonitor.enabled")
          }
        },
      },
      exec: {
        output: "devtools.netmonitor.enabled: " + netmonEnabledOrig,
      },
      post: function () {
        prefBranch.setBoolPref("devtools.netmonitor.enabled", netmonEnabledOrig);
      }
    },
  ]);

  yield helpers.closeToolbar(options);
  yield helpers.closeTab(options);
}