test_bug503926.xul 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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=503926
  6. -->
  7. <window title="Mozilla Bug 503926"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript"
  10. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  11. <!-- test results are displayed in the html:body -->
  12. <body xmlns="http://www.w3.org/1999/xhtml">
  13. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=503926"
  14. target="_blank">Mozilla Bug 503926</a>
  15. <iframe id="ifr" type="content" onload="loaded()" src="bug503926.xul#iframe"/>
  16. <iframe id="ifrContent" type="content" onload="loaded()" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"/>
  17. </body>
  18. <!-- test code goes here -->
  19. <script type="application/javascript">
  20. <![CDATA[
  21. SimpleTest.expectAssertions(0, 1);
  22. var gLoadCount = 0;
  23. function loaded() {
  24. if (++gLoadCount == 2)
  25. go();
  26. }
  27. /** Test for Bug 503926 **/
  28. function go() {
  29. var gWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
  30. getInterface(Components.interfaces.nsIDOMWindowUtils);
  31. // Try with a chrome object.
  32. var passed = false;
  33. var obj = { QueryInterface: function() { passed = true; } };
  34. gWindowUtils.xpconnectArgument(obj);
  35. ok(passed, "trusted QIs should be called");
  36. // Try with a content object.
  37. var contentWin = $('ifrContent').contentWindow.wrappedJSObject;
  38. contentWin.passed = false;
  39. var contentObj = contentWin.eval('({ QueryInterface: function() { passed = true; } })');
  40. gWindowUtils.xpconnectArgument(contentObj);
  41. ok(!contentWin.passed, "untrusted QI should not be called");
  42. // Try with a dialog.
  43. openDialog("bug503926.xul", "chromeDialog", "modal");
  44. SimpleTest.finish();
  45. }
  46. SimpleTest.waitForExplicitFinish();
  47. ]]>
  48. </script>
  49. </window>