browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d65174a72079
1 /* vim: set ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
4
5
6 function test()
7 {
8 waitForExplicitFinish();
9
10 gBrowser.selectedTab = gBrowser.addTab();
11 gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
12 gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
13 openScratchpad(testThrowOutput);
14 }, true);
15
16 content.location = "data:text/html;charset=utf8,<p>Test throw outputs in Scratchpad</p>";
17 }
18
19 function testThrowOutput()
20 {
21 let scratchpad = gScratchpadWindow.Scratchpad, tests = [];
22
23 let falsyValues = ["false", "0", "-0", "null", "undefined", "Infinity",
24 "-Infinity", "NaN"];
25 falsyValues.forEach(function(value) {
26 tests.push({
27 method: "display",
28 code: "throw " + value + ";",
29 result: "throw " + value + ";\n/*\nException: " + value + "\n*/",
30 label: "Correct exception message for '" + value + "' is shown"
31 });
32 });
33
34 let server = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {})
35 .DebuggerServer;
36
37 let longLength = server.LONG_STRING_LENGTH + 1;
38 let longString = new Array(longLength).join("a");
39 let shortedString = longString.substring(0, server.LONG_STRING_INITIAL_LENGTH) +
40 "\u2026";
41
42 tests.push({
43 method: "display",
44 code: "throw (new Array(" + longLength + ").join('a'));",
45 result: "throw (new Array(" + longLength + ").join('a'));\n" +
46 "/*\nException: " + shortedString + "\n*/",
47 label: "Correct exception message for a longString is shown"
48 });
49
50 runAsyncTests(scratchpad, tests).then(function() {
51 finish();
52 });
53 }

mercurial