js/xpconnect/tests/mochitest/test_bug870423.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9134d444744d
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=870423
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 870423</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 <script type="application/javascript">
12
13 /** Test for cross-scope instanceof. **/
14 SimpleTest.waitForExplicitFinish();
15
16 function go() {
17 var sowin = $('soifr').contentWindow;
18 var xowin = $('xoifr').contentWindow;
19
20 check(window, sowin, 'HTMLBodyElement', function(win) { return win.document.body; });
21 check(window, sowin, 'HTMLDocument', function(win) { return win.document; });
22 check(window, sowin, 'Window', function(win) { return win; });
23 check(window, sowin, 'Location', function(win) { return win.location; });
24
25 todo(xowin instanceof Window, "Cross-origin instanceof should work");
26 todo(xowin.location instanceof Location, "Cross-origin instanceof should work");
27
28 SimpleTest.finish();
29 }
30
31 function check(win1, win2, constructorName, getInstance) {
32 ok(getInstance(win1) instanceof win2[constructorName],
33 "Cross-Scope instanceof works: " + constructorName + ", " + win1.location + ", " + win2.location);
34 ok(getInstance(win2) instanceof win1[constructorName],
35 "Cross-Scope instanceof works: " + constructorName + ", " + win2.location + ", " + win1.location);
36 }
37
38 </script>
39 </head>
40 <body onload="go();">
41 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870423">Mozilla Bug 870423</a>
42 <p id="display"></p>
43 <div id="content" style="display: none">
44
45 </div>
46 <iframe id="soifr" src="file_empty.html"></iframe>
47 <iframe id="xoifr" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
48 <pre id="test">
49 </pre>
50 </body>
51 </html>

mercurial