test_bug916945.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=916945
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 916945</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 Bug 916945 **/
  13. SimpleTest.waitForExplicitFinish();
  14. var gLoadCount = 0;
  15. function loaded() {
  16. if (++gLoadCount == 2)
  17. go();
  18. }
  19. function go() {
  20. // Both same-origin and cross-origin names should be visible if they're set
  21. // on the iframe element.
  22. ok('winA' in window, "same-origin named access works");
  23. ok(winA instanceof Window, "same-origin named access works");
  24. ok('winB' in window, "cross-origin named access works when iframe name matches");
  25. // XXXbholley - flip me when Window moves to new bindings.
  26. todo_is(winB instanceof Window, "cross-origin named access works when iframe name matches");
  27. // Setting the 'name' attribute should propagate to the docshell.
  28. var ifrB = document.getElementById('ifrB');
  29. ifrB.setAttribute('name', 'foo');
  30. is(SpecialPowers.wrap(ifrB).contentWindow.name, 'foo', 'attribute sets propagate to the docshell');
  31. ok('foo' in window, "names are dynamic if updated via setAttribute");
  32. // XXXbholley - flip me when Window moves to new bindings.
  33. todo('foo' instanceof Window, "names are dynamic if updated via setAttribute");
  34. // Setting window.name on the subframe should not propagate to the attribute.
  35. SpecialPowers.wrap(ifrB).contentWindow.name = 'bar';
  36. is(ifrB.getAttribute('name'), 'foo', 'docshell updates dont propagate to the attribute');
  37. // When the frame element attribute and docshell name don't match, nothing is returned.
  38. ok(!('foo' in window), "frame element name not resolved if it doesn't match the docshell");
  39. ok(!('bar' in window), "docshell name not resolved if it doesn't match the frame element");
  40. SimpleTest.finish();
  41. }
  42. </script>
  43. </head>
  44. <body>
  45. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=916945">Mozilla Bug 916945</a>
  46. <p id="display"></p>
  47. <div id="content" style="display: none">
  48. </div>
  49. <iframe id="ifrA" name="winA" onload="loaded();" src="file_empty.html"></iframe>
  50. <iframe id="ifrB" name="winB" onload="loaded();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
  51. <pre id="test">
  52. </pre>
  53. </body>
  54. </html>