test_bug870423.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /** Test for cross-scope instanceof. **/
  13. SimpleTest.waitForExplicitFinish();
  14. function go() {
  15. var sowin = $('soifr').contentWindow;
  16. var xowin = $('xoifr').contentWindow;
  17. check(window, sowin, 'HTMLBodyElement', function(win) { return win.document.body; });
  18. check(window, sowin, 'HTMLDocument', function(win) { return win.document; });
  19. check(window, sowin, 'Window', function(win) { return win; });
  20. check(window, sowin, 'Location', function(win) { return win.location; });
  21. ok(xowin instanceof Window, "Cross-origin instanceof should work");
  22. ok(xowin.location instanceof Location, "Cross-origin instanceof should work");
  23. SimpleTest.finish();
  24. }
  25. function check(win1, win2, constructorName, getInstance) {
  26. ok(getInstance(win1) instanceof win2[constructorName],
  27. "Cross-Scope instanceof works: " + constructorName + ", " + win1.location + ", " + win2.location);
  28. ok(getInstance(win2) instanceof win1[constructorName],
  29. "Cross-Scope instanceof works: " + constructorName + ", " + win2.location + ", " + win1.location);
  30. }
  31. </script>
  32. </head>
  33. <body onload="go();">
  34. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870423">Mozilla Bug 870423</a>
  35. <p id="display"></p>
  36. <div id="content" style="display: none">
  37. </div>
  38. <iframe id="soifr" src="file_empty.html"></iframe>
  39. <iframe id="xoifr" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
  40. <pre id="test">
  41. </pre>
  42. </body>
  43. </html>