mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 1460097 - Autocompleted URLs are trimmed. r=mak
MozReview-Commit-ID: 6y26a9Nhm3b --HG-- extra : rebase_source : 7b56edf0185f4d15e989d6f71b259eae16c4e099
This commit is contained in:
parent
2bc18183da
commit
93f19f1f25
@ -36,3 +36,32 @@ add_task(async function() {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
const url = "http://example.com/4\u2028";
|
||||
await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
|
||||
gURLBar.focus();
|
||||
await new Promise((resolve, reject) => {
|
||||
waitForClipboard(url, function() {
|
||||
clipboardHelper.copyString(url);
|
||||
}, resolve,
|
||||
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
|
||||
);
|
||||
});
|
||||
let textBox = document.getAnonymousElementByAttribute(gURLBar,
|
||||
"anonid", "textbox-input-box");
|
||||
let cxmenu = document.getAnonymousElementByAttribute(textBox,
|
||||
"anonid", "input-box-contextmenu");
|
||||
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar, {type: "contextmenu", button: 2});
|
||||
await cxmenuPromise;
|
||||
let menuitem = document.getAnonymousElementByAttribute(textBox,
|
||||
"anonid", "paste-and-go");
|
||||
let browserLoadedPromise = BrowserTestUtils.browserLoaded(browser, false, url.replace(/\u2028/g, ""));
|
||||
EventUtils.synthesizeMouseAtCenter(menuitem, {});
|
||||
// Using toSource in order to get the newlines escaped:
|
||||
info("Paste and go, loading " + url.toSource());
|
||||
await browserLoadedPromise;
|
||||
ok(true, "Successfully loaded " + url);
|
||||
});
|
||||
});
|
||||
|
@ -791,6 +791,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
// set value and try to confirm it. UnifiedComplete should always
|
||||
// resolve to a valid url.
|
||||
try {
|
||||
url = url.trim();
|
||||
new URL(url);
|
||||
} catch (ex) {
|
||||
let lastLocationChange = browser.lastLocationChange;
|
||||
|
@ -1757,18 +1757,19 @@ Search.prototype = {
|
||||
let flags = Ci.nsIURIFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS |
|
||||
Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
|
||||
let fixupInfo = null;
|
||||
let searchUrl = this._trimmedOriginalSearchString;
|
||||
try {
|
||||
fixupInfo = Services.uriFixup.getFixupURIInfo(this._originalSearchString,
|
||||
fixupInfo = Services.uriFixup.getFixupURIInfo(searchUrl,
|
||||
flags);
|
||||
} catch (e) {
|
||||
if (e.result == Cr.NS_ERROR_MALFORMED_URI && !Prefs.get("keyword.enabled")) {
|
||||
let value = PlacesUtils.mozActionURI("visiturl", {
|
||||
url: this._originalSearchString,
|
||||
input: this._originalSearchString,
|
||||
url: searchUrl,
|
||||
input: searchUrl,
|
||||
});
|
||||
this._addMatch({
|
||||
value,
|
||||
comment: this._originalSearchString,
|
||||
comment: searchUrl,
|
||||
style: "action visiturl",
|
||||
frecency: Infinity
|
||||
});
|
||||
@ -1805,7 +1806,7 @@ Search.prototype = {
|
||||
|
||||
let value = PlacesUtils.mozActionURI("visiturl", {
|
||||
url: escapedURL,
|
||||
input: this._originalSearchString,
|
||||
input: searchUrl,
|
||||
});
|
||||
|
||||
let match = {
|
||||
@ -1822,7 +1823,7 @@ Search.prototype = {
|
||||
// By default we won't provide an icon, but for the subset of urls with a
|
||||
// host we'll check for a typed slash and set favicon for the host part.
|
||||
if (hostExpected &&
|
||||
(this._trimmedOriginalSearchString.endsWith("/") || uri.pathQueryRef.length > 1)) {
|
||||
(searchUrl.endsWith("/") || uri.pathQueryRef.length > 1)) {
|
||||
match.icon = `page-icon:${uri.prePath}/`;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,17 @@ add_task(async function() {
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "about:config", input: "about:config"}), title: "about:config", style: [ "action", "visiturl", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
info("visit url, with non-standard whitespace");
|
||||
await check_autocomplete({
|
||||
search: "https://www.mozilla.org\u2028",
|
||||
searchParam: "enable-actions",
|
||||
matches: [{
|
||||
uri: makeActionURI("visiturl", {url: "https://www.mozilla.org/",
|
||||
input: "https://www.mozilla.org"}),
|
||||
title: "https://www.mozilla.org/",
|
||||
style: [ "action", "visiturl", "heuristic" ]}]
|
||||
});
|
||||
|
||||
// This is distinct because of how we predict being able to url autofill via
|
||||
// host lookups.
|
||||
info("visit url, host matching visited host but not visited url");
|
||||
|
Loading…
Reference in New Issue
Block a user