summaryrefslogtreecommitdiffstats
path: root/devtools/client/styleeditor/test/browser_styleeditor_cmd_edit.js
blob: 96b64cc9476dddf83ce205aa253e027a8964714d (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Tests that the edit command works

// Import the GCLI test helper
/* import-globals-from ../../commandline/test/helpers.js */
Services.scriptloader.loadSubScript(
  "chrome://mochitests/content/browser/devtools/client/commandline/test/helpers.js",
  this);

const TEST_URI = "http://example.com/browser/devtools/client/styleeditor/" +
                 "test/browser_styleeditor_cmd_edit.html";

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

  yield helpers.audit(options, [
    {
      setup: "edit",
      check: {
        input: "edit",
        hints: " <resource> [line]",
        markup: "VVVV",
        status: "ERROR",
        args: {
          resource: { status: "INCOMPLETE" },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit i",
      check: {
        input: "edit i",
        hints: "nline-css [line]",
        markup: "VVVVVI",
        status: "ERROR",
        args: {
          resource: { arg: " i", status: "INCOMPLETE" },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit c",
      check: {
        input: "edit c",
        hints: "ss#style2 [line]",
        markup: "VVVVVI",
        status: "ERROR",
        args: {
          resource: { arg: " c", status: "INCOMPLETE" },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit http",
      check: {
        input: "edit http",
        hints: "://example.com/browser/devtools/client/styleeditor/test/" +
               "resources_inpage1.css [line]",
        markup: "VVVVVIIII",
        status: "ERROR",
        args: {
          resource: {
            arg: " http",
            status: "INCOMPLETE",
            message: "Value required for \u2018resource\u2019."
          },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit page1",
      check: {
        input: "edit page1",
        hints: " [line] -> http://example.com/browser/devtools/client/" +
               "styleeditor/test/resources_inpage1.css",
        markup: "VVVVVIIIII",
        status: "ERROR",
        args: {
          resource: {
            arg: " page1",
            status: "INCOMPLETE",
            message: "Value required for \u2018resource\u2019."
          },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit page2",
      check: {
        input: "edit page2",
        hints: " [line] -> http://example.com/browser/devtools/client/" +
               "styleeditor/test/resources_inpage2.css",
        markup: "VVVVVIIIII",
        status: "ERROR",
        args: {
          resource: {
            arg: " page2",
            status: "INCOMPLETE",
            message: "Value required for \u2018resource\u2019."
          },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit stylez",
      check: {
        input: "edit stylez",
        hints: " [line]",
        markup: "VVVVVEEEEEE",
        status: "ERROR",
        args: {
          resource: {
            arg: " stylez",
            status: "ERROR", message: "Can\u2019t use \u2018stylez\u2019." },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit css#style2",
      check: {
        input: "edit css#style2",
        hints: " [line]",
        markup: "VVVVVVVVVVVVVVV",
        status: "VALID",
        args: {
          resource: { arg: " css#style2", status: "VALID", message: "" },
          line: { status: "VALID" },
        }
      },
    },
    {
      setup: "edit css#style2 5",
      check: {
        input: "edit css#style2 5",
        hints: "",
        markup: "VVVVVVVVVVVVVVVVV",
        status: "VALID",
        args: {
          resource: { arg: " css#style2", status: "VALID", message: "" },
          line: { value: 5, arg: " 5", status: "VALID" },
        }
      },
    },
    {
      setup: "edit css#style2 0",
      check: {
        input: "edit css#style2 0",
        hints: "",
        markup: "VVVVVVVVVVVVVVVVE",
        status: "ERROR",
        args: {
          resource: { arg: " css#style2", status: "VALID", message: "" },
          line: {
            arg: " 0",
            status: "ERROR",
            message: "0 is smaller than minimum allowed: 1."
          },
        }
      },
    },
    {
      setup: "edit css#style2 -1",
      check: {
        input: "edit css#style2 -1",
        hints: "",
        markup: "VVVVVVVVVVVVVVVVEE",
        status: "ERROR",
        args: {
          resource: { arg: " css#style2", status: "VALID", message: "" },
          line: {
            arg: " -1",
            status: "ERROR",
            message: "-1 is smaller than minimum allowed: 1."
          },
        }
      },
    }
  ]);

  let toolbox = gDevTools.getToolbox(options.target);
  ok(toolbox == null, "toolbox is closed");

  yield helpers.audit(options, [
    {
      setup: "edit css#style2",
      check: {
        input: "edit css#style2",
      },
      exec: { output: "" }
    },
  ]);

  toolbox = gDevTools.getToolbox(options.target);
  ok(toolbox != null, "toolbox is open");

  let styleEditor = toolbox.getCurrentPanel();
  ok(typeof styleEditor.selectStyleSheet === "function", "styleeditor is open");

  yield toolbox.destroy();

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