toolkit/devtools/webconsole/test/test_throw.html

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 <!DOCTYPE HTML>
     2 <html lang="en">
     3 <head>
     4   <meta charset="utf8">
     5   <title>Web Console throw tests</title>
     6   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     7   <script type="text/javascript;version=1.8" src="common.js"></script>
     8   <!-- Any copyright is dedicated to the Public Domain.
     9      - http://creativecommons.org/publicdomain/zero/1.0/ -->
    10 </head>
    11 <body>
    12 <p>Web Console throw tests</p>
    14 <script class="testbody" type="text/javascript;version=1.8">
    15 SimpleTest.waitForExplicitFinish();
    17 function startTest()
    18 {
    19   removeEventListener("load", startTest);
    20   attachConsole([], onAttach, true);
    21 }
    23 function onAttach(aState, aResponse)
    24 {
    25   let tests = [];
    27   let falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"];
    28   falsyValues.forEach(function(value) {
    29     tests.push(function() {
    30       aState.client.evaluateJS("throw " + value + ";", function(aResponse) {
    31         let type = aResponse.exception.type;
    32         is(type, value, "exception.type for throw " + value);
    33         nextTest();
    34       });
    35     });
    36   });
    38   let identityTestValues = [false, 0];
    39   identityTestValues.forEach(function(value) {
    40     tests.push(function() {
    41       aState.client.evaluateJS("throw " + value + ";", function(aResponse) {
    42         let exception = aResponse.exception;
    43         ise(exception, value, "response.exception for throw " + value);
    44         nextTest();
    45       });
    46     });
    47   });
    49   let longString = Array(DebuggerServer.LONG_STRING_LENGTH + 1).join("a"),
    50       shortedString = longString.substring(0,
    51                         DebuggerServer.LONG_STRING_INITIAL_LENGTH
    52                       );
    53   tests.push(function() {
    54     aState.client.evaluateJS("throw '" + longString + "';", function(aResponse) {
    55       is(aResponse.exception.initial, shortedString,
    56         "exception.initial for throw longString"
    57       );
    58       nextTest();
    59     });
    60   });
    62   runTests(tests, endTest.bind(null, aState));
    63 }
    65 function endTest(aState)
    66 {
    67   closeDebugger(aState, function() {
    68     SimpleTest.finish();
    69   });
    70 }
    72 addEventListener("load", startTest);
    73 </script>
    74 </body>
    75 </html>

mercurial