1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/scratchpad/test/browser_scratchpad_display_outputs_errors.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* vim: set ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 +/* Bug 690552 */ 1.8 + 1.9 +function test() 1.10 +{ 1.11 + waitForExplicitFinish(); 1.12 + 1.13 + gBrowser.selectedTab = gBrowser.addTab(); 1.14 + gBrowser.selectedBrowser.addEventListener("load", function browserLoad() { 1.15 + gBrowser.selectedBrowser.removeEventListener("load", browserLoad, true); 1.16 + openScratchpad(runTests, {"state":{"text":""}}); 1.17 + }, true); 1.18 + 1.19 + content.location = "data:text/html,<p>test that exceptions are output as " + 1.20 + "comments for 'display' and not sent to the console in Scratchpad"; 1.21 +} 1.22 + 1.23 +function runTests() 1.24 +{ 1.25 + let scratchpad = gScratchpadWindow.Scratchpad; 1.26 + 1.27 + let message = "\"Hello World!\"" 1.28 + let openComment = "\n/*\n"; 1.29 + let closeComment = "\n*/"; 1.30 + let error = "throw new Error(\"Ouch!\")"; 1.31 + let syntaxError = "("; 1.32 + 1.33 + let tests = [{ 1.34 + method: "display", 1.35 + code: message, 1.36 + result: message + openComment + "Hello World!" + closeComment, 1.37 + label: "message display output" 1.38 + }, 1.39 + { 1.40 + method: "display", 1.41 + code: error, 1.42 + result: error + openComment + "Exception: Ouch!\n@" + 1.43 + scratchpad.uniqueName + ":1:1" + closeComment, 1.44 + label: "error display output", 1.45 + }, 1.46 + { 1.47 + method: "display", 1.48 + code: syntaxError, 1.49 + result: syntaxError + openComment + "Exception: syntax error\n@" + 1.50 + scratchpad.uniqueName + ":1" + closeComment, 1.51 + label: "syntaxError display output", 1.52 + }, 1.53 + { 1.54 + method: "run", 1.55 + code: message, 1.56 + result: message, 1.57 + label: "message run output", 1.58 + }, 1.59 + { 1.60 + method: "run", 1.61 + code: error, 1.62 + result: error + openComment + "Exception: Ouch!\n@" + 1.63 + scratchpad.uniqueName + ":1:1" + closeComment, 1.64 + label: "error run output", 1.65 + }, 1.66 + { 1.67 + method: "run", 1.68 + code: syntaxError, 1.69 + result: syntaxError + openComment + "Exception: syntax error\n@" + 1.70 + scratchpad.uniqueName + ":1" + closeComment, 1.71 + label: "syntaxError run output", 1.72 + }]; 1.73 + 1.74 + runAsyncTests(scratchpad, tests).then(finish); 1.75 +}