Bug 646270 - MozScrolledAreaChanged changed behavior and broke some browser-chrome tests [r=mbrubeck]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 30 Mar 2011 13:19:00 -0400
changeset 67552 c7024c1bc6e858050092ca236dc1e798ea040bb0
parent 67551 a2777c21e32d73115e3a44d4d188c15d5dc68269
child 67553 c4383fe2dbdf2c320a3a52e96c579c36528554af
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs646270
Bug 646270 - MozScrolledAreaChanged changed behavior and broke some browser-chrome tests [r=mbrubeck]
mobile/chrome/tests/browser_scrollbar.js
mobile/chrome/tests/browser_scrollbar.sjs
mobile/chrome/tests/browser_viewport.js
--- a/mobile/chrome/tests/browser_scrollbar.js
+++ b/mobile/chrome/tests/browser_scrollbar.js
@@ -20,20 +20,18 @@ function runNextTest() {
     finish();
   }
 }
 
 function waitForPageShow(aPageURL, aCallback) {
   messageManager.addMessageListener("pageshow", function(aMessage) {
     if (aMessage.target.currentURI.spec == aPageURL) {
       messageManager.removeMessageListener("pageshow", arguments.callee);
-      messageManager.addMessageListener("MozScrolledAreaChanged", function(aMessage) {
-        messageManager.removeMessageListener("MozScrolledAreaChanged", arguments.callee);
-        aCallback();
-      });
+
+      setTimeout(aCallback, 0);
     }
   });
 };
 
 //------------------------------------------------------------------------------
 // Entry point (must be named "test")
 function test() {
   // This test is async
@@ -70,17 +68,21 @@ gTests.push({
   checkNotScrollable: function() {
     checkScrollbars(false, false);
 
     waitForPageShow(testURL_01 + "horizontal", gCurrentTest.checkHorizontalScrollable);
     gOpenedTabs.push(Browser.addTab(testURL_01 + "horizontal", true));
   },
 
   checkHorizontalScrollable: function() {
-    checkScrollbars(true, false);
+    checkScrollbars(true, true);
+    // TODO: current code forces the height to grow so we always have visible document when
+    // zooming out to see the wide document
+    //checkScrollbars(true, false);
+    todo(false, "Don't cause the height to grow beyond the window height if it doesn't need to");
 
     waitForPageShow(testURL_01 + "vertical", gCurrentTest.checkVerticalScrollable);
     gOpenedTabs.push(Browser.addTab(testURL_01 + "vertical", true));
   },
 
   checkVerticalScrollable: function() {
     checkScrollbars(false, true);
 
--- a/mobile/chrome/tests/browser_scrollbar.sjs
+++ b/mobile/chrome/tests/browser_scrollbar.sjs
@@ -36,31 +36,32 @@
 
 function handleRequest(request, response) {
   response.setStatusLine(request.httpVersion, 200, "OK");
   response.setHeader("Content-Type", "text/html", false);
 
   let action = "";
   let query = decodeURIComponent(request.queryString || "");
   response.write("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");
-  response.write("<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>");
+  response.write("<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'>");
 
+  let body = "<span>" + query + "</span>";
   switch (query) {
     case "blank":
       response.write("<title>This is a not a scrollable page</title>");
       break;
     case "horizontal":
       response.write("<title>This is a horizontally scrollable page</title>");
-      response.write("<div style='height: 200px; width: 2000px; border: 1px solid red; background-color: grey; color: black'>Browser scrollbar test</div>");
+      body += "\n<div style='height: 200px; width: 2000px; border: 1px solid red; background-color: grey; color: black'>Browser scrollbar test</div>";
       break;
     case "vertical":
       response.write("<title>This is a vertically scrollable page</title>");
-      response.write("<div style='height: 2000px; width: 200px; border: 1px solid red; background-color: grey; color: black'>Browser scrollbar test</div>");
+      body += "\n<div style='height: 2000px; width: 200px; border: 1px solid red; background-color: grey; color: black'>Browser scrollbar test</div>";
       break;
     case "both":
       response.write("<title>This is a scrollable page in both directions</title>");
-      response.write("<div style='height: 2000px; width: 2000px; border: 1px solid red; background-color: grey; color: black'>Browser scrollbar test</div>");
+      body += "\n<div style='height: 2000px; width: 2000px; border: 1px solid red; background-color: grey; color: black'>Browser scrollbar test</div>";
       break;
     default:
       break;
   }
-  response.write("</head><body>" + query + "</body></html>");
+  response.write("</head><body style='border:2px solid blue'>" + body + "</body></html>");
 }
--- a/mobile/chrome/tests/browser_viewport.js
+++ b/mobile/chrome/tests/browser_viewport.js
@@ -54,23 +54,20 @@ function scaleRatio(n) {
   if ("scaleRatio" in gTestData[n])
     return gTestData[n].scaleRatio;
   return 150; // Default value matches our main target hardware (N900, Nexus One, etc.)
 }
 
 let currentTab;
 
 let loadURL = function loadURL(aPageURL, aCallback, aScale) {
-  messageManager.addMessageListener("MozScrolledAreaChanged", function(aMessage) {
+  messageManager.addMessageListener("pageshow", function(aMessage) {
     if (aMessage.target.currentURI.spec == aPageURL) {
       messageManager.removeMessageListener(aMessage.name, arguments.callee);
 
-      // HACK: Sometimes there are two MozScrolledAreaChanged messages in a
-      // row, and this waitFor is the only way founded to make sure the
-      // browser responds to both of them before we do.
       waitFor(aCallback, function() {
         return !aScale || aScale == aMessage.target.scale;
       });
     }
   });
 
   BrowserUI.goToURI(aPageURL);
 };