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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE HTML>
<html>
<!--
Test the formatting of the file name, line and columns are correct in frame components,
with optional columns, unknown and non-URL sources.
-->
<head>
<meta charset="utf-8">
<title>Frame component test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="head.js" type="application/javascript;version=1.8"></script>
<script type="application/javascript;version=1.8">
window.onload = Task.async(function* () {
try {
let ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
let React = browserRequire("devtools/client/shared/vendor/react");
let Frame = React.createFactory(browserRequire("devtools/client/shared/components/frame"));
ok(Frame, "Should get Frame");
// Check when there's a column
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 55,
column: 10,
}
}, {
file: "mahscripts.js",
line: 55,
column: 10,
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js:55:10",
});
// Check when there's no column
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 55,
}
}, {
file: "mahscripts.js",
line: 55,
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js:55",
});
// Check when column === 0
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 55,
column: 0,
}
}, {
file: "mahscripts.js",
line: 55,
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js:55",
});
// Check when there's no parseable URL source;
// should not link but should render line/columns
yield checkFrameComponent({
frame: {
source: "self-hosted",
line: 1,
}
}, {
file: "self-hosted",
line: "1",
shouldLink: false,
tooltip: "self-hosted:1",
});
yield checkFrameComponent({
frame: {
source: "self-hosted",
line: 1,
column: 10,
}
}, {
file: "self-hosted",
line: "1",
column: "10",
shouldLink: false,
tooltip: "self-hosted:1:10",
});
// Check when there's no source;
// should not link but should render line/columns
yield checkFrameComponent({
frame: {
line: 1,
}
}, {
file: "(unknown)",
line: "1",
shouldLink: false,
tooltip: "(unknown):1",
});
yield checkFrameComponent({
frame: {
line: 1,
column: 10,
}
}, {
file: "(unknown)",
line: "1",
column: "10",
shouldLink: false,
tooltip: "(unknown):1:10",
});
// Check when there's a column, but no line;
// no line/column info should render
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
column: 55,
}
}, {
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check when line is 0; this should be an invalid
// line option, so don't render line/column
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 0,
column: 55,
}
}, {
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check when source is via Scratchpad; we should render out the
// lines and columns as this is linkable.
yield checkFrameComponent({
frame: {
source: "Scratchpad/1",
line: 10,
column: 50,
}
}, {
file: "Scratchpad/1",
line: 10,
column: 50,
shouldLink: true,
tooltip: "View source in Debugger → Scratchpad/1:10:50",
});
// Check that line and column can be strings
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: "10",
column: "55",
}
}, {
file: "mahscripts.js",
line: 10,
column: 55,
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js:10:55",
});
// Check that line and column can be strings,
// and that the `0` rendering rules apply when they are strings as well
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: "0",
column: "55",
}
}, {
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check that the showFullSourceUrl option works correctly
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 0,
},
showFullSourceUrl: true
}, {
file: "http://myfile.com/mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check that the showFunctionName option works correctly
yield checkFrameComponent({
frame: {
functionDisplayName: "myfun",
source: "http://myfile.com/mahscripts.js",
line: 0,
}
}, {
functionName: null,
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
yield checkFrameComponent({
frame: {
functionDisplayName: "myfun",
source: "http://myfile.com/mahscripts.js",
line: 0,
},
showFunctionName: true
}, {
functionName: "myfun",
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check that anonymous function name is not displayed unless explicitly enabled
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 0,
},
showFunctionName: true
}, {
functionName: null,
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
yield checkFrameComponent({
frame: {
source: "http://myfile.com/mahscripts.js",
line: 0,
},
showFunctionName: true,
showAnonymousFunctionName: true
}, {
functionName: "<anonymous>",
file: "mahscripts.js",
shouldLink: true,
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check if file is rendered with "/" for root documents when showEmptyPathAsHost is false
yield checkFrameComponent({
frame: {
source: "http://www.cnn.com/",
line: "1",
},
showEmptyPathAsHost: false,
}, {
file: "/",
line: "1",
shouldLink: true,
tooltip: "View source in Debugger → http://www.cnn.com/:1",
});
// Check if file is rendered with hostname for root documents when showEmptyPathAsHost is true
yield checkFrameComponent({
frame: {
source: "http://www.cnn.com/",
line: "1",
},
showEmptyPathAsHost: true,
}, {
file: "www.cnn.com",
line: "1",
shouldLink: true,
tooltip: "View source in Debugger → http://www.cnn.com/:1",
});
function* checkFrameComponent(input, expected) {
let props = Object.assign({ onClick: () => {} }, input);
let frame = ReactDOM.render(Frame(props), window.document.body);
yield forceRender(frame);
let el = frame.getDOMNode();
let { source } = input.frame;
checkFrameString(Object.assign({ el, source }, expected));
}
} catch (e) {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
} finally {
SimpleTest.finish();
}
});
</script>
</pre>
</body>
</html>
|