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