Bug 623059 - TEST-UNEXPECTED-FAIL | chrome://mochitests/content/browser/mobile/chrome/browser_preferences_basic.js | Test timed out [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 05 Jan 2011 12:48:03 +0100
changeset 2595 3cd4fa6e52f2936152b04d81085120cd97ebd7ae
parent 2594 d54b2ffcad270d707f9b875a47373a0dc32cdbcc
child 2596 56701d9f69bd31370e809cd70b0c4be6d17ebd12
push id2176
push uservnicolas@mozilla.com
push dateWed, 05 Jan 2011 11:59:43 +0000
reviewersmfinkle
bugs623059
Bug 623059 - TEST-UNEXPECTED-FAIL | chrome://mochitests/content/browser/mobile/chrome/browser_preferences_basic.js | Test timed out [r=mfinkle]
chrome/tests/browser_preferences_basic.js
chrome/tests/browser_vkb.js
chrome/tests/remote_vkb.js
--- a/chrome/tests/browser_preferences_basic.js
+++ b/chrome/tests/browser_preferences_basic.js
@@ -69,40 +69,40 @@ gTests.push({
     // Assign offsets while panning
     initialDragOffset = document.getElementById("tabs-container").getBoundingClientRect().width;
     finalDragOffset = initialDragOffset + document.getElementById("browser-controls").getBoundingClientRect().width;
 
     gCurrentTest._contentScrollbox.getPosition(x, y);
     ok((x.value == initialDragOffset && y.value == 0), "The right sidebar must be invisible",
       "Got " + x.value + " " + y.value + ", expected " + initialDragOffset + ",0");
 
-    /* XXX For some reasons reavealing the sidebars this way let the test hang, we need to find why and fix that
     // Reveal right sidebar
     let w = controls.clientWidth;
     let h = controls.clientHeight;
     dragElement(controls, w / 2, h / 2, w / 4, h / 2);
-    */
 
     // check whether the right sidebar has appeared
     gCurrentTest._contentScrollbox.getPosition(x,y);
-    todo((x.value == finalDragOffset && y.value == 0), "The right sidebar must be visible",
+    ok(x.value == finalDragOffset && y.value == 0, "The right sidebar must be visible",
       "Got " + x.value + " " + y.value + ", expected " + finalDragOffset + ",0");
 
     // check to see if the preference open button is visible and not depressed
     var prefsOpen = document.getElementById("tool-panel-open");
     is(prefsOpen.hidden, false, "Preferences open button must be visible");
     is(prefsOpen.checked, false, "Preferences open button must not be depressed");
 
     // check if preferences pane is invisble
     is(BrowserUI.isPanelVisible(), false, "Preferences panel is invisble");
 
     // click on the prefs button to go the preferences pane
     var prefsClick = document.getElementById("tool-panel-open");
     prefsClick.click();
-    waitFor(gCurrentTest.onPrefsView, BrowserUI.isPanelVisible);
+    waitFor(function() {
+      setTimeout(gCurrentTest.onPrefsView, 0);
+    }, BrowserUI.isPanelVisible);
   },
 
   onPrefsView: function() {
     let prefsList = document.getElementById("prefs-list");
     let prefsListRect = prefsList.getBoundingClientRect();
     let w = prefsListRect.width;
     let h = prefsListRect.height;
 
@@ -151,19 +151,19 @@ gTests.push({
     EventUtils.synthesizeMouse(prefsList, x1, y1, { type: "mousedown" });
     EventUtils.synthesizeMouse(prefsList, x2, y2, { type: "mousemove" });
 
     // Check whether it is moved up to the correct view
     let distance = y1 - y2;
     gCurrentTest._prefsScrollbox.getPosition(x, y);
     ok((x.value == 0 && y.value == distance), "Preferences pane is panned up", "Got " + x.value + " " + y.value + ", expected 0," + distance);
 
-    // Need to wait for a paint event before another 
-    addEventListener("MozBeforePaint", function(aEvent) {
-      removeEventListener("MozBeforePaint", arguments.callee, false);
+    // Need to wait for a paint event before another
+    window.addEventListener("MozAfterPaint", function(aEvent) {
+      window.removeEventListener("MozAfterPaint", arguments.callee, false);
 
       // Move preferences pane down
       EventUtils.synthesizeMouse(prefsList, x1, y1, { type: "mousemove" });
       EventUtils.synthesizeMouse(prefsList, x1, y1, { type: "mouseup" });
 
       // Check whether it goes back to old position
       gCurrentTest._prefsScrollbox.getPosition(x, y);
       ok((x.value == 0 && y.value == 0), "Preferences pane is panned down", "Got " + x.value + " " + y.value + ", expected 0,0");
@@ -176,21 +176,21 @@ gTests.push({
     // Close the preferences pane
     BrowserUI.hidePanel();
 
     // check whether the preferences pane has disappeared
     is(document.getElementById("panel-container").hidden, true, "Preference pane is now invisible");
 
     //check if the right sidebar is still visible
     gCurrentTest._contentScrollbox.getPosition(x, y);
-    todo((x.value == finalDragOffset && y.value == 0), "The right sidebar is still visible",
+    ok(x.value == finalDragOffset && y.value == 0, "The right sidebar is still visible",
        "Got " + x.value + " " + y.value + ", expected " + finalDragOffset + ",0");
 
     // check whether the preferences open button is not depressed
-    var prefsOpen = document.getElementById("tool-panel-open");
+    let prefsOpen = document.getElementById("tool-panel-open");
     is(prefsOpen.checked, false, "Preferences open button must not be depressed");
 
     // Reset the UI before the next test starts.
     Browser.hideSidebars();
     Browser.closeTab(gCurrentTest._currentTab);
     runNextTest();
   }
 });
--- a/chrome/tests/browser_vkb.js
+++ b/chrome/tests/browser_vkb.js
@@ -1,9 +1,9 @@
-/* 
+/*
  * Check VKB show/hide behavior
  */
 let testURL_01 = chromeRoot + "browser_forms.html";
 messageManager.loadFrameScript(chromeRoot + "remote_vkb.js", true);
 
 /* ============================= Tests Utils =============================== */
 let gTests = [];
 let gCurrentTest = null;
@@ -50,49 +50,53 @@ let VKBObserver = {
 Services.obs.addObserver(VKBObserver, "ime-enabled-state-changed", false);
 
 function waitForVKBChange(aCallback, aState) {
   waitForAndContinue(aCallback, function() {
     if (VKBStateHasChanged) {
       VKBStateHasChanged = false;
       return true;
     }
-      
+
     return VKBStateHasChanged;
   });
 }
 
-
 let newTab = null;
 
-let isLoading = function() {
-  return !newTab.isLoading() && newTab.browser.currentURI.spec != "about:blank";
+function waitForPageShow(aPageURL, aCallback) {
+  messageManager.addMessageListener("pageshow", function(aMessage) {
+    if (aMessage.target.currentURI.spec == aPageURL) {
+      messageManager.removeMessageListener("pageshow", arguments.callee);
+      setTimeout(function() { aCallback(); }, 0);
+    }
+  });
 };
 
 function dragElement(element, x1, y1, x2, y2) {
   EventUtils.synthesizeMouse(element, x1, y1, { type: "mousedown" });
   EventUtils.synthesizeMouse(element, x2, y2, { type: "mousemove" });
   EventUtils.synthesizeMouse(element, x2, y2, { type: "mouseup" });
 }
 
 //------------------------------------------------------------------------------
 // Case: Test interactions with a VKB from content
 gTests.push({
   desc: "Test interactions with a VKB from content",
+  run: function() {
+    waitForPageShow(testURL_01, gCurrentTest.focusContentInputField);
 
-  run: function() {
     newTab = Browser.addTab(testURL_01, true);
-    ok(newTab, "Tab Opened");	
-    waitFor(gCurrentTest.focusContentInputField, isLoading);
+    ok(newTab, "Tab Opened");
   },
 
   focusContentInputField: function() {
     is(VKBObserver._enabled, false, "Initially the VKB should be closed");
 
-    AsyncTests.waitFor("Test:Focus", {}, function(json) {
+    AsyncTests.waitFor("Test:FocusRoot", {}, function(json) {
       waitForVKBChange(gCurrentTest.showLeftSidebar);
     })
   },
 
   showLeftSidebar: function() {
     is(VKBObserver._enabled, true, "When focusing an input field the VKB should be opened");
 
     let browsers = document.getElementById("browsers");
@@ -118,17 +122,17 @@ gTests.push({
 
   prepareOpenRightPanel: function() {
     is(VKBObserver._enabled, false, "Switching tab should close the VKB");
 
     BrowserUI.selectTab(newTab);
 
     // Give back the focus to the content input and launch and check
     // interaction with the right panel
-    AsyncTests.waitFor("Test:Focus", {}, function(json) {
+    AsyncTests.waitFor("Test:FocusRoot", {}, function(json) {
       waitForVKBChange(gCurrentTest.openRightPanel);
     });
   },
 
   openRightPanel: function() {
     is(VKBObserver._enabled, true, "Re-cliking on an input field should re-open the VKB");
 
     let toolsButton = document.getElementById("tool-panel-open");
--- a/chrome/tests/remote_vkb.js
+++ b/chrome/tests/remote_vkb.js
@@ -1,6 +1,6 @@
 dump("====================== Content Script Loaded =======================\n");
 
-AsyncTests.add("Test:Focus", function(aMessage, aJson) {
+AsyncTests.add("Test:FocusRoot", function(aMessage, aJson) {
   content.document.getElementById("root").focus();
   return true;
 });