Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / exception-linenums.js
blobbe94e19c1e06a9084fe9ca16c114e220ca30739e
1 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.');
3 function exceptionInFunction()
5 throw Exception();
8 var e = undefined;
10 try {
11 // Raises an exception that gets picked up by KJS_CHECKEXCEPTION
12 document.documentElement.innerHTML(foo);
13 } catch (exception) {
14 e = exception;
16 shouldBe("typeof e.sourceURL", '"string"');
17 shouldBe("e.line", '12');
19 e = undefined;
20 try {
21 // Raises an exception that gets picked up by KJS_CHECKEXCEPTIONVALUE
22 document.documentElement.appendChild('').prefix = '';
23 } catch (exception) {
24 e = exception;
26 shouldBe("typeof e.sourceURL", '"string"');
27 shouldBe("e.line", '22');
29 e = undefined;
30 try {
31 // Raises an exception that gets picked up by KJS_CHECKEXCEPTIONREFERENCE
32 document.documentElement.appendChild('').innerHTML = '';
33 } catch (exception) {
34 e = exception;
36 shouldBe("typeof e.sourceURL", '"string"');
37 shouldBe("e.line", '32');
39 e = undefined;
40 try {
41 // Raises an exception that gets picked up by KJS_CHECKEXCEPTIONLIST
42 document.getElementById(1());
43 } catch (exception) {
44 e = exception;
46 shouldBe("typeof e.sourceURL", '"string"');
47 shouldBe("e.line", '42');
49 e = undefined;
50 // Raises an exception inside a function to check that its line number
51 // isn't overwritten in the assignment node.
52 try {
53 var a = exceptionInFunction();
54 } catch (exception) {
55 e = exception;
57 shouldBe("typeof e.sourceURL", '"string"');
58 shouldBe("e.line", '5');
60 realEval = eval;
61 delete eval;
62 (function(){
63 try {
64 eval("");
65 } catch(exception) {
66 e = exception;
68 })();
69 eval = realEval;
70 shouldBe("typeof e.sourceURL", '"string"');
71 shouldBe("e.line", '64');
73 var firstPropIsGetter = {
74 get getter() { throw {} }
76 var secondPropIsGetter = {
77 prop: 1,
78 get getter() { throw {} }
80 var firstPropIsSetter = {
81 set setter(a) { throw {} }
83 var secondPropIsSetter = {
84 prop: 1,
85 set setter(a) { throw {} }
88 try {
89 firstPropIsGetter.getter;
90 } catch(ex) {
91 e = ex;
92 shouldBe("e.line", "74");
95 try {
96 secondPropIsGetter.getter;
97 } catch(ex) {
98 e = ex;
99 shouldBe("e.line", "78");
102 try {
103 firstPropIsSetter.setter = '';
104 } catch(ex) {
105 e = ex;
106 shouldBe("e.line", "81");
109 try {
110 secondPropIsSetter.setter = '';
111 } catch(ex) {
112 e = ex;
113 shouldBe("e.line", "85");