forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamples.js
More file actions
153 lines (135 loc) · 4.58 KB
/
Copy pathsamples.js
File metadata and controls
153 lines (135 loc) · 4.58 KB
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
/* 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/>. */
const samples = {
array: ['x = [1, "2", {three: 3}, []]', "x = []"],
boolean: ["true", "false"],
date: ["new Date()"],
function: ["x = () => { 2 }"],
node: [
`x = document.createElement("div");
x.setAttribute("id", "myNodeId");
x.setAttribute("class", "my-class and another");
x.textContent = "My node id";
x;`,
`x = document.createElementNS("http://www.w3.org/2000/svg", "clipPath");
x.setAttribute("id", "myNodeId");
x.setAttribute("class", "my-class and another");
x;`,
"document.createComment('my comment node')",
"document.createTextNode('foo')",
`x = document.createAttribute('foo');
x.value = "bar";
x;`
],
"map & sets": [
`
({
"small set": new Set([1,2,3,4]),
"small map": new Map([
["a", {suba: 1}],
[{bkey: "b"}, 2]]
),
"medium set": new Set(
Array.from({length: 20})
.map((el, i) => ({
[String.fromCharCode(65 + i)]: i + 1,
test: {
[i] : "item" + i
}
})
)),
"medium map": new Map(
Array
.from({length: 20})
.map((el, i) => [
{
[String.fromCharCode(65 + i)]: i + 1,
test: {[i] : "item" + i, body: document.body}
},
Symbol(i + 1)
])
),
"large set": new Set(
Array.from({length: 2000})
.map((el, i) => ({
[String.fromCharCode(65 + i)]: i + 1,
test: {
[i] : "item" + i
}
})
)),
"large map": new Map(
Array
.from({length: 2000})
.map((el, i) => [
{
[String.fromCharCode(65 + i)]: i + 1,
document
},
Symbol(i + 1)
])
),
})
`
],
number: ["1", "-1", "-3.14", "0", "-0", "Infinity", "-Infinity", "NaN"],
object: ["x = {a: 2}"],
promise: [
"Promise.resolve([1, 2, 3])",
"Promise.reject(new Error('This is wrong'))",
"new Promise(() => {})"
],
proxy: [
`
var handler = {
get: function(target, name) {
return name in target ?
target[name] :
37;
}
};
new Proxy({a: 1}, handler);
`
],
regexp: ["new RegExp('^[-]?[0-9]+[.]?[0-9]+$')"],
string: [
"'foo'",
"'bar\nbaz\nyup'",
"'http://example.com'",
"'blah'.repeat(10000)",
"'http://example.com '.repeat(1000)"
],
symbol: ["Symbol('foo')", "Symbol()"],
errors: [
"throw new Error('This is a simple error message.');",
`
var error = new Error('Complicated error message');
error.stack =
"unserializeProfileOfArbitraryFormat@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:26705:11\\n" +
"_callee7$@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:27948:27\\n" +
"tryCatch@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:64198:37\\n" +
"invoke@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:64432:22\\n" +
"defineIteratorMethods/</prototype[method]@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:64250:16\\n" +
"step@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:5257:22\\n" +
"step/<@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:5268:13\\n" +
"run@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:64973:22\\n" +
"notify/<@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:64986:28\\n" +
"flush@http://localhost:4242/2969802751c9e11c0c2d.bundle.js:65282:9\\n";
error;
`,
`
var error = new Error('Complicated error message');
error.stack =
"onPacket@resource://devtools/shared/base-loader.js -> resource://devtools/shared/client/debugger-client.js:856:9\\n" +
"send/<@resource://devtools/shared/base-loader.js -> resource://devtools/shared/transport/transport.js:569:13\\n" +
"exports.makeInfallible/<@resource://devtools/shared/base-loader.js -> resource://devtools/shared/ThreadSafeDevToolsUtils.js:109:14\\n" +
"exports.makeInfallible/<@resource://devtools/shared/base-loader.js -> resource://devtools/shared/ThreadSafeDevToolsUtils.js:109:14\\n";
error;
`
]
};
samples.yolo = Object.keys(samples).reduce((res, key) => {
return [...res, ...samples[key]];
}, []);
module.exports = samples;