test_exception_messages.html (3743B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=882653 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 882653</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 13 /** Test for Bug 882653 */ 14 // Each test is a string to eval, the expected exception message, and the 15 // test description. 16 var tests = [ 17 [ "document.documentElement.appendChild.call({}, new Image())", 18 "'appendChild' called on an object that does not implement interface Node.", 19 "bogus method this object" ], 20 [ 'Object.getOwnPropertyDescriptor(Document.prototype, "documentElement").get.call({})', 21 "'get documentElement' called on an object that does not implement interface Document.", 22 "bogus getter this object" ], 23 [ 'Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML").set.call({})', 24 "'set innerHTML' called on an object that does not implement interface Element.", 25 "bogus setter this object" ], 26 [ "document.documentElement.appendChild(5)", 27 "Node.appendChild: Argument 1 is not an object.", 28 "bogus interface argument" ], 29 [ "document.documentElement.appendChild(null)", 30 "Node.appendChild: Argument 1 is not an object.", 31 "null interface argument" ], 32 [ "document.createTreeWalker(document).currentNode = 5", 33 "TreeWalker.currentNode setter: Value being assigned is not an object.", 34 "interface setter call" ], 35 [ "document.documentElement.appendChild({})", 36 "Node.appendChild: Argument 1 does not implement interface Node.", 37 "wrong interface argument" ], 38 [ "document.createTreeWalker(document).currentNode = {}", 39 "TreeWalker.currentNode setter: Value being assigned does not implement interface Node.", 40 "wrong interface setter call" ], 41 [ 'document.createElement("canvas").getContext("2d").fill("bogus")', 42 "CanvasRenderingContext2D.fill: 'bogus' (value of argument 1) is not a valid value for enumeration CanvasWindingRule.", 43 "bogus enum value" ], 44 [ "document.createTreeWalker(document, 0xFFFFFFFF, { acceptNode: 5 }).nextNode()", 45 "Property 'acceptNode' is not callable.", 46 "non-callable callback interface operation property" ], 47 [ "(new TextDecoder).decode(new Uint8Array(), 5)", 48 "TextDecoder.decode: Argument 2 can't be converted to a dictionary.", 49 "primitive passed for a dictionary" ], 50 [ "URL.createObjectURL(null)", 51 "URL.createObjectURL: Argument 1 could not be converted to any of: Blob, MediaSource.", 52 "overload resolution failure" ], 53 [ 'document.createElement("select").add({})', 54 "HTMLSelectElement.add: Argument 1 could not be converted to any of: HTMLOptionElement, HTMLOptGroupElement.", 55 "invalid value passed for union" ], 56 [ 'document.createElement("canvas").getContext("2d").createLinearGradient(0, 1, 0, 1).addColorStop(NaN, "")', 57 "CanvasGradient.addColorStop: Argument 1 is not a finite floating-point value.", 58 "invalid float" ], 59 ]; 60 61 for (var i = 0; i < tests.length; ++i) { 62 var msg = "Correct exception should be thrown for " + tests[i][2]; 63 try { 64 // eslint-disable-next-line no-eval 65 eval(tests[i][0]); 66 ok(false, msg); 67 } catch (e) { 68 is(e.message, tests[i][1], msg); 69 } 70 } 71 72 </script> 73 </head> 74 <body> 75 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=882653">Mozilla Bug 882653</a> 76 <p id="display"></p> 77 <div id="content" style="display: none"> 78 79 </div> 80 <pre id="test"> 81 </pre> 82 </body> 83 </html>