1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bindings/test/test_exception_messages.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=882653 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 882653</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 + <script type="application/javascript"> 1.15 + 1.16 + /** Test for Bug 882653 **/ 1.17 + // Each test is a string to eval, the expected exception message, and the 1.18 + // test description. 1.19 + var tests = [ 1.20 + [ 'document.documentElement.appendChild.call({}, new Image())', 1.21 + "'appendChild' called on an object that does not implement interface Node.", 1.22 + "bogus method this object" ], 1.23 + [ 'Object.getOwnPropertyDescriptor(Document.prototype, "documentElement").get.call({})', 1.24 + "'documentElement' getter called on an object that does not implement interface Document.", 1.25 + "bogus getter this object" ], 1.26 + [ 'Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML").set.call({})', 1.27 + "'innerHTML' setter called on an object that does not implement interface Element.", 1.28 + "bogus setter this object" ], 1.29 + [ 'document.documentElement.appendChild(5)', 1.30 + "Argument 1 of Node.appendChild is not an object.", 1.31 + "bogus interface argument" ], 1.32 + [ 'document.documentElement.appendChild(null)', 1.33 + "Argument 1 of Node.appendChild is not an object.", 1.34 + "null interface argument" ], 1.35 + [ 'document.createTreeWalker(document).currentNode = 5', 1.36 + "Value being assigned to TreeWalker.currentNode is not an object.", 1.37 + "interface setter call" ], 1.38 + [ 'document.documentElement.appendChild({})', 1.39 + "Argument 1 of Node.appendChild does not implement interface Node.", 1.40 + "wrong interface argument" ], 1.41 + [ 'document.createTreeWalker(document).currentNode = {}', 1.42 + "Value being assigned to TreeWalker.currentNode does not implement interface Node.", 1.43 + "wrong interface setter call" ], 1.44 + [ 'document.createElement("canvas").getContext("2d").fill("bogus")', 1.45 + "Argument 1 of CanvasRenderingContext2D.fill 'bogus' is not a valid value for enumeration CanvasWindingRule.", 1.46 + "bogus enum value" ], 1.47 + [ 'document.createTreeWalker(document, 0xFFFFFFFF, { acceptNode: 5 }).nextNode()', 1.48 + "Property 'acceptNode' is not callable.", 1.49 + "non-callable callback interface operation property" ], 1.50 + [ '(new TextEncoder).encode("", new RegExp())', 1.51 + "Argument 2 of TextEncoder.encode can't be converted to a dictionary.", 1.52 + "regexp passed for a dictionary" ], 1.53 + [ 'URL.createObjectURL(null, null)', 1.54 + "Argument 1 is not valid for any of the 2-argument overloads of URL.createObjectURL.", 1.55 + "overload resolution failure" ], 1.56 + [ 'document.createElement("select").add({})', 1.57 + "Argument 1 of HTMLSelectElement.add could not be converted to any of: HTMLOptionElement, HTMLOptGroupElement.", 1.58 + "invalid value passed for union" ], 1.59 + [ 'document.createElement("canvas").getContext("2d").createLinearGradient(0, 1, 0, 1).addColorStop(NaN, "")', 1.60 + "Argument 1 of CanvasGradient.addColorStop is not a finite floating-point value.", 1.61 + "invalid float" ] 1.62 + ]; 1.63 + 1.64 + for (var i = 0; i < tests.length; ++i) { 1.65 + msg = "Correct exception should be thrown for " + tests[i][2]; 1.66 + try { 1.67 + eval(tests[i][0]); 1.68 + ok(false, msg); 1.69 + } catch (e) { 1.70 + is(e.message, tests[i][1], msg); 1.71 + } 1.72 + } 1.73 + 1.74 + </script> 1.75 +</head> 1.76 +<body> 1.77 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=882653">Mozilla Bug 882653</a> 1.78 +<p id="display"></p> 1.79 +<div id="content" style="display: none"> 1.80 + 1.81 +</div> 1.82 +<pre id="test"> 1.83 +</pre> 1.84 +</body> 1.85 +</html>