test_bug478438.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=478438
  5. -->
  6. <head>
  7. <title>Test for Bug 478438</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. <script type="application/javascript;version=1.8">
  11. function fail(s, e) { ok(false, s + e) }
  12. function pass(s, e) { ok(true, s) }
  13. (pass.opposite = fail).opposite = pass;
  14. function test() {
  15. if (test.calledAlready)
  16. return;
  17. test.calledAlready = true;
  18. var iwin = document.getElementById("f").contentWindow;
  19. function testOne(fn, onAllow, infinitive) {
  20. try { fn(); onAllow("able " + infinitive, "") }
  21. catch (e) { onAllow.opposite("unable " + infinitive, ": " + e) }
  22. }
  23. testOne(() => iwin.focus, pass,
  24. "to resolve/get allAccess property iwin.focus");
  25. testOne(() => iwin.focus(), pass,
  26. "to call allAccess method iwin.focus");
  27. testOne(() => iwin.alert, fail,
  28. "to resolve/get restricted property iwin.alert");
  29. testOne(() => iwin.alert(), fail,
  30. "to call restricted method iwin.alert");
  31. testOne(() => iwin.location.toString(), fail,
  32. "to call restricted method iwin.location.toString");
  33. testOne(function() { iwin.location = "http://example.org" }, pass,
  34. "to set writable property iwin.location");
  35. SimpleTest.finish();
  36. }
  37. </script>
  38. </head>
  39. <body>
  40. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478438">Mozilla Bug 478438</a>
  41. <p id="display"></p>
  42. <div id="content">
  43. <iframe id="f" src="http://example.com" onload="test()"></iframe>
  44. </div>
  45. <pre id="test">
  46. <script type="application/javascript">
  47. /** Test for Bug 478438 **/
  48. SimpleTest.waitForExplicitFinish();
  49. </script>
  50. </pre>
  51. </body>
  52. </html>