Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / exception-line-number.js
blob75e21b5fe5599a0f0145462b88afb744e49956f4
1 description('This test makes sure the exception stack has line number information.');
3 // Test error.stack:
4 function foo() { // line 4
5 try {
6 doError(); // line 6
7 } catch(err) {
8 temp = err.stack;
11 foo(); // line 11
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.