test_bug799348.xul 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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=799348
  6. -->
  7. <window title="Mozilla Bug 799348"
  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=799348"
  13. target="_blank">Mozilla Bug 799348</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for Bug 799348 **/
  19. SimpleTest.waitForExplicitFinish();
  20. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  21. Components.utils.import("resource://gre/modules/Services.jsm");
  22. gCalledOnload = false;
  23. var myObserver = {
  24. QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
  25. observe: function(win, topic, data) {
  26. if (topic == "domwindowopened") {
  27. ok(!gCalledOnload, "domwindowopened notification fired before onload");
  28. win.addEventListener("load", function(evt) {
  29. gCalledOnload = true;
  30. win.close();
  31. }, false);
  32. } else if (topic == "domwindowclosed") {
  33. ok(gCalledOnload, "should have called onload");
  34. Services.ww.unregisterNotification(myObserver);
  35. SimpleTest.finish();
  36. }
  37. else {
  38. ok(false, "unknown topic");
  39. }
  40. }
  41. };
  42. Services.ww.registerNotification(myObserver);
  43. ]]>
  44. </script>
  45. <iframe id="frame" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_bug799348.html" />
  46. </window>