Bug 527099, use waitForFocus to wait for the frameset window
authorNeil Deakin <neil@mozilla.com>
Mon, 17 May 2010 09:21:11 -0400
changeset 42373 067e44b89712ba4040416331ac9659132925732c
parent 42372 ac8653880111e33ba4775cf462dda75a5e6e612e
child 42374 6636a42ce2a458cf40e69f0d8871f1585837f808
push id13302
push userneil@mozilla.com
push dateMon, 17 May 2010 13:21:47 +0000
treeherdermozilla-central@067e44b89712 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs527099
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 527099, use waitForFocus to wait for the frameset window
dom/tests/mochitest/chrome/focus_frameset.html
testing/mochitest/tests/SimpleTest/SimpleTest.js
--- a/dom/tests/mochitest/chrome/focus_frameset.html
+++ b/dom/tests/mochitest/chrome/focus_frameset.html
@@ -1,21 +1,19 @@
 <html id="outer">
 
 <script type="application/javascript"
         src="chrome://mochikit/content/MochiKit/packed.js"></script>
 <script type="application/javascript"
         src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 <script>
-dump("frameset script parsed\n");
-SimpleTest.waitForFocus(function () dump("focus on frameset occured\n"));
+SimpleTest.waitForFocus(function () opener.framesetWindowLoaded(window));
 </script>
 
-<frameset rows="30%, 70%" onload="dump('frameset load ' + event.target.location + ' ' + window.location + '\n'); window.loaded = true; if (window.loaded === window.focused) opener.framesetWindowLoaded(window)"
-                          onfocus="dump('frameset focus: ' + event.target.location + ' ' + window.location + '\n'); window.focused = true; if (window.loaded === window.focused) opener.framesetWindowLoaded(window)">
+<frameset rows="30%, 70%">
   <frame src="data:text/html,&lt;html id='f1' &gt;&lt;body id='framebody1'&gt;&lt;input id='f2'&gt;&lt;body&gt;&lt;/html&gt;">
   <frameset cols="30%, 33%, 34%">
     <frame src="data:text/html,&lt;html id='f3'&gt;&lt;body id='framebody2'&gt;&lt;input id='f4'&gt;&lt;body&gt;&lt;/html&gt;">
     <frame src="data:text/html,&lt;html id='f5'&gt;&lt;body id='framebody3'&gt;&lt;input id='f6' tabindex='2'&gt;&lt;body&gt;&lt;/html&gt;">
     <frame src="data:text/html,&lt;html id='f7'&gt;&lt;body id='framebody4'&gt;&lt;input id='f8'&gt;&lt;body&gt;&lt;/html&gt;">
   </frameset>
   <noframes>
     <input id="unusued1"/>
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -264,24 +264,16 @@ SimpleTest.waitForFocus = function (call
                                      .QueryInterface(Components.interfaces.nsIBaseWindow);
         SimpleTest.ok(true, prefix + " -- loaded: " + targetWindow.document.readyState +
            " active window: " +
                (fm.activeWindow ? "(" + fm.activeWindow + ") " + fm.activeWindow.location : "<no window active>") +
            " focused window: " +
                (fm.focusedWindow ? "(" + fm.focusedWindow + ") " + fm.focusedWindow.location : "<no window focused>") +
            " desired window: (" + targetWindow + ") " + targetWindow.location +
            " docshell visible: " + baseWindow.visibility);
-        dump(prefix + " -- loaded: " + targetWindow.document.readyState +
-           " active window: " +
-               (fm.activeWindow ? "(" + fm.activeWindow + ") " + fm.activeWindow.location : "<no window active>") +
-           " focused window: " +
-               (fm.focusedWindow ? "(" + fm.focusedWindow + ") " + fm.focusedWindow.location : "<no window focused>") +
-           " desired window: (" + targetWindow + ") " + targetWindow.location +
-           " docshell visible: " + baseWindow.visibility);
-
     }
 
     debugFocusLog("before wait for focus");
 
     function maybeRunTests() {
         debugFocusLog("maybe run tests <load:" +
                       SimpleTest.waitForFocus_loaded + ", focus:" + SimpleTest.waitForFocus_focused + ">");
         if (SimpleTest.waitForFocus_loaded &&
@@ -291,41 +283,41 @@ SimpleTest.waitForFocus = function (call
             setTimeout(callback, 0, targetWindow);
         }
     }
 
     function waitForEvent(event) {
         SimpleTest["waitForFocus_" + event.type + "ed"] = true;
         targetWindow.removeEventListener(event.type, waitForEvent, false);
         if (event.type == "MozAfterPaint")
-          dump("MozAfterPaint event received");
+          SimpleTest.ok(true, "MozAfterPaint event received");
         maybeRunTests();
     }
 
     // wait for the page to load if it hasn't already
     SimpleTest.waitForFocus_loaded = (targetWindow.document.readyState == "complete");
     if (!SimpleTest.waitForFocus_loaded) {
-        dump("must wait for load");
+        SimpleTest.ok(true, "must wait for load");
         targetWindow.addEventListener("load", waitForEvent, false);
     }
 
     // check if the window is focused, and focus it if it is not
     var focusedWindow = { };
     if (fm.activeWindow)
       fm.getFocusedElementForWindow(fm.activeWindow, true, focusedWindow);
 
     // if this is a child frame, ensure that the frame is focused
     SimpleTest.waitForFocus_focused = (focusedWindow.value == targetWindow);
     if (SimpleTest.waitForFocus_focused) {
-        dump("already focused");
+        SimpleTest.ok(true, "already focused");
         // if the frame is already focused and loaded, call the callback directly
         maybeRunTests();
     }
     else {
-        dump("must wait for focus");
+        SimpleTest.ok(true, "must wait for focus");
         targetWindow.addEventListener("focus", waitForEvent, false);
         targetWindow.focus();
     }
 
     targetWindow.addEventListener("MozAfterPaint", waitForEvent, false);
 };
 
 /**