forked from MozillaSecurity/funfuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-misc.js
More file actions
80 lines (64 loc) · 1.98 KB
/
test-misc.js
File metadata and controls
80 lines (64 loc) · 1.98 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
function optionalTests(f, code, wtt)
{
if (count % 100 == 1) {
tryHalves(code);
}
if (count % 100 == 2 && engine == ENGINE_SPIDERMONKEY_TRUNK) {
try {
Reflect.parse(code);
} catch(e) {
}
}
if (count % 100 == 3 && f && typeof disassemble == "function") {
// It's hard to use the recursive disassembly in the comparator,
// but let's at least make sure the disassembler itself doesn't crash.
disassemble("-r", f);
}
if (0 && f && wtt.allowExec && engine == ENGINE_SPIDERMONKEY_TRUNK) {
simpleDVGTest(code);
tryEnsureSanity();
}
if (count % 100 == 6 && f && wtt.allowExec && wtt.expectConsistentOutput && wtt.expectConsistentOutputAcrossIter
&& engine == ENGINE_SPIDERMONKEY_TRUNK && getBuildConfiguration()['more-deterministic']) {
nestingConsistencyTest(code);
}
}
function simpleDVGTest(code)
{
var fullCode = "(function() { try { \n" + code + "\n; throw 1; } catch(exx) { this.nnn.nnn } })()";
try {
eval(fullCode);
} catch(e) {
if (e.message != "this.nnn is undefined" && e.message.indexOf("redeclaration of") == -1) {
foundABug("Wrong error message", e);
}
}
}
function tryHalves(code)
{
// See if there are any especially horrible bugs that appear when the parser has to start/stop in the middle of something. this is kinda evil.
// Stray "}"s are likely in secondHalf, so use new Function rather than eval. "}" can't escape from new Function :)
var f, firstHalf, secondHalf;
try {
firstHalf = code.substr(0, code.length / 2);
if (verbose)
dumpln("First half: " + firstHalf);
f = new Function(firstHalf);
void ("" + f);
}
catch(e) {
if (verbose)
dumpln("First half compilation error: " + e);
}
try {
secondHalf = code.substr(code.length / 2, code.length);
if (verbose)
dumpln("Second half: " + secondHalf);
f = new Function(secondHalf);
void ("" + f);
}
catch(e) {
if (verbose)
dumpln("Second half compilation error: " + e);
}
}