1 description('This test makes sure the exception stack has line number information.');
4 function foo() { // line 4
13 // The stack trace contains the full path to the file. We need to trim it to
14 // only the part below LayoutTest so that the test results are consistent
15 // regardless of which server it is served from.
17 // String.match() generates an array of matches. We'll just convert all the
18 // elements back into a comma separated string by simply stringifying the
19 // array. This makes it easier to compare the resultant stack trace info.
21 result
= String(temp
.match(/LayoutTests\/[^:]+\:[0-9]+/g));
23 shouldBe("result", '"LayoutTests/fast/js/script-tests/exception-line-number.js:6,LayoutTests/fast/js/script-tests/exception-line-number.js:11"');
26 // Test window.onerror:
28 window
.onerror = function(msg
, url
, line
) {
29 url
= String(url
.match(/LayoutTests\/[^:]+/g));
30 result
= url
+ ':' + line
;
31 shouldBe("result", '"LayoutTests/fast/js/script-tests/exception-line-number.js:36"');
32 return true; // We handled it.
35 this.err
= Error(12, "line number test");
36 throw this.err
; // Line 36.