1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/webconsole/test/test_throw.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html lang="en"> 1.6 +<head> 1.7 + <meta charset="utf8"> 1.8 + <title>Web Console throw tests</title> 1.9 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.10 + <script type="text/javascript;version=1.8" src="common.js"></script> 1.11 + <!-- Any copyright is dedicated to the Public Domain. 1.12 + - http://creativecommons.org/publicdomain/zero/1.0/ --> 1.13 +</head> 1.14 +<body> 1.15 +<p>Web Console throw tests</p> 1.16 + 1.17 +<script class="testbody" type="text/javascript;version=1.8"> 1.18 +SimpleTest.waitForExplicitFinish(); 1.19 + 1.20 +function startTest() 1.21 +{ 1.22 + removeEventListener("load", startTest); 1.23 + attachConsole([], onAttach, true); 1.24 +} 1.25 + 1.26 +function onAttach(aState, aResponse) 1.27 +{ 1.28 + let tests = []; 1.29 + 1.30 + let falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"]; 1.31 + falsyValues.forEach(function(value) { 1.32 + tests.push(function() { 1.33 + aState.client.evaluateJS("throw " + value + ";", function(aResponse) { 1.34 + let type = aResponse.exception.type; 1.35 + is(type, value, "exception.type for throw " + value); 1.36 + nextTest(); 1.37 + }); 1.38 + }); 1.39 + }); 1.40 + 1.41 + let identityTestValues = [false, 0]; 1.42 + identityTestValues.forEach(function(value) { 1.43 + tests.push(function() { 1.44 + aState.client.evaluateJS("throw " + value + ";", function(aResponse) { 1.45 + let exception = aResponse.exception; 1.46 + ise(exception, value, "response.exception for throw " + value); 1.47 + nextTest(); 1.48 + }); 1.49 + }); 1.50 + }); 1.51 + 1.52 + let longString = Array(DebuggerServer.LONG_STRING_LENGTH + 1).join("a"), 1.53 + shortedString = longString.substring(0, 1.54 + DebuggerServer.LONG_STRING_INITIAL_LENGTH 1.55 + ); 1.56 + tests.push(function() { 1.57 + aState.client.evaluateJS("throw '" + longString + "';", function(aResponse) { 1.58 + is(aResponse.exception.initial, shortedString, 1.59 + "exception.initial for throw longString" 1.60 + ); 1.61 + nextTest(); 1.62 + }); 1.63 + }); 1.64 + 1.65 + runTests(tests, endTest.bind(null, aState)); 1.66 +} 1.67 + 1.68 +function endTest(aState) 1.69 +{ 1.70 + closeDebugger(aState, function() { 1.71 + SimpleTest.finish(); 1.72 + }); 1.73 +} 1.74 + 1.75 +addEventListener("load", startTest); 1.76 +</script> 1.77 +</body> 1.78 +</html>