Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1480349 - RTL hosts don't stay visible when the browser window is…
Browse files Browse the repository at this point in the history
… resized. r=adw

On window resize we should format the urlbar again, to ensure the host stays visible.
Also fixes bug 1192501, that requires the same resize handler.

Differential Revision: https://phabricator.services.mozilla.com/D2711
  • Loading branch information
mak77 committed Aug 7, 2018
1 parent 826790a commit efadf39
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
17 changes: 10 additions & 7 deletions browser/base/content/test/urlbar/browser_urlbarAddonIframe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable mozilla/no-arbitrary-setTimeout */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// The purpose of this test is to test the urlbar popup's add-on iframe. It has
Expand Down Expand Up @@ -133,13 +135,14 @@ add_task(async function() {
// urlbar.setPanelHeight
let newHeight = height + 100;
await promiseUrlbarFunctionCall("setPanelHeight", newHeight);
await new Promise(resolve => {
// The height change is animated, so give it time to complete. Again, wait
// a sec to be safe.
setTimeout(resolve, 1000);
// The height change is animated, so give it time to complete.
await TestUtils.waitForCondition(
() => Math.round(iframe.getBoundingClientRect().height) == newHeight,
"Wait for panel height change after setPanelHeight"
).catch(ex => {
info("Last detected height: " + Math.round(iframe.getBoundingClientRect().height));
throw ex;
});
Assert.equal(iframe.getBoundingClientRect().height, newHeight,
"setPanelHeight");
});

function promiseIframeLoad() {
Expand Down
21 changes: 21 additions & 0 deletions browser/base/content/urlbarBindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this.inputField.addEventListener("overflow", this);
this.inputField.addEventListener("underflow", this);
this.inputField.addEventListener("scrollend", this);
window.addEventListener("resize", this);

var textBox = document.getAnonymousElementByAttribute(this,
"anonid", "moz-input-box");
Expand Down Expand Up @@ -158,6 +159,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this.inputField.removeEventListener("overflow", this);
this.inputField.removeEventListener("underflow", this);
this.inputField.removeEventListener("scrollend", this);
window.removeEventListener("resize", this);

if (this._deferredKeyEventTimeout) {
clearTimeout(this._deferredKeyEventTimeout);
Expand Down Expand Up @@ -1418,6 +1420,25 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Ensure to clear those internal caches when switching tabs.
this.controller.resetInternalState();
break;
case "resize":
// Throttle resize handling for performance reasons.
if (aEvent.target == window && !this._resizeThrottleTimeout) {
this._resizeThrottleTimeout = setTimeout(() => {
window.requestAnimationFrame(() => {
delete this._resizeThrottleTimeout;

// Close the popup since it would be wrongly sized, we'll
// recalculate a proper size on reopening. For example, this may
// happen when using special OS resize functions like Win+Arrow.
this.closePopup();

// Ensure the host remains visible when the input field is not
// focused.
this.formatValue();
});
}, 30);
}
break;
}
]]></body>
</method>
Expand Down

0 comments on commit efadf39

Please sign in to comment.