test_bug505915.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=505915
  5. -->
  6. <head>
  7. <title>Test for Bug 505915</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=505915">Mozilla Bug 505915</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script type="application/javascript;version=1.7">
  18. /** Test for Bug 505915 **/
  19. window.addEventListener("message", function () { gen.next() }, false);
  20. function go() {
  21. var ifr = $('ifr');
  22. try {
  23. // NB: the contentDocument getter now returns null for cross-origin
  24. // frames, so use SpecialPowers to get a security wrapper to the document.
  25. var xdoc = SpecialPowers.unwrap(SpecialPowers.wrap(ifr).contentDocument)
  26. document.createTreeWalker(xdoc, 0, null);
  27. ok(false, "should have thrown a security exception");
  28. } catch (e) {
  29. ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||
  30. /TypeError: Argument 1 of Document.createTreeWalker does not implement interface Node/.test(e),
  31. "threw a security exception or binding exception instead of an " +
  32. "invalid child exception");
  33. }
  34. SimpleTest.finish();
  35. yield;
  36. }
  37. SimpleTest.waitForExplicitFinish();
  38. </script>
  39. </pre>
  40. <iframe id="ifr" onload="gen = go(); gen.next();" src="http://example.org/"></iframe>
  41. </body>
  42. </html>