1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/bugs/test_bug370098.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=370098 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 370098</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=370098">Mozilla Bug 370098</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 +/** Test for Bug 370098 **/ 1.23 +function test_constructor(dom_proto, shouldthrow) { 1.24 + var threw = false; 1.25 + try { 1.26 + window[dom_proto](); 1.27 + } catch (e) { 1.28 + threw = true; 1.29 + } 1.30 + // XSLTProcessor is still on the old bindings. 1.31 + if (dom_proto != 'XSLTProcessor') 1.32 + ok(threw, "Calling |" + dom_proto + "()| should always throw"); 1.33 + 1.34 + threw = false; 1.35 + try { 1.36 + new window[dom_proto](); 1.37 + } catch (e) { 1.38 + threw = true; 1.39 + } 1.40 + is(threw, shouldthrow, "Calling |new " + dom_proto + "()| should" + (shouldthrow ? " " : " not ") + "throw"); 1.41 +} 1.42 +var dom_protos = [ "Element" ]; 1.43 +var dom_constructors = [ "Document", "Image", "DOMParser", "XMLSerializer", 1.44 + "XMLHttpRequest", "XPathEvaluator", "XSLTProcessor" ]; 1.45 +dom_protos.forEach( 1.46 + function(p) { test_constructor(p, true); }); 1.47 +dom_constructors.forEach( 1.48 + function(p) { test_constructor(p, false); }); 1.49 +</script> 1.50 +</pre> 1.51 +</body> 1.52 +</html> 1.53 +