Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / bindings / test / test_InstanceOf.html
blobd04e4e47712e7abf9bb177b45bb85db3fb070f37
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=748983
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 748983</title>
9 <script src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=748983">Mozilla Bug 748983</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
20 /** Test for Bug 748983 **/
22 SimpleTest.waitForExplicitFinish();
24 function runTest() {
25 ok(document instanceof EventTarget, "document is an event target");
26 ok(new XMLHttpRequest() instanceof XMLHttpRequest, "instanceof should work on XHR");
27 ok(HTMLElement.prototype instanceof Node, "instanceof needs to walk the prototype chain");
29 var otherWin = document.getElementById("testFrame").contentWindow;
31 ok(otherWin.HTMLElement.prototype instanceof otherWin.Node, "Same-origin instanceof of a interface prototype object should work, even if called cross-origin");
32 ok(!(otherWin.HTMLElement.prototype instanceof Node), "Cross-origin instanceof of a interface prototype object shouldn't work");
34 // We need to reset HTMLElement.prototype.__proto__ to the original value
35 // before using anything from the harness, otherwise the harness code breaks
36 // in weird ways.
37 HTMLElement.prototype.__proto__ = otherWin.Element.prototype;
38 var [ shouldSucceed, shouldFail ] = otherWin.runTest();
39 shouldSucceed = shouldSucceed && HTMLElement.prototype instanceof otherWin.Element;
40 shouldFail = shouldFail && HTMLElement.prototype instanceof Element;
41 HTMLElement.prototype.__proto__ = Element.prototype;
43 ok(shouldSucceed, "If an interface prototype object is on the protochain then instanceof with the interface object should succeed");
44 ok(!shouldFail, "If an interface prototype object is not on the protochain then instanceof with the interface object should succeed");
46 SimpleTest.finish();
49 </script>
50 </pre>
51 <iframe id="testFrame" src="file_InstanceOf.html" onload="runTest()"></iframe>
52 </body>
53 </html>