browser/devtools/scratchpad/test/browser_scratchpad_display_outputs_errors.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 /* Bug 690552 */
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 browserLoad() {
michael@0 12 gBrowser.selectedBrowser.removeEventListener("load", browserLoad, true);
michael@0 13 openScratchpad(runTests, {"state":{"text":""}});
michael@0 14 }, true);
michael@0 15
michael@0 16 content.location = "data:text/html,<p>test that exceptions are output as " +
michael@0 17 "comments for 'display' and not sent to the console in Scratchpad";
michael@0 18 }
michael@0 19
michael@0 20 function runTests()
michael@0 21 {
michael@0 22 let scratchpad = gScratchpadWindow.Scratchpad;
michael@0 23
michael@0 24 let message = "\"Hello World!\""
michael@0 25 let openComment = "\n/*\n";
michael@0 26 let closeComment = "\n*/";
michael@0 27 let error = "throw new Error(\"Ouch!\")";
michael@0 28 let syntaxError = "(";
michael@0 29
michael@0 30 let tests = [{
michael@0 31 method: "display",
michael@0 32 code: message,
michael@0 33 result: message + openComment + "Hello World!" + closeComment,
michael@0 34 label: "message display output"
michael@0 35 },
michael@0 36 {
michael@0 37 method: "display",
michael@0 38 code: error,
michael@0 39 result: error + openComment + "Exception: Ouch!\n@" +
michael@0 40 scratchpad.uniqueName + ":1:1" + closeComment,
michael@0 41 label: "error display output",
michael@0 42 },
michael@0 43 {
michael@0 44 method: "display",
michael@0 45 code: syntaxError,
michael@0 46 result: syntaxError + openComment + "Exception: syntax error\n@" +
michael@0 47 scratchpad.uniqueName + ":1" + closeComment,
michael@0 48 label: "syntaxError display output",
michael@0 49 },
michael@0 50 {
michael@0 51 method: "run",
michael@0 52 code: message,
michael@0 53 result: message,
michael@0 54 label: "message run output",
michael@0 55 },
michael@0 56 {
michael@0 57 method: "run",
michael@0 58 code: error,
michael@0 59 result: error + openComment + "Exception: Ouch!\n@" +
michael@0 60 scratchpad.uniqueName + ":1:1" + closeComment,
michael@0 61 label: "error run output",
michael@0 62 },
michael@0 63 {
michael@0 64 method: "run",
michael@0 65 code: syntaxError,
michael@0 66 result: syntaxError + openComment + "Exception: syntax error\n@" +
michael@0 67 scratchpad.uniqueName + ":1" + closeComment,
michael@0 68 label: "syntaxError run output",
michael@0 69 }];
michael@0 70
michael@0 71 runAsyncTests(scratchpad, tests).then(finish);
michael@0 72 }

mercurial