test_bug932906.xul 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
  3. <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
  4. <!--
  5. https://bugzilla.mozilla.org/show_bug.cgi?id=932906
  6. -->
  7. <window title="Mozilla Bug 932906"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  10. <!-- test results are displayed in the html:body -->
  11. <body xmlns="http://www.w3.org/1999/xhtml">
  12. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=932906"
  13. target="_blank">Mozilla Bug 932906</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. const Cu = Components.utils;
  19. Cu.import('resource://gre/modules/Services.jsm');
  20. /** Test for Bug 932906 **/
  21. SimpleTest.waitForExplicitFinish();
  22. function passToContent(shouldThrow) {
  23. try {
  24. $('ifr').contentWindow.obs = Services.obs;
  25. ok(!shouldThrow, "Didn't throw when passing non-DOM XPCWN to content");
  26. } catch (e) {
  27. ok(shouldThrow, "Threw when passing non-DOM XPCWN to content");
  28. ok(/denied/.test(e), "Threw correct exception: " + e);
  29. }
  30. }
  31. var gLoadCount = 0;
  32. function loaded() {
  33. ++gLoadCount;
  34. if (gLoadCount == 1)
  35. part1();
  36. else if (gLoadCount == 2)
  37. part2();
  38. else
  39. ok(false, "Didn't expect three loads");
  40. }
  41. function part1() {
  42. // Make sure that the pref is what we expect for mochitests.
  43. is(Services.prefs.getBoolPref('dom.use_xbl_scopes_for_remote_xul'), true,
  44. "Test harness set up like we expect");
  45. // First, test that we can't normally pass non-DOM XPCWNs to content.
  46. passToContent(/* shouldThrow = */ true);
  47. // Now, make sure we _can_ for the remote xul case. We use SpecialPowers
  48. // for the pref munging because it cleans up after us.
  49. SpecialPowers.pushPrefEnv({set: [['dom.use_xbl_scopes_for_remote_xul', false]]}, function() {
  50. $('ifr').contentWindow.location.reload();
  51. });
  52. }
  53. function part2() {
  54. passToContent(/* shouldThrow = */ false);
  55. SimpleTest.finish();
  56. }
  57. ]]>
  58. </script>
  59. <iframe id="ifr" onload="loaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  60. </window>