Skip to content

Commit

Permalink
Bug 1610200 - In full screen, properly hide the toolbars after the us…
Browse files Browse the repository at this point in the history
…er picks a result in the urlbar. r=dao

Two fixes:

* The urlbar view isn't a popup anymore, so `FullScreen` should listen for `onViewOpen` and `onViewClose` on the urlbar controller instead of popup events.
* Change the keypress listeners to keydown to listen for enter events in the urlbar and hide the toolbars.

Differential Revision: https://phabricator.services.mozilla.com/D62123

--HG--
extra : moz-landing-system : lando
  • Loading branch information
0c0w3 committed Feb 13, 2020
1 parent e2fb6b8 commit 83760cc
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
20 changes: 18 additions & 2 deletions browser/base/content/browser-fullScreenAndPointerLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ var FullScreen = {
document.addEventListener("keypress", this._keyToggleCallback);
document.addEventListener("popupshown", this._setPopupOpen);
document.addEventListener("popuphidden", this._setPopupOpen);
gURLBar.controller.addQueryListener(this);

// In DOM fullscreen mode, we hide toolbars with CSS
if (!document.fullscreenElement) {
this.hideNavToolbox(true);
Expand Down Expand Up @@ -480,6 +482,7 @@ var FullScreen = {
document.removeEventListener("keypress", this._keyToggleCallback);
document.removeEventListener("popupshown", this._setPopupOpen);
document.removeEventListener("popuphidden", this._setPopupOpen);
gURLBar.controller.removeQueryListener(this);
}
},

Expand Down Expand Up @@ -612,6 +615,19 @@ var FullScreen = {
}
},

// UrlbarController listener method
onViewOpen() {
if (!this._isChromeCollapsed) {
this._isPopupOpen = true;
}
},

// UrlbarController listener method
onViewClose() {
this._isPopupOpen = false;
this.hideNavToolbox(true);
},

get navToolboxHidden() {
return this._isChromeCollapsed;
},
Expand Down Expand Up @@ -702,10 +718,10 @@ var FullScreen = {
}
}, 0);
});
window.removeEventListener("keypress", retryHideNavToolbox);
window.removeEventListener("keydown", retryHideNavToolbox);
window.removeEventListener("click", retryHideNavToolbox);
};
window.addEventListener("keypress", retryHideNavToolbox);
window.addEventListener("keydown", retryHideNavToolbox);
window.addEventListener("click", retryHideNavToolbox);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions browser/base/content/test/fullscreen/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ skip-if = os == 'linux' # Bug 1561973
skip-if = debug && os == 'mac' # Bug 1568570
[browser_fullscreen_cross_origin.js]
support-files = fullscreen.html fullscreen_frame.html
[browser_fullscreen_enterInUrlbar.js]
run-if = os != 'mac' # Tests non-Mac full screen
[browser_fullscreen_window_open.js]
skip-if = debug && os == 'mac' # Bug 1568570
[browser_fullscreen_window_focus.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

// This test makes sure that when the user presses enter in the urlbar in full
// screen, the toolbars are hidden. This should not be run on macOS because we
// don't hide the toolbars there.

"use strict";

XPCOMUtils.defineLazyModuleGetters(this, {
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.jsm",
});

add_task(async function test() {
await BrowserTestUtils.withNewTab("about:blank", async () => {
// Do the View:FullScreen command and wait for the transition.
let onFullscreen = BrowserTestUtils.waitForEvent(window, "fullscreen");
document.getElementById("View:FullScreen").doCommand();
await onFullscreen;

// Do the Browser:OpenLocation command to show the nav toolbox and focus
// the urlbar.
let onToolboxShown = TestUtils.topicObserved(
"fullscreen-nav-toolbox",
(subject, data) => data == "shown"
);
document.getElementById("Browser:OpenLocation").doCommand();
info("Waiting for the nav toolbox to be shown");
await onToolboxShown;

// Enter a URL.
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "http://example.com/",
waitForFocus: SimpleTest.waitForFocus,
fireInputEvent: true,
});

// Press enter and wait for the nav toolbox to be hidden.
let onToolboxHidden = TestUtils.topicObserved(
"fullscreen-nav-toolbox",
(subject, data) => data == "hidden"
);
EventUtils.synthesizeKey("KEY_Enter");
info("Waiting for the nav toolbox to be hidden");
await onToolboxHidden;

Assert.ok(true, "Nav toolbox hidden");
});
});

0 comments on commit 83760cc

Please sign in to comment.