tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / js / script-tests / exception-linenums.js
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.');
2
3 function exceptionInFunction()
4 {
5     throw Exception();
6 }
7
8 var e = undefined;
9
10 try {
11     // Raises an exception that gets picked up by KJS_CHECKEXCEPTION
12     document.documentElement.innerHTML(foo);
13 } catch (exception) {
14     e = exception;
15 }
16 shouldBe("typeof e.sourceURL", '"string"');
17 shouldBe("e.line", '12');
18
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;
25 }
26 shouldBe("typeof e.sourceURL", '"string"');
27 shouldBe("e.line", '22');
28
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;
35 }
36 shouldBe("typeof e.sourceURL", '"string"');
37 shouldBe("e.line", '32');
38
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;
45 }
46 shouldBe("typeof e.sourceURL", '"string"');
47 shouldBe("e.line", '42');
48
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;
56 }
57 shouldBe("typeof e.sourceURL", '"string"');
58 shouldBe("e.line", '5');
59
60 realEval = eval;
61 delete eval;
62 (function(){
63     try {
64         eval("");
65     } catch(exception) {
66         e = exception;
67     }
68 })();
69 eval = realEval;
70 shouldBe("typeof e.sourceURL", '"string"');
71 shouldBe("e.line", '64');