test_bug858101.xul 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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=858101
  6. -->
  7. <window title="Mozilla Bug 858101"
  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=858101"
  13. target="_blank">Mozilla Bug 858101</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for [[DefaultValue]] on XrayWrappers. **/
  19. SimpleTest.waitForExplicitFinish();
  20. function muckWithToString() {
  21. function tricky() { return "hah"; };
  22. window.toString = document.toString = document.body.toString = tricky;
  23. window.valueOf = document.valueOf = document.body.valueOf = tricky;
  24. Window.prototype.toString = Window.prototype.valueOf = tricky;
  25. Document.prototype.toString = Document.prototype.valueOf = tricky;
  26. HTMLBodyElement.toString = HTMLBodyElement.valueOf = tricky;
  27. }
  28. function go() {
  29. var iwin = $('ifr').contentWindow;
  30. iwin.wrappedJSObject.eval('(' + muckWithToString.toSource() + ')()');
  31. // Check behavior with vanilla CCWs.
  32. ok(!!/hah/.exec(iwin.wrappedJSObject + ""), "Waivers should get content-defined window stringification");
  33. ok(!!/hah/.exec(iwin.document.wrappedJSObject + ""), "Waivers should get content-defined document stringification");
  34. ok(!!/hah/.exec(iwin.document.body.wrappedJSObject + ""), "Waivers should get content-defined body stringification");
  35. // Check Xray behavior.
  36. ok(!/hah/.exec(iwin + ""), "Xrays should not get content-defined window stringification");
  37. ok(!/hah/.exec(iwin.document + ""), "Xrays should not get content-defined document stringification");
  38. ok(!/hah/.exec(iwin.document.body + ""), "Xrays should not get content-defined body stringification");
  39. SimpleTest.finish();
  40. }
  41. ]]>
  42. </script>
  43. <iframe id="ifr" onload="go();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
  44. </window>