Backed out changeset cf34b2e8ac53 (bug 1513337) for test client failure

This commit is contained in:
Coroiu Cristina 2019-07-17 12:12:21 +03:00
parent 0c11927126
commit 0882dc9bf4
35 changed files with 336 additions and 143 deletions

View File

@ -32,10 +32,8 @@ async function runTests(browser, accDoc) {
evt = await onFocus;
testStates(evt.accessible, STATE_FOCUSED);
onFocus = waitForEvent(
EVENT_FOCUS,
event => event.accessible.DOMNode == gURLBar.inputField
);
let inputField = browser.ownerDocument.getElementById("urlbar").inputField;
onFocus = waitForEvent(EVENT_FOCUS, getAccessible(inputField));
EventUtils.synthesizeKey("t", { accelKey: true }, browser.ownerGlobal);
evt = await onFocus;
testStates(evt.accessible, STATE_FOCUSED);

View File

@ -52,7 +52,7 @@ async function runTests() {
let focused = waitForEvent(
EVENT_FOCUS,
event => event.accessible.role == ROLE_EDITCOMBOBOX
event => event.accessible.role == ROLE_ENTRY
);
gURLBar.focus();
let event = await focused;

View File

@ -30,7 +30,7 @@ async function checkURLBarCaretEvents() {
});
info("Loaded " + kURL);
let urlbarInputEl = newWin.gURLBar.inputField;
let urlbarInputEl = newWin.document.getElementById("urlbar").inputField;
let urlbarInput = getAccessible(urlbarInputEl, [nsIAccessibleText]);
let onCaretMove = waitForEvents([

View File

@ -21,7 +21,7 @@ add_task(async function testAutocompleteRichResult() {
value: "a",
});
info("Waiting for accessibility to be created for the results list");
info("Waiting for accessibility to be created for the richlistbox");
let resultsView;
resultsView = gURLBar.view.panel.querySelector("#urlbarView-results");
await BrowserTestUtils.waitForCondition(() =>

View File

@ -529,6 +529,11 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
min-width: 1px;
}
#urlbar[quantumbar="true"] {
-moz-binding: url(chrome://browser/content/urlbarBindings.xml#urlbar);
}
/* Display URLs left-to-right but right aligned in RTL mode. */
html|input.urlbar-input:-moz-locale-dir(rtl) {
direction: ltr !important;
@ -578,18 +583,18 @@ html|input.urlbar-scheme {
/* Visible if the urlbar is not focused and it overflows at the start.
Uses the required-valid trick to check if it contains a value */
#urlbar[textoverflow="start"]:not([focused]) > .urlbar-input-box > html|input.urlbar-scheme:valid {
html|input.urlbar-scheme[textoverflow="start"]:not([focused]):valid {
visibility: visible;
}
/* Fade out URL on overflow
This mask may be overriden when a Contextual Feature Recommendation is shown,
see browser/themes/shared/urlbar-searchbar.inc.css for details */
#urlbar[textoverflow="end"]:not([focused]) > .urlbar-input-box > html|input.urlbar-input {
html|input.urlbar-input[textoverflow="end"]:not([focused]) {
mask-image: linear-gradient(to left, transparent, black 3ch);
}
#urlbar[textoverflow="start"]:not([focused]) > .urlbar-input-box > html|input.urlbar-input {
html|input.urlbar-input[textoverflow="start"]:not([focused]) {
mask-image: linear-gradient(to right, transparent var(--urlbar-scheme-size), black calc(var(--urlbar-scheme-size) + 3ch));
}
@ -650,9 +655,9 @@ html|input.urlbar-input {
#urlbar[pageproxystate=invalid] > #page-action-buttons > .urlbar-page-action,
#identity-box.chromeUI ~ #page-action-buttons > .urlbar-page-action:not(#star-button-box),
#urlbar[usertyping] > .urlbar-history-dropmarker,
#urlbar:not([usertyping]) > .urlbar-go-button,
#urlbar:not([focused]) > .urlbar-go-button {
.urlbar-history-dropmarker[usertyping],
.urlbar-go-button:not([usertyping]),
.urlbar-go-button:not([parentfocused="true"]) {
display: none;
}

View File

@ -1620,6 +1620,10 @@ var gBrowserInit = {
},
onBeforeInitialXULLayout() {
// Turn on QuantumBar. This can be removed once the quantumbar attribute is gone.
let urlbar = document.getElementById("urlbar");
urlbar.setAttribute("quantumbar", true);
// Set a sane starting width/height for all resolutions on new profiles.
if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) {
// When the fingerprinting resistance is enabled, making sure that we don't
@ -1795,7 +1799,7 @@ var gBrowserInit = {
if (!window.toolbar.visible) {
// adjust browser UI for popups
gURLBar.readOnly = true;
gURLBar.setAttribute("readonly", "true");
}
// Misc. inits.
@ -4524,7 +4528,7 @@ const BrowserSearch = {
} else {
placeholder = gURLBar.getAttribute("defaultPlaceholder");
}
gURLBar.placeholder = placeholder;
gURLBar.setAttribute("placeholder", placeholder);
},
addEngine(browser, engine, uri) {

View File

@ -68,7 +68,7 @@
screenX="4" screenY="4"
fullscreenbutton="true"
sizemode="normal"
retargetdocumentfocus="urlbar-input"
retargetdocumentfocus="urlbar"
persist="screenX screenY width height sizemode"
>
@ -841,10 +841,11 @@
removable="false"
class="chromeclass-location" overflows="false">
<toolbartabstop/>
<hbox id="urlbar" flex="1"
defaultPlaceholder="&urlbar.placeholder2;"
focused="true"
pageproxystate="invalid">
<textbox id="urlbar" flex="1"
placeholder="&urlbar.placeholder2;"
defaultPlaceholder="&urlbar.placeholder2;"
focused="true"
pageproxystate="invalid">
<!-- Use onclick instead of normal popup= syntax since the popup
code fires onmousedown, and hence eats our favicon drag events. -->
<box id="identity-box" role="button"
@ -949,28 +950,6 @@
<label id="switchtab" class="urlbar-display urlbar-display-switchtab" value="&urlbar.switchToTab.label;"/>
<label id="extension" class="urlbar-display urlbar-display-extension" value="&urlbar.extension.label;"/>
</box>
<moz-input-box tooltip="aHTMLTooltip"
class="urlbar-input-box"
flex="1">
<html:input class="urlbar-scheme textbox-input"
required="required"/>
<html:input id="urlbar-input"
anonid="input"
class="urlbar-input textbox-input"
role="combobox"
aria-owns="urlbarView-results"
aria-controls="urlbarView-results"
aria-autocomplete="both"
allowevents="true"
inputmode="mozAwesomebar"
placeholder="&urlbar.placeholder2;"/>
</moz-input-box>
<image class="urlbar-go-button urlbar-icon"
onclick="gURLBar.handleCommand(event);"
tooltiptext="&goEndCap.tooltip;"/>
<image class="urlbar-history-dropmarker urlbar-icon chromeclass-toolbar-additional"
tooltiptext="&urlbar.openHistoryPopup.tooltip;"
allowevents="true"/>
<hbox id="page-action-buttons" context="pageActionContextMenu">
<toolbartabstop/>
<hbox id="contextual-feature-recommendation" role="button" hidden="true">
@ -1029,7 +1008,7 @@
</hbox>
</hbox>
</hbox>
</hbox>
</textbox>
<toolbartabstop/>
</toolbaritem>

View File

@ -85,7 +85,11 @@ add_task(async function test_toolbar_contextmenu_touch() {
// Test the urlbar input context menu.
add_task(async function test_urlbar_contextmenu_touch() {
let urlbar = document.getElementById("urlbar");
let textBox = urlbar.querySelector("moz-input-box");
let textBox = document.getAnonymousElementByAttribute(
urlbar,
"anonid",
"moz-input-box"
);
let menu = textBox.menupopup;
await openAndCheckContextMenu(menu, textBox);
});

View File

@ -45,8 +45,8 @@ const EXPECTED_APPMENU_OPEN_REFLOWS = [
add_task(async function() {
await ensureNoPreloadedBrowser();
let textBoxRect = gURLBar
.querySelector("moz-input-box")
let textBoxRect = document
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
.getBoundingClientRect();
let menuButtonRect = document
.getElementById("PanelUI-menu-button")

View File

@ -32,10 +32,16 @@ add_task(async function() {
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
let firstTabRect = gBrowser.selectedTab.getBoundingClientRect();
let firstTabLabelRect = gBrowser.selectedTab.textLabel.getBoundingClientRect();
let textBoxRect = gURLBar
.querySelector("moz-input-box")
let textBoxRect = document
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
.getBoundingClientRect();
let historyDropmarkerRect = document
.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"historydropmarker"
)
.getBoundingClientRect();
let historyDropmarkerRect = gURLBar.dropmarker.getBoundingClientRect();
let inRange = (val, min, max) => min <= val && val <= max;

View File

@ -34,8 +34,8 @@ add_task(async function() {
await ensureFocusedUrlbar();
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
let textBoxRect = gURLBar
.querySelector("moz-input-box")
let textBoxRect = document
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
.getBoundingClientRect();
await withPerfObserver(

View File

@ -38,10 +38,16 @@ add_task(async function() {
await ensureFocusedUrlbar();
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
let textBoxRect = gURLBar
.querySelector("moz-input-box")
let textBoxRect = document
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
.getBoundingClientRect();
let urlbarDropmarkerRect = document
.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"historydropmarker"
)
.getBoundingClientRect();
let urlbarDropmarkerRect = gURLBar.dropmarker.getBoundingClientRect();
let ignoreTabstripRects = {
filter: rects =>

View File

@ -43,7 +43,13 @@ add_task(async function() {
"We shouldn't have added any new expected reflows for window close."
);
let dropmarkerRect = gURLBar.dropmarker.getBoundingClientRect();
let dropmarkerRect = document
.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"historydropmarker"
)
.getBoundingClientRect();
await withPerfObserver(
async function() {

View File

@ -298,8 +298,13 @@ async function ensureFocusedUrlbar() {
() => !gURLBar.hasAttribute("switchingtabs")
);
let dropmarker = document.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"historydropmarker"
);
let opacityPromise = BrowserTestUtils.waitForEvent(
gURLBar.dropmarker,
dropmarker,
"transitionend",
false,
e => e.propertyName === "opacity"
@ -816,9 +821,15 @@ async function runUrlbarTest(
await UrlbarTestUtils.promisePopupClose(win);
};
let dropmarkerRect = URLBar.dropmarker.getBoundingClientRect();
let textBoxRect = gURLBar
.querySelector("moz-input-box")
let dropmarkerRect = win.document
.getAnonymousElementByAttribute(
URLBar.textbox,
"anonid",
"historydropmarker"
)
.getBoundingClientRect();
let textBoxRect = win.document
.getAnonymousElementByAttribute(URLBar.textbox, "anonid", "moz-input-box")
.getBoundingClientRect();
let expectedRects = {
filter: rects =>

View File

@ -24,8 +24,13 @@ add_task(async function toolbar_ui_visibility() {
"'open location' command is not disabled in the popup"
);
let historyButton = doc.getAnonymousElementByAttribute(
win.gURLBar.textbox,
"anonid",
"historydropmarker"
);
is(
win.gURLBar.dropmarker.clientWidth,
historyButton.clientWidth,
0,
"history dropdown button is hidden in the popup"
);

View File

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!--
-*- Mode: HTML -*-
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<!DOCTYPE bindings [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
%browserDTD;
]>
<bindings id="urlbarBindings" xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="urlbar" extends="chrome://global/content/bindings/textbox.xml#textbox">
<content role="combobox">
<children includes="box"/>
<xul:moz-input-box anonid="moz-input-box"
tooltip="aHTMLTooltip"
class="urlbar-input-box"
flex="1">
<children/>
<html:input anonid="scheme"
class="urlbar-scheme textbox-input"
required="required"
xbl:inherits="textoverflow,focused"/>
<html:input anonid="input"
class="urlbar-input textbox-input"
aria-owns="urlbarView-results"
aria-controls="urlbarView-results"
aria-autocomplete="both"
allowevents="true"
inputmode="mozAwesomebar"
xbl:inherits="value,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,focused,textoverflow"/>
</xul:moz-input-box>
<xul:image anonid="urlbar-go-button"
class="urlbar-go-button urlbar-icon"
onclick="gURLBar.handleCommand(event);"
tooltiptext="&goEndCap.tooltip;"
xbl:inherits="pageproxystate,parentfocused=focused,usertyping"/>
<xul:image anonid="historydropmarker"
class="urlbar-history-dropmarker urlbar-icon chromeclass-toolbar-additional"
tooltiptext="&urlbar.openHistoryPopup.tooltip;"
allowevents="true"
xbl:inherits="open,parentfocused=focused,usertyping"/>
<children includes="hbox"/>
</content>
</binding>
</bindings>

View File

@ -94,6 +94,7 @@ browser.jar:
content/browser/tabbrowser.js (content/tabbrowser.js)
content/browser/tabbrowser-tab.js (content/tabbrowser-tab.js)
content/browser/tabbrowser-tabs.js (content/tabbrowser-tabs.js)
content/browser/urlbarBindings.xml (content/urlbarBindings.xml)
content/browser/utilityOverlay.js (content/utilityOverlay.js)
content/browser/webext-panels.js (content/webext-panels.js)
* content/browser/webext-panels.xul (content/webext-panels.xul)

View File

@ -111,21 +111,17 @@ class UrlbarInput {
// This exists only for tests.
this._enableAutofillPlaceholder = true;
// Forward certain methods and properties.
const CONTAINER_METHODS = [
// Forward textbox methods and properties.
const METHODS = [
"addEventListener",
"removeEventListener",
"getAttribute",
"hasAttribute",
"querySelector",
"setAttribute",
"removeAttribute",
"toggleAttribute",
];
const INPUT_METHODS = [
"addEventListener",
"blur",
"focus",
"removeEventListener",
];
const READ_ONLY_PROPERTIES = ["inputField", "editor"];
const READ_WRITE_PROPERTIES = [
"placeholder",
"readOnly",
@ -133,33 +129,33 @@ class UrlbarInput {
"selectionEnd",
];
for (let method of CONTAINER_METHODS) {
for (let method of METHODS) {
this[method] = (...args) => {
return this.textbox[method](...args);
};
}
for (let method of INPUT_METHODS) {
this[method] = (...args) => {
return this.inputField[method](...args);
};
for (let property of READ_ONLY_PROPERTIES) {
Object.defineProperty(this, property, {
enumerable: true,
get() {
return this.textbox && this.textbox[property];
},
});
}
for (let property of READ_WRITE_PROPERTIES) {
Object.defineProperty(this, property, {
enumerable: true,
get() {
return this.inputField[property];
return this.textbox && this.textbox[property];
},
set(val) {
return (this.inputField[property] = val);
return (this.textbox[property] = val);
},
});
}
this.inputField = this.querySelector(".urlbar-input");
this.dropmarker = this.querySelector(".urlbar-history-dropmarker");
XPCOMUtils.defineLazyGetter(this, "valueFormatter", () => {
return new UrlbarValueFormatter(this);
});
@ -167,7 +163,7 @@ class UrlbarInput {
// If the toolbar is not visible in this window or the urlbar is readonly,
// we'll stop here, so that most properties of the input object are valid,
// but we won't handle events.
if (!this.window.toolbar.visible || this.readOnly) {
if (!this.window.toolbar.visible || this.hasAttribute("readonly")) {
return;
}
@ -199,10 +195,12 @@ class UrlbarInput {
"select",
];
for (let name of this._inputFieldEvents) {
this.addEventListener(name, this);
this.inputField.addEventListener(name, this);
}
this.dropmarker.addEventListener("mousedown", this);
// This is needed for the dropmarker. Once we remove that (i.e. make
// openViewOnFocus = true the default), this won't be needed anymore.
this.addEventListener("mousedown", this);
this.view.panel.addEventListener("popupshowing", this);
this.view.panel.addEventListener("popuphidden", this);
@ -229,9 +227,9 @@ class UrlbarInput {
uninit() {
this.window.removeEventListener("unload", this);
for (let name of this._inputFieldEvents) {
this.removeEventListener(name, this);
this.inputField.removeEventListener(name, this);
}
this.dropmarker.removeEventListener("mousedown", this);
this.removeEventListener("mousedown", this);
this.view.panel.remove();
@ -266,7 +264,6 @@ class UrlbarInput {
delete this.view;
delete this.controller;
delete this.textbox;
delete this.inputField;
}
/**
@ -304,6 +301,14 @@ class UrlbarInput {
}
}
focus() {
this.inputField.focus();
}
blur() {
this.inputField.blur();
}
select() {
// See _on_select(). HTMLInputElement.select() dispatches a "select"
// event but does not set the primary selection.
@ -780,16 +785,16 @@ class UrlbarInput {
// Getters and Setters below.
get editor() {
return this.inputField.editor;
}
get focused() {
return this.getAttribute("focused") == "true";
return this.textbox.getAttribute("focused") == "true";
}
get goButton() {
return this.querySelector(".urlbar-go-button");
return this.document.getAnonymousElementByAttribute(
this.textbox,
"anonid",
"urlbar-go-button"
);
}
get textValue() {
@ -817,7 +822,7 @@ class UrlbarInput {
this._openViewOnFocus = Services.prefs.getBoolPref(
"browser.urlbar.openViewOnFocus"
);
this.dropmarker.hidden = this._openViewOnFocus;
this.toggleAttribute("hidedropmarker", this._openViewOnFocus);
}
_setValue(val, allowTrim) {
@ -1317,7 +1322,13 @@ class UrlbarInput {
}
_initPasteAndGo() {
let inputBox = this.querySelector("moz-input-box");
let inputBox = this.document.getAnonymousElementByAttribute(
this.textbox,
"anonid",
"moz-input-box"
);
// Force the Custom Element to upgrade until Bug 1470242 handles this:
this.window.customElements.upgrade(inputBox);
let contextMenu = inputBox.menupopup;
let insertLocation = contextMenu.firstElementChild;
while (
@ -1394,14 +1405,11 @@ class UrlbarInput {
// Event handlers below.
_on_blur(event) {
this.removeAttribute("focused");
this.formatValue();
this._resetSearchState();
// In certain cases, like holding an override key and confirming an entry,
// we don't key a keyup event for the override key, thus we make this
// additional cleanup on blur.
this._clearActionOverride();
this.formatValue();
// The extension input sessions depends more on blur than on the fact we
// actually cancel a running query, so we do it here.
@ -1414,11 +1422,11 @@ class UrlbarInput {
if (!UrlbarPrefs.get("ui.popup.disable_autohide")) {
this.view.close();
}
// We may have hidden popup notifications, show them again if necessary.
if (this.getAttribute("pageproxystate") != "valid") {
this.window.UpdatePopupNotificationsVisibility();
}
this._resetSearchState();
}
_on_click(event) {
@ -1442,7 +1450,6 @@ class UrlbarInput {
}
_on_focus(event) {
this.setAttribute("focused", "true");
this._updateUrlTooltip();
this.formatValue();
@ -1476,7 +1483,10 @@ class UrlbarInput {
return;
}
if (event.currentTarget == this.dropmarker && event.button == 0) {
if (
event.originalTarget.classList.contains("urlbar-history-dropmarker") &&
event.button == 0
) {
if (this.view.isOpen) {
this.view.close();
} else {
@ -1701,11 +1711,11 @@ class UrlbarInput {
}
_on_popupshowing() {
this.dropmarker.setAttribute("open", "true");
this.setAttribute("open", "true");
}
_on_popuphidden() {
this.dropmarker.removeAttribute("open");
this.removeAttribute("open");
}
_on_dragstart(event) {
@ -1714,7 +1724,7 @@ class UrlbarInput {
event.originalTarget
);
if (
event.target != this.inputField &&
this.inputField != event.originalTarget &&
!(nodePosition & Node.DOCUMENT_POSITION_CONTAINED_BY)
) {
return;

View File

@ -46,7 +46,11 @@ class UrlbarValueFormatter {
}
get scheme() {
return this.urlbarInput.textbox.querySelector(".urlbar-scheme");
return this.document.getAnonymousElementByAttribute(
this.urlbarInput.textbox,
"anonid",
"scheme"
);
}
update() {

View File

@ -216,7 +216,11 @@ var UrlbarTestUtils = {
},
getDropMarker(win) {
return win.gURLBar.dropmarker;
return win.document.getAnonymousElementByAttribute(
win.gURLBar.textbox,
"anonid",
"historydropmarker"
);
},
/**

View File

@ -50,7 +50,12 @@ add_task(async function proxyState() {
async function clickDropmarker() {
await UrlbarTestUtils.promisePopupOpen(window, () => {
EventUtils.synthesizeMouseAtCenter(gURLBar.dropmarker, {}, window);
let historyDropMarker = window.document.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"historydropmarker"
);
EventUtils.synthesizeMouseAtCenter(historyDropMarker, {}, window);
});
let queryContext = await gURLBar.lastQueryContextPromise;
return queryContext;

View File

@ -30,7 +30,11 @@ add_task(async function() {
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
);
});
let textBox = gURLBar.querySelector("moz-input-box");
let textBox = document.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"moz-input-box"
);
let cxmenu = textBox.menupopup;
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {
@ -67,7 +71,11 @@ add_task(async function() {
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
);
});
let textBox = gURLBar.querySelector("moz-input-box");
let textBox = document.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"moz-input-box"
);
let cxmenu = textBox.menupopup;
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {

View File

@ -31,7 +31,12 @@ add_task(async function() {
await BrowserTestUtils.switchTab(gBrowser, tab1);
// Now open the popup by the history marker.
await UrlbarTestUtils.promisePopupOpen(window, () => {
EventUtils.synthesizeMouseAtCenter(gURLBar.dropmarker, {}, window);
let historyDropMarker = window.document.getAnonymousElementByAttribute(
gURLBar.textbox,
"anonid",
"historydropmarker"
);
EventUtils.synthesizeMouseAtCenter(historyDropMarker, {}, window);
});
// Check that the popup closes when we switch tab.
await UrlbarTestUtils.promisePopupClose(window, () => {

View File

@ -46,18 +46,23 @@ add_task(async function test_change_default_engine_updates_placeholder() {
await Services.search.setDefault(extraEngine);
await TestUtils.waitForCondition(
() => gURLBar.placeholder == gURLBar.getAttribute("defaultPlaceholder"),
() =>
gURLBar.getAttribute("placeholder") ==
gURLBar.getAttribute("defaultPlaceholder"),
"The placeholder should match the default placeholder for non-built-in engines."
);
Assert.equal(gURLBar.placeholder, gURLBar.getAttribute("defaultPlaceholder"));
Assert.equal(
gURLBar.getAttribute("placeholder"),
gURLBar.getAttribute("defaultPlaceholder")
);
await Services.search.setDefault(originalEngine);
await TestUtils.waitForCondition(
() => gURLBar.placeholder == expectedString,
() => gURLBar.getAttribute("placeholder") == expectedString,
"The placeholder should include the engine name for built-in engines."
);
Assert.equal(gURLBar.placeholder, expectedString);
Assert.equal(gURLBar.getAttribute("placeholder"), expectedString);
});
add_task(async function test_delayed_update_placeholder() {
@ -77,7 +82,7 @@ add_task(async function test_delayed_update_placeholder() {
BrowserSearch._updateURLBarPlaceholder(extraEngine.name, true);
Assert.equal(
gURLBar.placeholder,
gURLBar.getAttribute("placeholder"),
expectedString,
"Placeholder should be unchanged."
);
@ -86,7 +91,9 @@ add_task(async function test_delayed_update_placeholder() {
await BrowserTestUtils.switchTab(gBrowser, urlTab);
await TestUtils.waitForCondition(
() => gURLBar.placeholder == gURLBar.getAttribute("defaultPlaceholder"),
() =>
gURLBar.getAttribute("placeholder") ==
gURLBar.getAttribute("defaultPlaceholder"),
"The placeholder should have updated in the background."
);
@ -97,7 +104,7 @@ add_task(async function test_delayed_update_placeholder() {
await TestUtils.waitForTick();
Assert.equal(
gURLBar.placeholder,
gURLBar.getAttribute("placeholder"),
gURLBar.getAttribute("defaultPlaceholder"),
"Placeholder should be unchanged."
);
@ -105,7 +112,7 @@ add_task(async function test_delayed_update_placeholder() {
await BrowserTestUtils.switchTab(gBrowser, urlTab);
await TestUtils.waitForCondition(
() => gURLBar.placeholder == expectedString,
() => gURLBar.getAttribute("placeholder") == expectedString,
"The placeholder should include the engine name for built-in engines."
);
@ -114,7 +121,7 @@ add_task(async function test_delayed_update_placeholder() {
await TestUtils.waitForTick();
Assert.equal(
gURLBar.placeholder,
gURLBar.getAttribute("placeholder"),
gURLBar.getAttribute("defaultPlaceholder"),
"Placeholder should be the default."
);

View File

@ -316,18 +316,24 @@
height: 30px;
}
:not(.urlbar-icon-wrapper) > .urlbar-icon:not([disabled]):hover,
.urlbar-icon:not([disabled]):hover,
.urlbar-icon-wrapper:not([disabled]):hover {
background-color: hsla(0,0%,70%,.2);
}
:not(.urlbar-icon-wrapper) > .urlbar-icon:not([disabled])[open],
:not(.urlbar-icon-wrapper) > .urlbar-icon:not([disabled]):hover:active,
.urlbar-icon-wrapper:not([disabled])[open],
.urlbar-icon-wrapper:not([disabled]):hover:active {
.urlbar-icon[open],
.urlbar-icon-wrapper[open],
.urlbar-icon:not([disabled]):hover:active,
.urlbar-icon-wrapper:hover:active {
background-color: hsla(0,0%,70%,.3);
}
.urlbar-icon-wrapper[open] > .urlbar-icon,
.urlbar-icon-wrapper > .urlbar-icon:hover,
.urlbar-icon-wrapper > .urlbar-icon:hover:active {
background-color: transparent;
}
.urlbar-icon:-moz-focusring,
.urlbar-icon-wrapper:-moz-focusring {
outline: var(--toolbarbutton-focus-outline);
@ -350,6 +356,15 @@
transition: opacity 0.15s ease;
}
#urlbar[hidedropmarker] > .urlbar-history-dropmarker {
display: none;
}
/* Avoid re-opening the popup when the dropmarker is clicked while the popup is still open. */
#urlbar[quantumbar="false"] > .urlbar-history-dropmarker[open] {
pointer-events: none;
}
#urlbar[switchingtabs] > .urlbar-history-dropmarker {
transition: none;
}

View File

@ -142,7 +142,7 @@ add_task(async function() {
}
// Focus chrome
gURLBar.focus();
document.getElementById("urlbar").focus();
let originalFocus = Services.focus.focusedElement;
// Load about:blank just to make sure that everything works nicely

View File

@ -17,11 +17,11 @@ add_task(async function test() {
for (var button = 0; button < 3; button++) {
// Set focus to a chrome element before synthesizing a mouse down event.
gURLBar.focus();
document.getElementById("urlbar").focus();
is(
fm.focusedElement,
gURLBar.inputField,
document.getElementById("urlbar").inputField,
"Failed to move focus to search bar: button=" + button
);
@ -31,7 +31,7 @@ add_task(async function test() {
isnot(
fm.focusedElement,
gURLBar.inputField,
document.getElementById("urlbar").inputField,
"Failed to move focus away from search bar: button=" + button
);

View File

@ -95,11 +95,17 @@ class TestLocationBar(PuppeteerMixin, MarionetteTestCase):
self.assertEqual(self.locationbar.identity_organization_label.get_property('localName'),
'label')
self.assertEqual(self.locationbar.identity_icon.get_property('localName'), 'image')
self.assertEqual(self.locationbar.history_drop_marker.get_property('localName'),
'dropmarker')
self.assertEqual(self.locationbar.reload_button.get_property('localName'),
'toolbarbutton')
self.assertEqual(self.locationbar.stop_button.get_property('localName'),
'toolbarbutton')
self.assertEqual(self.locationbar.contextmenu.get_property('localName'), 'menupopup')
self.assertEqual(self.locationbar.get_contextmenu_entry('paste').get_attribute('cmd'),
'cmd_paste')
def test_reload(self):
event_types = ["shortcut", "shortcut2", "button"]
for event in event_types:

View File

@ -90,6 +90,11 @@ class LocationBar(UIBaseLib):
lambda _: self.value == '',
message='Contents of location bar could not be cleared.')
def close_context_menu(self):
"""Closes the Location Bar context menu by a key event."""
# TODO: This method should be implemented via the menu API.
self.contextmenu.send_keys(keys.Keys.ESCAPE)
@property
def connection_icon(self):
""" Provides access to the urlbar connection icon.
@ -98,6 +103,16 @@ class LocationBar(UIBaseLib):
"""
return self.marionette.find_element(By.ID, 'connection-icon')
@property
def contextmenu(self):
"""Provides access to the urlbar context menu.
:returns: Reference to the urlbar context menu.
"""
# TODO: This method should be implemented via the menu API.
parent = self.urlbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'moz-input-box'})
return parent.find_element(By.ANON_ATTRIBUTE, {'anonid': 'input-box-contextmenu'})
@property
def focused(self):
"""Checks the focus state of the location bar.
@ -132,6 +147,27 @@ class LocationBar(UIBaseLib):
lambda _: self.focused,
message='Location bar has not be focused.')
def get_contextmenu_entry(self, action):
"""Retrieves the urlbar context menu entry corresponding
to the given action.
:param action: The action corresponding to the retrieved value.
:returns: Reference to the urlbar contextmenu entry.
"""
# TODO: This method should be implemented via the menu API.
entries = self.contextmenu.find_elements(By.CSS_SELECTOR, 'menuitem')
filter_on = 'cmd_%s' % action
found = [e for e in entries if e.get_attribute('cmd') == filter_on]
return found[0] if len(found) else None
@property
def history_drop_marker(self):
"""Provides access to the history drop marker.
:returns: Reference to the history drop marker.
"""
return self.urlbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'historydropmarker'})
@property
def identity_box(self):
"""The DOM element which represents the identity box.
@ -243,7 +279,7 @@ class LocationBar(UIBaseLib):
:returns: Reference to the urlbar input.
"""
return self.urlbar.find_element(By.CLASS_NAME, 'urlbar-input')
return self.urlbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'input'})
@property
def value(self):
@ -251,7 +287,7 @@ class LocationBar(UIBaseLib):
:returns: The urlbar value.
"""
return self.urlbar_input.get_property('value')
return self.urlbar.get_property('value')
class AutocompleteResults(UIBaseLib):

View File

@ -29,9 +29,10 @@ add_task(async function test_support_selection() {
});
await extension.startup();
let urlBar = document.querySelector("#urlbar");
let fields = [
gURLBar.inputField,
document.getAnonymousElementByAttribute(urlBar, "anonid", "input"),
document.querySelector("#searchbar .searchbar-textbox"),
].filter(field => {
let bounds = field.getBoundingClientRect();

View File

@ -77,6 +77,18 @@ add_task(async function test_backButton_forwardButton() {
);
await fillTestPage(aBrowser);
let forwardButton = document.getElementById("forward-button");
let forwardTransitionPromise;
if (forwardButton.nextElementSibling == gURLBar) {
// We need to wait for the forward button transition to complete before we
// can click it, so we hook up a listener to wait for it to be ready.
forwardTransitionPromise = BrowserTestUtils.waitForEvent(
forwardButton,
"transitionend"
);
}
let backPromise = BrowserTestUtils.browserStopped(aBrowser);
EventUtils.synthesizeMouseAtCenter(
document.getElementById("back-button"),
@ -91,7 +103,11 @@ add_task(async function test_backButton_forwardButton() {
// Now go forward again after filling
await fillTestPage(aBrowser);
let forwardButton = document.getElementById("forward-button");
if (forwardTransitionPromise) {
await forwardTransitionPromise;
info("transition done");
}
await BrowserTestUtils.waitForCondition(() => {
return !forwardButton.disabled;
});

View File

@ -63,7 +63,7 @@ class TelemetryTestCase(WindowManagerMixin, MarionetteTestCase):
"""Perform a search via the browser's URL bar."""
with self.marionette.using_context(self.marionette.CONTEXT_CHROME):
urlbar = self.marionette.find_element(By.ID, "urlbar-input")
urlbar = self.marionette.find_element(By.ID, "urlbar")
urlbar.send_keys(keys.Keys.DELETE)
urlbar.send_keys(text + keys.Keys.ENTER)

View File

@ -46,7 +46,7 @@ class TestEventPing(TelemetryTestCase):
self.enable_search_events()
self.wait_for_search_service_init()
self.search_in_new_tab("mozilla firefox")
self.search("mozilla firefox")
payload = self.wait_for_ping(self.restart_browser, EVENT_PING)["payload"]

View File

@ -74,7 +74,6 @@ window.addEventListener("contextmenu", e => {
let needsContextMenu =
e.target.ownerDocument == document &&
!e.defaultPrevented &&
e.target.parentNode.nodeName != "moz-input-box" &&
((["textarea", "input"].includes(e.target.localName) &&
e.target.namespaceURI == HTML_NS) ||
e.target.closest("textbox[is='search-textbox']"));

View File

@ -88,7 +88,7 @@
this.menupopup = this.querySelector(".textbox-contextmenu");
this.menupopup.addEventListener("popupshowing", event => {
let input = this._input;
var input = this.getElementsByAttribute("anonid", "input")[0];
if (document.commandDispatcher.focusedElement != input) {
input.focus();
}
@ -196,13 +196,18 @@
return null;
}
var textbox = document.getBindingParent(this);
if (!textbox || textbox.localName != "textbox") {
return null;
}
try {
ChromeUtils.import(
"resource://gre/modules/InlineSpellChecker.jsm",
this
);
this.InlineSpellCheckerUI = new this.InlineSpellChecker(
this._input.editor
textbox.editor
);
} catch (ex) {}
}
@ -224,13 +229,6 @@
);
controller.doCommand(command);
}
get _input() {
return (
this.getElementsByAttribute("anonid", "input")[0] ||
this.querySelector(".textbox-input")
);
}
}
customElements.define("moz-input-box", MozInputBox);