|
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 type="application/javascript" 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"> |
|
19 |
|
20 /** Test for Bug 748983 **/ |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 function runTest() |
|
25 { |
|
26 ok(document instanceof EventTarget, "document is an event target") |
|
27 ok(new XMLHttpRequest() instanceof XMLHttpRequest, "instanceof should work on XHR"); |
|
28 ok(HTMLElement.prototype instanceof Node, "instanceof needs to walk the prototype chain") |
|
29 |
|
30 var otherWin = document.getElementById("testFrame").contentWindow; |
|
31 |
|
32 ok(otherWin.HTMLElement.prototype instanceof otherWin.Node, "Same-origin instanceof of a interface prototype object should work, even if called cross-origin"); |
|
33 ok(!(otherWin.HTMLElement.prototype instanceof Node), "Cross-origin instanceof of a interface prototype object shouldn't work"); |
|
34 |
|
35 // We need to reset HTMLElement.prototype.__proto__ to the original value |
|
36 // before using anything from the harness, otherwise the harness code breaks |
|
37 // in weird ways. |
|
38 HTMLElement.prototype.__proto__ = otherWin.Element.prototype; |
|
39 var [ shouldSucceed, shouldFail ] = otherWin.runTest(); |
|
40 shouldSucceed = shouldSucceed && HTMLElement.prototype instanceof otherWin.Element; |
|
41 shouldFail = shouldFail && HTMLElement.prototype instanceof Element; |
|
42 HTMLElement.prototype.__proto__ = Element.prototype; |
|
43 |
|
44 ok(shouldSucceed, "If an interface prototype object is on the protochain then instanceof with the interface object should succeed"); |
|
45 ok(!shouldFail, "If an interface prototype object is not on the protochain then instanceof with the interface object should succeed"); |
|
46 |
|
47 SimpleTest.finish(); |
|
48 } |
|
49 |
|
50 </script> |
|
51 </pre> |
|
52 <iframe id="testFrame" src="file_InstanceOf.html" onload="runTest()"></iframe> |
|
53 </body> |
|
54 </html> |