summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/script-tests/exception-linenums.js
blob: be94e19c1e06a9084fe9ca16c114e220ca30739e (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
description('This test exercises the source URL and line number that is embedded in JavaScript exceptions, which is displayed in places like the JavaScript console.');

function exceptionInFunction()
{
    throw Exception();
}

var e = undefined;

try {
    // Raises an exception that gets picked up by KJS_CHECKEXCEPTION
    document.documentElement.innerHTML(foo);
} catch (exception) {
    e = exception;
}
shouldBe("typeof e.sourceURL", '"string"');
shouldBe("e.line", '12');

e = undefined;
try {
    // Raises an exception that gets picked up by KJS_CHECKEXCEPTIONVALUE
    document.documentElement.appendChild('').prefix = '';
} catch (exception) {
    e = exception;
}
shouldBe("typeof e.sourceURL", '"string"');
shouldBe("e.line", '22');

e = undefined;
try {
    // Raises an exception that gets picked up by KJS_CHECKEXCEPTIONREFERENCE
    document.documentElement.appendChild('').innerHTML = '';
} catch (exception) {
    e = exception;
}
shouldBe("typeof e.sourceURL", '"string"');
shouldBe("e.line", '32');

e = undefined;
try {
    // Raises an exception that gets picked up by KJS_CHECKEXCEPTIONLIST
    document.getElementById(1());
} catch (exception) {
    e = exception;
}
shouldBe("typeof e.sourceURL", '"string"');
shouldBe("e.line", '42');

e = undefined;
// Raises an exception inside a function to check that its line number
// isn't overwritten in the assignment node.
try {
    var a = exceptionInFunction();
} catch (exception) {
    e = exception;
}
shouldBe("typeof e.sourceURL", '"string"');
shouldBe("e.line", '5');

realEval = eval;
delete eval;
(function(){
    try {
        eval("");
    } catch(exception) {
        e = exception;
    }
})();
eval = realEval;
shouldBe("typeof e.sourceURL", '"string"');
shouldBe("e.line", '64');

var firstPropIsGetter = {
    get getter() { throw {} }
};
var secondPropIsGetter = {
    prop: 1,
    get getter() { throw {} }
};
var firstPropIsSetter = {
    set setter(a) { throw {} }
};
var secondPropIsSetter = {
    prop: 1,
    set setter(a) { throw {} }
};

try {
    firstPropIsGetter.getter;
} catch(ex) {
    e = ex;
    shouldBe("e.line", "74");
}

try {
    secondPropIsGetter.getter;
} catch(ex) {
    e = ex;
    shouldBe("e.line", "78");
}

try {
    firstPropIsSetter.setter = '';
} catch(ex) {
    e = ex;
    shouldBe("e.line", "81");
}

try {
    secondPropIsSetter.setter = '';
} catch(ex) {
    e = ex;
    shouldBe("e.line", "85");
}