michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function onLoad() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); michael@0: openScratchpad(testThrowOutput); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html;charset=utf8,
Test throw outputs in Scratchpad
"; michael@0: } michael@0: michael@0: function testThrowOutput() michael@0: { michael@0: let scratchpad = gScratchpadWindow.Scratchpad, tests = []; michael@0: michael@0: let falsyValues = ["false", "0", "-0", "null", "undefined", "Infinity", michael@0: "-Infinity", "NaN"]; michael@0: falsyValues.forEach(function(value) { michael@0: tests.push({ michael@0: method: "display", michael@0: code: "throw " + value + ";", michael@0: result: "throw " + value + ";\n/*\nException: " + value + "\n*/", michael@0: label: "Correct exception message for '" + value + "' is shown" michael@0: }); michael@0: }); michael@0: michael@0: let server = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}) michael@0: .DebuggerServer; michael@0: michael@0: let longLength = server.LONG_STRING_LENGTH + 1; michael@0: let longString = new Array(longLength).join("a"); michael@0: let shortedString = longString.substring(0, server.LONG_STRING_INITIAL_LENGTH) + michael@0: "\u2026"; michael@0: michael@0: tests.push({ michael@0: method: "display", michael@0: code: "throw (new Array(" + longLength + ").join('a'));", michael@0: result: "throw (new Array(" + longLength + ").join('a'));\n" + michael@0: "/*\nException: " + shortedString + "\n*/", michael@0: label: "Correct exception message for a longString is shown" michael@0: }); michael@0: michael@0: runAsyncTests(scratchpad, tests).then(function() { michael@0: finish(); michael@0: }); michael@0: }