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