зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1513337 - Inline urlbar markup into browser.xhtml. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D23191 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0805f9e709
Коммит
d4258708f3
|
@ -32,8 +32,10 @@ async function runTests(browser, accDoc) {
|
|||
evt = await onFocus;
|
||||
testStates(evt.accessible, STATE_FOCUSED);
|
||||
|
||||
let inputField = browser.ownerDocument.getElementById("urlbar").inputField;
|
||||
onFocus = waitForEvent(EVENT_FOCUS, getAccessible(inputField));
|
||||
onFocus = waitForEvent(
|
||||
EVENT_FOCUS,
|
||||
event => event.accessible.DOMNode == gURLBar.inputField
|
||||
);
|
||||
EventUtils.synthesizeKey("t", { accelKey: true }, browser.ownerGlobal);
|
||||
evt = await onFocus;
|
||||
testStates(evt.accessible, STATE_FOCUSED);
|
||||
|
|
|
@ -52,7 +52,7 @@ async function runTests() {
|
|||
|
||||
let focused = waitForEvent(
|
||||
EVENT_FOCUS,
|
||||
event => event.accessible.role == ROLE_ENTRY
|
||||
event => event.accessible.role == ROLE_EDITCOMBOBOX
|
||||
);
|
||||
gURLBar.focus();
|
||||
let event = await focused;
|
||||
|
|
|
@ -30,7 +30,7 @@ async function checkURLBarCaretEvents() {
|
|||
});
|
||||
info("Loaded " + kURL);
|
||||
|
||||
let urlbarInputEl = newWin.document.getElementById("urlbar").inputField;
|
||||
let urlbarInputEl = newWin.gURLBar.inputField;
|
||||
let urlbarInput = getAccessible(urlbarInputEl, [nsIAccessibleText]);
|
||||
|
||||
let onCaretMove = waitForEvents([
|
||||
|
|
|
@ -21,7 +21,7 @@ add_task(async function testAutocompleteRichResult() {
|
|||
value: "a",
|
||||
});
|
||||
|
||||
info("Waiting for accessibility to be created for the richlistbox");
|
||||
info("Waiting for accessibility to be created for the results list");
|
||||
let resultsView;
|
||||
resultsView = gURLBar.view.panel.querySelector("#urlbarView-results");
|
||||
await BrowserTestUtils.waitForCondition(() =>
|
||||
|
|
|
@ -529,11 +529,6 @@ 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;
|
||||
|
@ -583,18 +578,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 */
|
||||
html|input.urlbar-scheme[textoverflow="start"]:not([focused]):valid {
|
||||
#urlbar[textoverflow="start"]:not([focused]) > .urlbar-input-box > html|input.urlbar-scheme: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 */
|
||||
html|input.urlbar-input[textoverflow="end"]:not([focused]) {
|
||||
#urlbar[textoverflow="end"]:not([focused]) > .urlbar-input-box > html|input.urlbar-input {
|
||||
mask-image: linear-gradient(to left, transparent, black 3ch);
|
||||
}
|
||||
|
||||
html|input.urlbar-input[textoverflow="start"]:not([focused]) {
|
||||
#urlbar[textoverflow="start"]:not([focused]) > .urlbar-input-box > html|input.urlbar-input {
|
||||
mask-image: linear-gradient(to right, transparent var(--urlbar-scheme-size), black calc(var(--urlbar-scheme-size) + 3ch));
|
||||
}
|
||||
|
||||
|
@ -655,9 +650,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-history-dropmarker[usertyping],
|
||||
.urlbar-go-button:not([usertyping]),
|
||||
.urlbar-go-button:not([parentfocused="true"]) {
|
||||
#urlbar[usertyping] > .urlbar-history-dropmarker,
|
||||
#urlbar:not([usertyping]) > .urlbar-go-button,
|
||||
#urlbar:not([focused]) > .urlbar-go-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -1620,10 +1620,6 @@ 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
|
||||
|
@ -1799,7 +1795,7 @@ var gBrowserInit = {
|
|||
|
||||
if (!window.toolbar.visible) {
|
||||
// adjust browser UI for popups
|
||||
gURLBar.setAttribute("readonly", "true");
|
||||
gURLBar.readOnly = true;
|
||||
}
|
||||
|
||||
// Misc. inits.
|
||||
|
@ -4528,7 +4524,7 @@ const BrowserSearch = {
|
|||
} else {
|
||||
placeholder = gURLBar.getAttribute("defaultPlaceholder");
|
||||
}
|
||||
gURLBar.setAttribute("placeholder", placeholder);
|
||||
gURLBar.placeholder = placeholder;
|
||||
},
|
||||
|
||||
addEngine(browser, engine, uri) {
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
screenX="4" screenY="4"
|
||||
fullscreenbutton="true"
|
||||
sizemode="normal"
|
||||
retargetdocumentfocus="urlbar"
|
||||
retargetdocumentfocus="urlbar-input"
|
||||
persist="screenX screenY width height sizemode"
|
||||
>
|
||||
|
||||
|
@ -841,11 +841,10 @@
|
|||
removable="false"
|
||||
class="chromeclass-location" overflows="false">
|
||||
<toolbartabstop/>
|
||||
<textbox id="urlbar" flex="1"
|
||||
placeholder="&urlbar.placeholder2;"
|
||||
defaultPlaceholder="&urlbar.placeholder2;"
|
||||
focused="true"
|
||||
pageproxystate="invalid">
|
||||
<hbox id="urlbar" flex="1"
|
||||
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"
|
||||
|
@ -950,6 +949,28 @@
|
|||
<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">
|
||||
|
@ -1008,7 +1029,7 @@
|
|||
</hbox>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</textbox>
|
||||
</hbox>
|
||||
<toolbartabstop/>
|
||||
</toolbaritem>
|
||||
|
||||
|
|
|
@ -85,11 +85,7 @@ 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 = document.getAnonymousElementByAttribute(
|
||||
urlbar,
|
||||
"anonid",
|
||||
"moz-input-box"
|
||||
);
|
||||
let textBox = urlbar.querySelector("moz-input-box");
|
||||
let menu = textBox.menupopup;
|
||||
await openAndCheckContextMenu(menu, textBox);
|
||||
});
|
||||
|
|
|
@ -45,8 +45,8 @@ const EXPECTED_APPMENU_OPEN_REFLOWS = [
|
|||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
|
||||
let textBoxRect = document
|
||||
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let menuButtonRect = document
|
||||
.getElementById("PanelUI-menu-button")
|
||||
|
|
|
@ -32,16 +32,10 @@ add_task(async function() {
|
|||
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
|
||||
let firstTabRect = gBrowser.selectedTab.getBoundingClientRect();
|
||||
let firstTabLabelRect = gBrowser.selectedTab.textLabel.getBoundingClientRect();
|
||||
let textBoxRect = document
|
||||
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let historyDropmarkerRect = document
|
||||
.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
)
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let historyDropmarkerRect = gURLBar.dropmarker.getBoundingClientRect();
|
||||
|
||||
let inRange = (val, min, max) => min <= val && val <= max;
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ add_task(async function() {
|
|||
await ensureFocusedUrlbar();
|
||||
|
||||
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
|
||||
let textBoxRect = document
|
||||
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
|
||||
await withPerfObserver(
|
||||
|
|
|
@ -38,16 +38,10 @@ add_task(async function() {
|
|||
await ensureFocusedUrlbar();
|
||||
|
||||
let tabStripRect = gBrowser.tabContainer.arrowScrollbox.getBoundingClientRect();
|
||||
let textBoxRect = document
|
||||
.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let urlbarDropmarkerRect = document
|
||||
.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
)
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let urlbarDropmarkerRect = gURLBar.dropmarker.getBoundingClientRect();
|
||||
|
||||
let ignoreTabstripRects = {
|
||||
filter: rects =>
|
||||
|
|
|
@ -43,13 +43,7 @@ add_task(async function() {
|
|||
"We shouldn't have added any new expected reflows for window close."
|
||||
);
|
||||
|
||||
let dropmarkerRect = document
|
||||
.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
)
|
||||
.getBoundingClientRect();
|
||||
let dropmarkerRect = gURLBar.dropmarker.getBoundingClientRect();
|
||||
|
||||
await withPerfObserver(
|
||||
async function() {
|
||||
|
|
|
@ -298,13 +298,8 @@ async function ensureFocusedUrlbar() {
|
|||
() => !gURLBar.hasAttribute("switchingtabs")
|
||||
);
|
||||
|
||||
let dropmarker = document.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
);
|
||||
let opacityPromise = BrowserTestUtils.waitForEvent(
|
||||
dropmarker,
|
||||
gURLBar.dropmarker,
|
||||
"transitionend",
|
||||
false,
|
||||
e => e.propertyName === "opacity"
|
||||
|
@ -821,15 +816,9 @@ async function runUrlbarTest(
|
|||
await UrlbarTestUtils.promisePopupClose(win);
|
||||
};
|
||||
|
||||
let dropmarkerRect = win.document
|
||||
.getAnonymousElementByAttribute(
|
||||
URLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
)
|
||||
.getBoundingClientRect();
|
||||
let textBoxRect = win.document
|
||||
.getAnonymousElementByAttribute(URLBar.textbox, "anonid", "moz-input-box")
|
||||
let dropmarkerRect = URLBar.dropmarker.getBoundingClientRect();
|
||||
let textBoxRect = gURLBar
|
||||
.querySelector("moz-input-box")
|
||||
.getBoundingClientRect();
|
||||
let expectedRects = {
|
||||
filter: rects =>
|
||||
|
|
|
@ -24,13 +24,8 @@ 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(
|
||||
historyButton.clientWidth,
|
||||
win.gURLBar.dropmarker.clientWidth,
|
||||
0,
|
||||
"history dropdown button is hidden in the popup"
|
||||
);
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?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>
|
|
@ -94,7 +94,6 @@ 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)
|
||||
|
|
|
@ -110,17 +110,21 @@ class UrlbarInput {
|
|||
// This exists only for tests.
|
||||
this._enableAutofillPlaceholder = true;
|
||||
|
||||
// Forward textbox methods and properties.
|
||||
const METHODS = [
|
||||
"addEventListener",
|
||||
"removeEventListener",
|
||||
// Forward certain methods and properties.
|
||||
const CONTAINER_METHODS = [
|
||||
"getAttribute",
|
||||
"hasAttribute",
|
||||
"querySelector",
|
||||
"setAttribute",
|
||||
"removeAttribute",
|
||||
"toggleAttribute",
|
||||
];
|
||||
const READ_ONLY_PROPERTIES = ["inputField", "editor"];
|
||||
const INPUT_METHODS = [
|
||||
"addEventListener",
|
||||
"blur",
|
||||
"focus",
|
||||
"removeEventListener",
|
||||
];
|
||||
const READ_WRITE_PROPERTIES = [
|
||||
"placeholder",
|
||||
"readOnly",
|
||||
|
@ -128,33 +132,33 @@ class UrlbarInput {
|
|||
"selectionEnd",
|
||||
];
|
||||
|
||||
for (let method of METHODS) {
|
||||
for (let method of CONTAINER_METHODS) {
|
||||
this[method] = (...args) => {
|
||||
return this.textbox[method](...args);
|
||||
};
|
||||
}
|
||||
|
||||
for (let property of READ_ONLY_PROPERTIES) {
|
||||
Object.defineProperty(this, property, {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this.textbox && this.textbox[property];
|
||||
},
|
||||
});
|
||||
for (let method of INPUT_METHODS) {
|
||||
this[method] = (...args) => {
|
||||
return this.inputField[method](...args);
|
||||
};
|
||||
}
|
||||
|
||||
for (let property of READ_WRITE_PROPERTIES) {
|
||||
Object.defineProperty(this, property, {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this.textbox && this.textbox[property];
|
||||
return this.inputField[property];
|
||||
},
|
||||
set(val) {
|
||||
return (this.textbox[property] = val);
|
||||
return (this.inputField[property] = val);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
this.inputField = this.querySelector(".urlbar-input");
|
||||
this.dropmarker = this.querySelector(".urlbar-history-dropmarker");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "valueFormatter", () => {
|
||||
return new UrlbarValueFormatter(this);
|
||||
});
|
||||
|
@ -162,7 +166,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.hasAttribute("readonly")) {
|
||||
if (!this.window.toolbar.visible || this.readOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -194,12 +198,10 @@ class UrlbarInput {
|
|||
"select",
|
||||
];
|
||||
for (let name of this._inputFieldEvents) {
|
||||
this.inputField.addEventListener(name, this);
|
||||
this.addEventListener(name, 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.dropmarker.addEventListener("mousedown", this);
|
||||
|
||||
this.view.panel.addEventListener("popupshowing", this);
|
||||
this.view.panel.addEventListener("popuphidden", this);
|
||||
|
@ -226,9 +228,9 @@ class UrlbarInput {
|
|||
uninit() {
|
||||
this.window.removeEventListener("unload", this);
|
||||
for (let name of this._inputFieldEvents) {
|
||||
this.inputField.removeEventListener(name, this);
|
||||
this.removeEventListener(name, this);
|
||||
}
|
||||
this.removeEventListener("mousedown", this);
|
||||
this.dropmarker.removeEventListener("mousedown", this);
|
||||
|
||||
this.view.panel.remove();
|
||||
|
||||
|
@ -263,6 +265,7 @@ class UrlbarInput {
|
|||
delete this.view;
|
||||
delete this.controller;
|
||||
delete this.textbox;
|
||||
delete this.inputField;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,14 +303,6 @@ 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.
|
||||
|
@ -784,16 +779,16 @@ class UrlbarInput {
|
|||
|
||||
// Getters and Setters below.
|
||||
|
||||
get editor() {
|
||||
return this.inputField.editor;
|
||||
}
|
||||
|
||||
get focused() {
|
||||
return this.textbox.getAttribute("focused") == "true";
|
||||
return this.getAttribute("focused") == "true";
|
||||
}
|
||||
|
||||
get goButton() {
|
||||
return this.document.getAnonymousElementByAttribute(
|
||||
this.textbox,
|
||||
"anonid",
|
||||
"urlbar-go-button"
|
||||
);
|
||||
return this.querySelector(".urlbar-go-button");
|
||||
}
|
||||
|
||||
get textValue() {
|
||||
|
@ -821,7 +816,7 @@ class UrlbarInput {
|
|||
this._openViewOnFocus = Services.prefs.getBoolPref(
|
||||
"browser.urlbar.openViewOnFocus"
|
||||
);
|
||||
this.toggleAttribute("hidedropmarker", this._openViewOnFocus);
|
||||
this.dropmarker.hidden = this._openViewOnFocus;
|
||||
}
|
||||
|
||||
_setValue(val, allowTrim) {
|
||||
|
@ -1321,13 +1316,7 @@ class UrlbarInput {
|
|||
}
|
||||
|
||||
_initPasteAndGo() {
|
||||
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 inputBox = this.querySelector("moz-input-box");
|
||||
let contextMenu = inputBox.menupopup;
|
||||
let insertLocation = contextMenu.firstElementChild;
|
||||
while (
|
||||
|
@ -1404,11 +1393,14 @@ 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.
|
||||
|
@ -1421,11 +1413,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) {
|
||||
|
@ -1449,6 +1441,7 @@ class UrlbarInput {
|
|||
}
|
||||
|
||||
_on_focus(event) {
|
||||
this.setAttribute("focused", "true");
|
||||
this._updateUrlTooltip();
|
||||
this.formatValue();
|
||||
|
||||
|
@ -1482,10 +1475,7 @@ class UrlbarInput {
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
event.originalTarget.classList.contains("urlbar-history-dropmarker") &&
|
||||
event.button == 0
|
||||
) {
|
||||
if (event.currentTarget == this.dropmarker && event.button == 0) {
|
||||
if (this.view.isOpen) {
|
||||
this.view.close();
|
||||
} else {
|
||||
|
@ -1710,11 +1700,11 @@ class UrlbarInput {
|
|||
}
|
||||
|
||||
_on_popupshowing() {
|
||||
this.setAttribute("open", "true");
|
||||
this.dropmarker.setAttribute("open", "true");
|
||||
}
|
||||
|
||||
_on_popuphidden() {
|
||||
this.removeAttribute("open");
|
||||
this.dropmarker.removeAttribute("open");
|
||||
}
|
||||
|
||||
_on_dragstart(event) {
|
||||
|
@ -1723,7 +1713,7 @@ class UrlbarInput {
|
|||
event.originalTarget
|
||||
);
|
||||
if (
|
||||
this.inputField != event.originalTarget &&
|
||||
event.target != this.inputField &&
|
||||
!(nodePosition & Node.DOCUMENT_POSITION_CONTAINED_BY)
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -46,11 +46,7 @@ class UrlbarValueFormatter {
|
|||
}
|
||||
|
||||
get scheme() {
|
||||
return this.document.getAnonymousElementByAttribute(
|
||||
this.urlbarInput.textbox,
|
||||
"anonid",
|
||||
"scheme"
|
||||
);
|
||||
return this.urlbarInput.textbox.querySelector(".urlbar-scheme");
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -216,11 +216,7 @@ var UrlbarTestUtils = {
|
|||
},
|
||||
|
||||
getDropMarker(win) {
|
||||
return win.document.getAnonymousElementByAttribute(
|
||||
win.gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
);
|
||||
return win.gURLBar.dropmarker;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,12 +50,7 @@ add_task(async function proxyState() {
|
|||
|
||||
async function clickDropmarker() {
|
||||
await UrlbarTestUtils.promisePopupOpen(window, () => {
|
||||
let historyDropMarker = window.document.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(historyDropMarker, {}, window);
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.dropmarker, {}, window);
|
||||
});
|
||||
let queryContext = await gURLBar.lastQueryContextPromise;
|
||||
return queryContext;
|
||||
|
|
|
@ -30,11 +30,7 @@ add_task(async function() {
|
|||
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
|
||||
);
|
||||
});
|
||||
let textBox = document.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"moz-input-box"
|
||||
);
|
||||
let textBox = gURLBar.querySelector("moz-input-box");
|
||||
let cxmenu = textBox.menupopup;
|
||||
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {
|
||||
|
@ -71,11 +67,7 @@ add_task(async function() {
|
|||
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
|
||||
);
|
||||
});
|
||||
let textBox = document.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"moz-input-box"
|
||||
);
|
||||
let textBox = gURLBar.querySelector("moz-input-box");
|
||||
let cxmenu = textBox.menupopup;
|
||||
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {
|
||||
|
|
|
@ -31,12 +31,7 @@ add_task(async function() {
|
|||
await BrowserTestUtils.switchTab(gBrowser, tab1);
|
||||
// Now open the popup by the history marker.
|
||||
await UrlbarTestUtils.promisePopupOpen(window, () => {
|
||||
let historyDropMarker = window.document.getAnonymousElementByAttribute(
|
||||
gURLBar.textbox,
|
||||
"anonid",
|
||||
"historydropmarker"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(historyDropMarker, {}, window);
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.dropmarker, {}, window);
|
||||
});
|
||||
// Check that the popup closes when we switch tab.
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
|
|
|
@ -46,23 +46,18 @@ add_task(async function test_change_default_engine_updates_placeholder() {
|
|||
await Services.search.setDefault(extraEngine);
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() =>
|
||||
gURLBar.getAttribute("placeholder") ==
|
||||
gURLBar.getAttribute("defaultPlaceholder"),
|
||||
() => gURLBar.placeholder == gURLBar.getAttribute("defaultPlaceholder"),
|
||||
"The placeholder should match the default placeholder for non-built-in engines."
|
||||
);
|
||||
Assert.equal(
|
||||
gURLBar.getAttribute("placeholder"),
|
||||
gURLBar.getAttribute("defaultPlaceholder")
|
||||
);
|
||||
Assert.equal(gURLBar.placeholder, gURLBar.getAttribute("defaultPlaceholder"));
|
||||
|
||||
await Services.search.setDefault(originalEngine);
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => gURLBar.getAttribute("placeholder") == expectedString,
|
||||
() => gURLBar.placeholder == expectedString,
|
||||
"The placeholder should include the engine name for built-in engines."
|
||||
);
|
||||
Assert.equal(gURLBar.getAttribute("placeholder"), expectedString);
|
||||
Assert.equal(gURLBar.placeholder, expectedString);
|
||||
});
|
||||
|
||||
add_task(async function test_delayed_update_placeholder() {
|
||||
|
@ -82,7 +77,7 @@ add_task(async function test_delayed_update_placeholder() {
|
|||
BrowserSearch._updateURLBarPlaceholder(extraEngine.name, true);
|
||||
|
||||
Assert.equal(
|
||||
gURLBar.getAttribute("placeholder"),
|
||||
gURLBar.placeholder,
|
||||
expectedString,
|
||||
"Placeholder should be unchanged."
|
||||
);
|
||||
|
@ -91,9 +86,7 @@ add_task(async function test_delayed_update_placeholder() {
|
|||
await BrowserTestUtils.switchTab(gBrowser, urlTab);
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() =>
|
||||
gURLBar.getAttribute("placeholder") ==
|
||||
gURLBar.getAttribute("defaultPlaceholder"),
|
||||
() => gURLBar.placeholder == gURLBar.getAttribute("defaultPlaceholder"),
|
||||
"The placeholder should have updated in the background."
|
||||
);
|
||||
|
||||
|
@ -104,7 +97,7 @@ add_task(async function test_delayed_update_placeholder() {
|
|||
await TestUtils.waitForTick();
|
||||
|
||||
Assert.equal(
|
||||
gURLBar.getAttribute("placeholder"),
|
||||
gURLBar.placeholder,
|
||||
gURLBar.getAttribute("defaultPlaceholder"),
|
||||
"Placeholder should be unchanged."
|
||||
);
|
||||
|
@ -112,7 +105,7 @@ add_task(async function test_delayed_update_placeholder() {
|
|||
await BrowserTestUtils.switchTab(gBrowser, urlTab);
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => gURLBar.getAttribute("placeholder") == expectedString,
|
||||
() => gURLBar.placeholder == expectedString,
|
||||
"The placeholder should include the engine name for built-in engines."
|
||||
);
|
||||
|
||||
|
@ -121,7 +114,7 @@ add_task(async function test_delayed_update_placeholder() {
|
|||
await TestUtils.waitForTick();
|
||||
|
||||
Assert.equal(
|
||||
gURLBar.getAttribute("placeholder"),
|
||||
gURLBar.placeholder,
|
||||
gURLBar.getAttribute("defaultPlaceholder"),
|
||||
"Placeholder should be the default."
|
||||
);
|
||||
|
|
|
@ -316,24 +316,18 @@
|
|||
height: 30px;
|
||||
}
|
||||
|
||||
.urlbar-icon:not([disabled]):hover,
|
||||
:not(.urlbar-icon-wrapper) > .urlbar-icon:not([disabled]):hover,
|
||||
.urlbar-icon-wrapper:not([disabled]):hover {
|
||||
background-color: hsla(0,0%,70%,.2);
|
||||
}
|
||||
|
||||
.urlbar-icon[open],
|
||||
.urlbar-icon-wrapper[open],
|
||||
.urlbar-icon:not([disabled]):hover:active,
|
||||
.urlbar-icon-wrapper:hover:active {
|
||||
: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 {
|
||||
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);
|
||||
|
@ -356,15 +350,6 @@
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ add_task(async function() {
|
|||
}
|
||||
|
||||
// Focus chrome
|
||||
document.getElementById("urlbar").focus();
|
||||
gURLBar.focus();
|
||||
let originalFocus = Services.focus.focusedElement;
|
||||
|
||||
// Load about:blank just to make sure that everything works nicely
|
||||
|
|
|
@ -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.
|
||||
document.getElementById("urlbar").focus();
|
||||
gURLBar.focus();
|
||||
|
||||
is(
|
||||
fm.focusedElement,
|
||||
document.getElementById("urlbar").inputField,
|
||||
gURLBar.inputField,
|
||||
"Failed to move focus to search bar: button=" + button
|
||||
);
|
||||
|
||||
|
@ -31,7 +31,7 @@ add_task(async function test() {
|
|||
|
||||
isnot(
|
||||
fm.focusedElement,
|
||||
document.getElementById("urlbar").inputField,
|
||||
gURLBar.inputField,
|
||||
"Failed to move focus away from search bar: button=" + button
|
||||
);
|
||||
|
||||
|
|
|
@ -95,17 +95,11 @@ 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:
|
||||
|
|
|
@ -90,11 +90,6 @@ 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.
|
||||
|
@ -103,16 +98,6 @@ 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.
|
||||
|
@ -147,27 +132,6 @@ 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.
|
||||
|
@ -279,7 +243,7 @@ class LocationBar(UIBaseLib):
|
|||
|
||||
:returns: Reference to the urlbar input.
|
||||
"""
|
||||
return self.urlbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'input'})
|
||||
return self.urlbar.find_element(By.CLASS_NAME, 'urlbar-input')
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
|
@ -287,7 +251,7 @@ class LocationBar(UIBaseLib):
|
|||
|
||||
:returns: The urlbar value.
|
||||
"""
|
||||
return self.urlbar.get_property('value')
|
||||
return self.urlbar_input.get_property('value')
|
||||
|
||||
|
||||
class AutocompleteResults(UIBaseLib):
|
||||
|
|
|
@ -29,10 +29,9 @@ add_task(async function test_support_selection() {
|
|||
});
|
||||
|
||||
await extension.startup();
|
||||
let urlBar = document.querySelector("#urlbar");
|
||||
|
||||
let fields = [
|
||||
document.getAnonymousElementByAttribute(urlBar, "anonid", "input"),
|
||||
gURLBar.inputField,
|
||||
document.querySelector("#searchbar .searchbar-textbox"),
|
||||
].filter(field => {
|
||||
let bounds = field.getBoundingClientRect();
|
||||
|
|
|
@ -77,18 +77,6 @@ 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"),
|
||||
|
@ -103,11 +91,7 @@ add_task(async function test_backButton_forwardButton() {
|
|||
// Now go forward again after filling
|
||||
await fillTestPage(aBrowser);
|
||||
|
||||
if (forwardTransitionPromise) {
|
||||
await forwardTransitionPromise;
|
||||
info("transition done");
|
||||
}
|
||||
|
||||
let forwardButton = document.getElementById("forward-button");
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
return !forwardButton.disabled;
|
||||
});
|
||||
|
|
|
@ -74,6 +74,7 @@ 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']"));
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
this.menupopup = this.querySelector(".textbox-contextmenu");
|
||||
|
||||
this.menupopup.addEventListener("popupshowing", event => {
|
||||
var input = this.getElementsByAttribute("anonid", "input")[0];
|
||||
let input = this._input;
|
||||
if (document.commandDispatcher.focusedElement != input) {
|
||||
input.focus();
|
||||
}
|
||||
|
@ -196,18 +196,13 @@
|
|||
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(
|
||||
textbox.editor
|
||||
this._input.editor
|
||||
);
|
||||
} catch (ex) {}
|
||||
}
|
||||
|
@ -229,6 +224,13 @@
|
|||
);
|
||||
controller.doCommand(command);
|
||||
}
|
||||
|
||||
get _input() {
|
||||
return (
|
||||
this.getElementsByAttribute("anonid", "input")[0] ||
|
||||
this.querySelector(".textbox-input")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("moz-input-box", MozInputBox);
|
||||
|
|
Загрузка…
Ссылка в новой задаче