Bug 632345 - [regression] Scrollbar position should not updated before showing the scrollbars [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2011-02-08 23:38:20 +01:00
parent 63ce29e354
commit ca9ab315ef
4 changed files with 167 additions and 0 deletions

View File

@ -1288,6 +1288,7 @@ Browser.MainDragger.prototype = {
},
_showScrollbars: function _showScrollbars() {
this._updateScrollbars();
let scaleX = this._scrollScales.x, scaleY = this._scrollScales.y;
if (scaleX) {
this._horizontalScrollbar.width = ViewableAreaObserver.width * scaleX;

View File

@ -72,6 +72,7 @@ _BROWSER_FILES = \
browser_preferences_text.js \
browser_rect.js \
browser_rememberPassword.js \
browser_scrollbar.js \
browser_select.html \
browser_select.js \
browser_sessionstore.js \
@ -82,6 +83,7 @@ _BROWSER_FILES = \
browser_vkb.js \
browser_viewport.js \
browser_viewport.sjs \
browser_scrollbar.sjs \
browser_title.sjs \
browser_install.xml \
browser_upgrade.rdf\

View File

@ -0,0 +1,98 @@
let baseURI = "http://mochi.test:8888/browser/mobile/chrome/";
let testURL_01 = baseURI + "browser_scrollbar.sjs?";
let gCurrentTest = null;
let gTests = [];
//------------------------------------------------------------------------------
// Iterating tests by shifting test out one by one as runNextTest is called.
function runNextTest() {
// Run the next test until all tests completed
if (gTests.length > 0) {
gCurrentTest = gTests.shift();
info(gCurrentTest.desc);
gCurrentTest.run();
}
else {
// Close the awesome panel just in case
BrowserUI.activePanel = null;
finish();
}
}
function waitForPageShow(aPageURL, aCallback) {
messageManager.addMessageListener("pageshow", function(aMessage) {
if (aMessage.target.currentURI.spec == aPageURL) {
messageManager.removeMessageListener("pageshow", arguments.callee);
setTimeout(function() { aCallback(); }, 0);
}
});
};
//------------------------------------------------------------------------------
// Entry point (must be named "test")
function test() {
// This test is async
waitForExplicitFinish();
runNextTest();
}
let horizontalScrollbar = document.getElementById("horizontal-scroller");
let verticalScrollbar = document.getElementById("vertical-scroller");
function checkScrollbars(aHorizontalVisible, aVerticalVisible, aHorizontalPosition, aVerticalPosition) {
let browser = getBrowser();
let width = browser.getBoundingClientRect().width;
let height = browser.getBoundingClientRect().height;
EventUtils.synthesizeMouse(browser, width / 2, height / 4, { type: "mousedown" });
EventUtils.synthesizeMouse(browser, width / 2, height * 3 / 4, { type: "mousemove" });
let horizontalVisible = horizontalScrollbar.hasAttribute("panning"),
verticalVisible = verticalScrollbar.hasAttribute("panning");
is(horizontalVisible, aHorizontalVisible, "The horizontal scrollbar should be " + (aHorizontalVisible ? "visible" : "hidden"));
is(verticalVisible, aVerticalVisible, "The vertical scrollbar should be " + (aVerticalVisible ? "visible" : "hidden"));
EventUtils.synthesizeMouse(browser, width / 2, height * 3 / 4, { type: "mouseup" });
}
gTests.push({
desc: "Testing visibility of scrollbars",
run: function() {
waitForPageShow(testURL_01 + "blank", gCurrentTest.checkNotScrollable);
Browser.addTab(testURL_01 + "blank", true);
},
checkNotScrollable: function() {
checkScrollbars(false, false);
waitForPageShow(testURL_01 + "horizontal", gCurrentTest.checkHorizontalScrollable);
Browser.addTab(testURL_01 + "horizontal", true);
},
checkHorizontalScrollable: function() {
checkScrollbars(true, false);
waitForPageShow(testURL_01 + "vertical", gCurrentTest.checkVerticalScrollable);
Browser.addTab(testURL_01 + "vertical", true);
},
checkVerticalScrollable: function() {
checkScrollbars(false, true);
waitForPageShow(testURL_01 + "both", gCurrentTest.checkBothScrollable);
Browser.addTab(testURL_01 + "both", true);
},
checkBothScrollable: function() {
checkScrollbars(true, true);
Elements.browsers.addEventListener("PanFinished", function(aEvent) {
setTimeout(function() {
while (Browser.tabs.length > 1)
BrowserUI.closeTab();
}, 0);
}, false);
runNextTest();
}
});

View File

@ -0,0 +1,66 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Mobile Browser.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
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'>");
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>");
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>");
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>");
break;
default:
break;
}
response.write("</head><body>" + query + "</body></html>");
}