Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Tests that the edit command works
6 const TEST_URI = "http://example.com/browser/browser/devtools/styleeditor/" +
7 "test/browser_styleeditor_cmd_edit.html";
9 function test() {
10 return Task.spawn(spawnTest).then(finish, helpers.handleError);
11 }
13 function spawnTest() {
14 let options = yield helpers.openTab(TEST_URI);
15 yield helpers.openToolbar(options);
17 yield helpers.audit(options, [
18 {
19 setup: "edit",
20 check: {
21 input: 'edit',
22 hints: ' <resource> [line]',
23 markup: 'VVVV',
24 status: 'ERROR',
25 args: {
26 resource: { status: 'INCOMPLETE' },
27 line: { status: 'VALID' },
28 }
29 },
30 },
31 {
32 setup: "edit i",
33 check: {
34 input: 'edit i',
35 hints: 'nline-css [line]',
36 markup: 'VVVVVI',
37 status: 'ERROR',
38 args: {
39 resource: { arg: ' i', status: 'INCOMPLETE' },
40 line: { status: 'VALID' },
41 }
42 },
43 },
44 {
45 setup: "edit c",
46 check: {
47 input: 'edit c',
48 hints: 'ss#style2 [line]',
49 markup: 'VVVVVI',
50 status: 'ERROR',
51 args: {
52 resource: { arg: ' c', status: 'INCOMPLETE' },
53 line: { status: 'VALID' },
54 }
55 },
56 },
57 {
58 setup: "edit http",
59 check: {
60 input: 'edit http',
61 hints: '://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css [line]',
62 markup: 'VVVVVIIII',
63 status: 'ERROR',
64 args: {
65 resource: {
66 arg: ' http',
67 status: 'INCOMPLETE',
68 message: 'Value required for \'resource\'.'
69 },
70 line: { status: 'VALID' },
71 }
72 },
73 },
74 {
75 setup: "edit page1",
76 check: {
77 input: 'edit page1',
78 hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css',
79 markup: 'VVVVVIIIII',
80 status: 'ERROR',
81 args: {
82 resource: {
83 arg: ' page1',
84 status: 'INCOMPLETE',
85 message: 'Value required for \'resource\'.'
86 },
87 line: { status: 'VALID' },
88 }
89 },
90 },
91 {
92 setup: "edit page2",
93 check: {
94 input: 'edit page2',
95 hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage2.css',
96 markup: 'VVVVVIIIII',
97 status: 'ERROR',
98 args: {
99 resource: {
100 arg: ' page2',
101 status: 'INCOMPLETE',
102 message: 'Value required for \'resource\'.'
103 },
104 line: { status: 'VALID' },
105 }
106 },
107 },
108 {
109 setup: "edit stylez",
110 check: {
111 input: 'edit stylez',
112 hints: ' [line]',
113 markup: 'VVVVVEEEEEE',
114 status: 'ERROR',
115 args: {
116 resource: { arg: ' stylez', status: 'ERROR', message: 'Can\'t use \'stylez\'.' },
117 line: { status: 'VALID' },
118 }
119 },
120 },
121 {
122 setup: "edit css#style2",
123 check: {
124 input: 'edit css#style2',
125 hints: ' [line]',
126 markup: 'VVVVVVVVVVVVVVV',
127 status: 'VALID',
128 args: {
129 resource: { arg: ' css#style2', status: 'VALID', message: '' },
130 line: { status: 'VALID' },
131 }
132 },
133 },
134 {
135 setup: "edit css#style2 5",
136 check: {
137 input: 'edit css#style2 5',
138 hints: '',
139 markup: 'VVVVVVVVVVVVVVVVV',
140 status: 'VALID',
141 args: {
142 resource: { arg: ' css#style2', status: 'VALID', message: '' },
143 line: { value: 5, arg: ' 5', status: 'VALID' },
144 }
145 },
146 },
147 {
148 setup: "edit css#style2 0",
149 check: {
150 input: 'edit css#style2 0',
151 hints: '',
152 markup: 'VVVVVVVVVVVVVVVVE',
153 status: 'ERROR',
154 args: {
155 resource: { arg: ' css#style2', status: 'VALID', message: '' },
156 line: { arg: ' 0', status: 'ERROR', message: '0 is smaller than minimum allowed: 1.' },
157 }
158 },
159 },
160 {
161 setup: "edit css#style2 -1",
162 check: {
163 input: 'edit css#style2 -1',
164 hints: '',
165 markup: 'VVVVVVVVVVVVVVVVEE',
166 status: 'ERROR',
167 args: {
168 resource: { arg: ' css#style2', status: 'VALID', message: '' },
169 line: { arg: ' -1', status: 'ERROR', message: '-1 is smaller than minimum allowed: 1.' },
170 }
171 },
172 }
173 ]);
175 let toolbox = gDevTools.getToolbox(options.target);
176 ok(toolbox == null, 'toolbox is closed');
178 yield helpers.audit(options, [
179 {
180 setup: "edit css#style2",
181 check: {
182 input: "edit css#style2",
183 args: {
184 resource: {
185 value: function(resource) {
186 let style2 = options.window.document.getElementById("style2");
187 return resource.element.ownerNode == style2;
188 }
189 }
190 }
191 },
192 exec: { output: "" }
193 },
194 ]);
196 let toolbox = gDevTools.getToolbox(options.target);
197 ok(toolbox != null, "toolbox is open");
199 let styleEditor = toolbox.getCurrentPanel();
200 ok(typeof styleEditor.selectStyleSheet === "function", "styleeditor is open");
202 yield toolbox.destroy();
204 yield helpers.closeToolbar(options);
205 yield helpers.closeTab(options);
206 }