Bug 1699407 - Cannot click on the search mode indicator to focus the urlbar. r=harry

Differential Revision: https://phabricator.services.mozilla.com/D109098
This commit is contained in:
Marco Bonardo 2021-03-20 11:17:25 +00:00
Родитель eed3915465
Коммит 925df8fc60
5 изменённых файлов: 77 добавлений и 16 удалений

Просмотреть файл

@ -348,9 +348,7 @@ var UrlbarTestUtils = {
if (win.gURLBar.view.isOpen) {
return;
}
if (this._testScope) {
this._testScope.info("Awaiting for the urlbar panel to open");
}
this._testScope?.info("Awaiting for the urlbar panel to open");
await new Promise(resolve => {
win.gURLBar.controller.addQueryListener({
onViewOpen() {
@ -359,6 +357,7 @@ var UrlbarTestUtils = {
},
});
});
this._testScope?.info("Urlbar panel opened");
},
/**
@ -377,9 +376,7 @@ var UrlbarTestUtils = {
if (!win.gURLBar.view.isOpen) {
return;
}
if (this._testScope) {
this._testScope.info("Awaiting for the urlbar panel to close");
}
this._testScope?.info("Awaiting for the urlbar panel to close");
await new Promise(resolve => {
win.gURLBar.controller.addQueryListener({
onViewClose() {
@ -388,6 +385,7 @@ var UrlbarTestUtils = {
},
});
});
this._testScope?.info("Urlbar panel closed");
},
/**
@ -481,11 +479,9 @@ var UrlbarTestUtils = {
let ignoreProperties = ["icon", "pref", "restrict"];
for (let prop of ignoreProperties) {
if (prop in expectedSearchMode && !(prop in window.gURLBar.searchMode)) {
if (this._testScope) {
this._testScope.info(
`Ignoring unimportant property '${prop}' in expected search mode`
);
}
this._testScope?.info(
`Ignoring unimportant property '${prop}' in expected search mode`
);
delete expectedSearchMode[prop];
}
}
@ -595,6 +591,8 @@ var UrlbarTestUtils = {
* @note Can only be used if UrlbarTestUtils has been initialized with init().
*/
async enterSearchMode(window, searchMode = null) {
this._testScope?.info(`Enter Search Mode ${JSON.stringify(searchMode)}`);
// Ensure any pending query is complete.
await this.promiseSearchComplete(window);

Просмотреть файл

@ -27,3 +27,4 @@ support-files =
add_search_engine_two.html
add_search_engine_0.xml
add_search_engine_1.xml
[browser_searchMode_indicator_clickthrough.js]

Просмотреть файл

@ -0,0 +1,57 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check clicking on the search mode label when the urlbar is not focused puts
* focus in the urlbar.
*/
add_task(async function test() {
// Avoid remote connections.
await SpecialPowers.pushPrefEnv({
set: [["browser.search.suggest.enabled", false]],
});
await BrowserTestUtils.withNewTab("about:robots", async browser => {
// View open, with string.
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "test",
});
const indicator = document.getElementById("urlbar-search-mode-indicator");
Assert.ok(!BrowserTestUtils.is_visible(indicator));
const labelBox = document.getElementById("urlbar-label-box");
Assert.ok(!BrowserTestUtils.is_visible(labelBox));
await UrlbarTestUtils.enterSearchMode(window);
Assert.ok(BrowserTestUtils.is_visible(indicator));
Assert.ok(!BrowserTestUtils.is_visible(labelBox));
info("Blur the urlbar");
gURLBar.blur();
Assert.ok(!BrowserTestUtils.is_visible(indicator));
Assert.ok(BrowserTestUtils.is_visible(labelBox));
Assert.notEqual(
document.activeElement,
gURLBar.inputField,
"URL Bar should not be focused"
);
info("Focus the urlbar clicking on the label box");
EventUtils.synthesizeMouseAtCenter(labelBox, {});
Assert.ok(BrowserTestUtils.is_visible(indicator));
Assert.ok(!BrowserTestUtils.is_visible(labelBox));
Assert.equal(
document.activeElement,
gURLBar.inputField,
"URL Bar should be focused"
);
info("Leave search mode clicking on the close button");
await UrlbarTestUtils.exitSearchMode(window, { clickClose: true });
Assert.ok(!BrowserTestUtils.is_visible(indicator));
Assert.ok(!BrowserTestUtils.is_visible(labelBox));
});
});

Просмотреть файл

@ -17,6 +17,8 @@ add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.suggest.searches", false]],
});
// Ensure initial state.
UrlbarTestUtils.getOneOffSearchButtons(window).invalidateCache();
});
add_task(async function shortcuts_none() {
@ -30,7 +32,7 @@ add_task(async function shortcuts_none() {
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
value: "test",
});
await rebuildPromise;
@ -52,7 +54,7 @@ add_task(async function shortcuts_two() {
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
value: "test",
});
await rebuildPromise;
@ -123,7 +125,7 @@ add_task(async function shortcuts_two() {
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
value: "test",
});
await rebuildPromise;
Assert.ok(
@ -145,7 +147,7 @@ add_task(async function shortcuts_many() {
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
value: "test",
});
await rebuildPromise;

Просмотреть файл

@ -145,6 +145,10 @@
}
} /*** END proton ***/
#urlbar[searchmode]:not([focused="true"]) > #urlbar-input-container > #urlbar-label-box {
pointer-events: none;
}
@supports not -moz-bool-pref("browser.proton.urlbar.enabled") {
#identity-box[pageproxystate="valid"].notSecureText,
#identity-box[pageproxystate="valid"].chromeUI,
@ -171,7 +175,6 @@
#urlbar[searchmode]:not([breakout-extend]) > #urlbar-input-container > #urlbar-label-box {
border-inline-start-color: transparent;
border-image-width: 0 1px 0 0;
pointer-events: none;
}
#urlbar[searchmode]:not([breakout-extend]) > #urlbar-input-container > #urlbar-label-box:-moz-locale-dir(rtl) {