test_bug533596.xul 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  3. <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
  4. type="text/css"?>
  5. <!--
  6. https://bugzilla.mozilla.org/show_bug.cgi?id=533596
  7. -->
  8. <window title="Mozilla Bug 533596"
  9. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  10. <script type="application/javascript"
  11. src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  12. <!-- test results are displayed in the html:body -->
  13. <body xmlns="http://www.w3.org/1999/xhtml">
  14. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=533596"
  15. target="_blank">Mozilla Bug 533596</a>
  16. </body>
  17. <!-- test code goes here -->
  18. <script type="application/javascript"><![CDATA[
  19. /** Test for Bug 533596 **/
  20. function go() {
  21. try { XPCNativeWrapper.unwrap(); } catch (e) {}
  22. try { XPCNativeWrapper.unwrap(0); } catch (e) {}
  23. try { XPCNativeWrapper.unwrap(null); } catch (e) {}
  24. var o = {};
  25. is(o, XPCNativeWrapper.unwrap(o), "unwrap on a random object returns it");
  26. var win = $('ifr').contentWindow;
  27. var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
  28. .getInterface(Components.interfaces.nsIDOMWindowUtils);
  29. is(utils.getClassName(win), "Proxy", "win is a Proxy");
  30. ok("x" in XPCNativeWrapper.unwrap(win), "actually unwrapped");
  31. is(utils.getClassName(XPCNativeWrapper.unwrap(win)), "Proxy",
  32. "unwrap on an Proxy returns the same object");
  33. is(utils.getClassName(XPCNativeWrapper.unwrap(new XPCNativeWrapper(win))), "Proxy",
  34. "unwrap on an explicit NW works too");
  35. ok(utils.getClassName(window) !== "XPCNativeWrapper", "window is not a native wrapper");
  36. ok(utils.getClassName(XPCNativeWrapper.unwrap(new XPCNativeWrapper(window))) !== "XPCSafeJSObjectWrapper",
  37. "unwrapping a chrome object returns the object itself");
  38. SimpleTest.finish();
  39. }
  40. SimpleTest.waitForExplicitFinish();
  41. ]]></script>
  42. <iframe type="content"
  43. src="http://example.org/tests/js/xpconnect/tests/mochitest/bug500931_helper.html"
  44. onload="go()"
  45. id="ifr">
  46. </iframe>
  47. </window>