mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 654122 - window.scrollTo on pageload does not always hide Fennec urlbar [r=stechz]
This commit is contained in:
parent
a68b012a57
commit
f19fd0912b
@ -1174,12 +1174,10 @@ var Browser = {
|
||||
|
||||
case "scroll":
|
||||
if (browser == this.selectedBrowser) {
|
||||
let view = browser.getRootView();
|
||||
let position = view.getPosition();
|
||||
if (position.x != 0)
|
||||
if (json.x != 0)
|
||||
this.hideSidebars();
|
||||
|
||||
if (position.y != 0)
|
||||
if (json.y != 0)
|
||||
this.hideTitlebar();
|
||||
}
|
||||
break;
|
||||
@ -1532,7 +1530,8 @@ Browser.WebProgress.prototype = {
|
||||
let json = aMessage.json;
|
||||
browser.getRootView().scrollTo(Math.floor(json.x * browser.scale),
|
||||
Math.floor(json.y * browser.scale));
|
||||
Browser.pageScrollboxScroller.scrollTo(0, 0);
|
||||
if (json.x == 0 && json.y == 0)
|
||||
Browser.pageScrollboxScroller.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
aTab.scrolledAreaChanged();
|
||||
|
16
mobile/chrome/tests/browser_scroll.html
Normal file
16
mobile/chrome/tests/browser_scroll.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>scrollTo test</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<script>
|
||||
function run() {
|
||||
window.scrollTo(0,1);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()" style="height:2000px">
|
||||
<h1>scrollTo test</h1>
|
||||
<p>The urlbar should scroll out of view after this page loads.</p>
|
||||
</body>
|
||||
</html>
|
19
mobile/chrome/tests/browser_scroll.js
Normal file
19
mobile/chrome/tests/browser_scroll.js
Normal file
@ -0,0 +1,19 @@
|
||||
// Test behavior of window.scrollTo during page load (bug 654122).
|
||||
"use strict";
|
||||
|
||||
var gTab;
|
||||
registerCleanupFunction(function() Browser.closeTab(gTab));
|
||||
|
||||
const BASE_URL = "http://mochi.test:8888/browser/mobile/chrome/";
|
||||
const TEST_URL = BASE_URL + "browser_scroll.html";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
gTab = Browser.addTab(TEST_URL, true);
|
||||
onMessageOnce(gTab.browser.messageManager, "Browser:FirstPaint", function() {
|
||||
executeSoon(function() {
|
||||
let rect = Elements.browsers.getBoundingClientRect();
|
||||
is(rect.top, 0, "Titlebar is hidden.");
|
||||
});
|
||||
});
|
||||
}
|
@ -34,6 +34,14 @@ function waitForAndContinue(callback, test, timeout) {
|
||||
setTimeout(waitForAndContinue, 50, callback, test, timeout);
|
||||
};
|
||||
|
||||
// Listen for the specified message once, then remove the listener.
|
||||
function onMessageOnce(aMessageManager, aName, aCallback) {
|
||||
aMessageManager.addMessageListener(aName, function onMessage(aMessage) {
|
||||
aMessageManager.removeMessageListener(aName, onMessage);
|
||||
aCallback(aMessage);
|
||||
});
|
||||
}
|
||||
|
||||
function makeURI(spec) {
|
||||
return Services.io.newURI(spec, null, null);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user