browser/devtools/scratchpad/test/browser_scratchpad_throw_output.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.

     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/ */
     6 function test()
     7 {
     8   waitForExplicitFinish();
    10   gBrowser.selectedTab = gBrowser.addTab();
    11   gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
    12     gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
    13     openScratchpad(testThrowOutput);
    14   }, true);
    16   content.location = "data:text/html;charset=utf8,<p>Test throw outputs in Scratchpad</p>";
    17 }
    19 function testThrowOutput()
    20 {
    21   let scratchpad = gScratchpadWindow.Scratchpad, tests = [];
    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   });
    34   let server = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {})
    35                .DebuggerServer;
    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";
    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   });
    50   runAsyncTests(scratchpad, tests).then(function() {
    51     finish();
    52   });
    53 }

mercurial