Backed out changeset 742dfaf7631d (bug 1355451) for eslint failure at urlbarBindings.xml:2331: multiple spaces before elt. r=backout

This commit is contained in:
Sebastian Hengst 2017-08-03 16:08:48 +02:00
Родитель 03f7131602
Коммит 17cc85402f
6 изменённых файлов: 27 добавлений и 136 удалений

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

@ -115,7 +115,6 @@ support-files =
support-files =
searchSuggestionEngine2.xml
searchSuggestionEngine.sjs
[browser_urlbar_search_speculative_connect_mousedown.js]
[browser_urlbar_stop_pending.js]
support-files =
slow-page.sjs

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

@ -7,6 +7,7 @@
// This test ensures that we setup a speculative network
// connection for autoFilled values.
let {HttpServer} = Cu.import("resource://testing-common/httpd.js", {});
let gHttpServer = null;
let gScheme = "http";
let gHost = "localhost"; // 'localhost' by default.
@ -15,13 +16,21 @@ let gPrivateWin = null;
let gIsSpeculativeConnected = false;
add_task(async function setup() {
gHttpServer = runHttpServer(gScheme, gHost);
// The server will be run on a random port if the port number wasn't given.
gPort = gHttpServer.identity.primaryPort;
if (!gHttpServer) {
gHttpServer = new HttpServer();
try {
gHttpServer.start(gPort);
gPort = gHttpServer.identity.primaryPort;
gHttpServer.identity.setPrimary(gScheme, gHost, gPort);
} catch (ex) {
info("We can't launch our http server successfully.")
}
}
is(gHttpServer.identity.has(gScheme, gHost, gPort), true, "make sure we have this domain listed");
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.autoFill", true],
// Turn off search suggestion so we won't speculative connect to the search engine.
// Turn off speculative connect to the search engine.
["browser.search.suggest.enabled", false],
["browser.urlbar.speculativeConnect.enabled", true],
// In mochitest this number is 0 by default but we have to turn it on.
@ -41,7 +50,7 @@ add_task(async function setup() {
is(PrivateBrowsingUtils.isWindowPrivate(gPrivateWin), true, "A private window created.");
// Bug 764062 - we can't get port number from autocomplete result, so we have to mock
// this function and add it manually.
// this function to add it manually.
let oldSpeculativeConnect = gURLBar.popup.maybeSetupSpeculativeConnect.bind(gURLBar.popup);
let newSpeculativeConnect = (uriString) => {
gIsSpeculativeConnected = true;

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

@ -7,6 +7,7 @@
// This test ensures that we setup a speculative network connection to
// current search engine if the first result is 'searchengine'.
let {HttpServer} = Cu.import("resource://testing-common/httpd.js", {});
let gHttpServer = null;
let gScheme = "http";
let gHost = "localhost"; // 'localhost' by default.
@ -14,11 +15,21 @@ let gPort = 20709; // the port number must be identical to what we said in searc
const TEST_ENGINE_BASENAME = "searchSuggestionEngine2.xml";
add_task(async function setup() {
gHttpServer = runHttpServer(gScheme, gHost, gPort);
if (!gHttpServer) {
gHttpServer = new HttpServer();
try {
gHttpServer.start(gPort);
gPort = gHttpServer.identity.primaryPort;
gHttpServer.identity.setPrimary(gScheme, gHost, gPort);
} catch (ex) {
info("We can't launch our http server successfully.")
}
}
is(gHttpServer.identity.has(gScheme, gHost, gPort), true, "make sure we have this domain listed");
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.autoFill", true],
// Make sure search suggestion for location bar is enabled
// Turn off speculative connect to the search engine.
["browser.search.suggest.enabled", true],
["browser.urlbar.suggest.searches", true],
["browser.urlbar.speculativeConnect.enabled", true],

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

@ -1,67 +0,0 @@
/* 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/. */
"use strict";
// This test ensures that we setup a speculative network connection to
// the site in mousedown event before the http request happens(in mouseup).
let gHttpServer = null;
let gScheme = "http";
let gHost = "localhost"; // 'localhost' by default.
let gPort = -1;
let gIsSpeculativeConnected = false;
add_task(async function setup() {
gHttpServer = runHttpServer(gScheme, gHost, gPort);
// The server will be run on a random port if the port number wasn't given.
gPort = gHttpServer.identity.primaryPort;
await PlacesTestUtils.addVisits([{
uri: `${gScheme}://${gHost}:${gPort}`,
title: "test visit for speculative connection",
transition: Ci.nsINavHistoryService.TRANSITION_TYPED,
}]);
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.autoFill", true],
// Turn off search suggestion so we won't speculative connect to the search engine.
["browser.search.suggest.enabled", false],
["browser.urlbar.speculativeConnect.enabled", true],
// In mochitest this number is 0 by default but we have to turn it on.
["network.http.speculative-parallel-limit", 6],
// The http server is using IPv4, so it's better to disable IPv6 to avoid weird
// networking problem.
["network.dns.disableIPv6", true]],
});
registerCleanupFunction(async function() {
await PlacesUtils.history.clear();
gHttpServer.identity.remove(gScheme, gHost, gPort);
gHttpServer.stop(() => {
gHttpServer = null;
});
});
});
add_task(async function autofill_tests() {
const test = {
// To not trigger autofill, search keyword starts from the second character.
search: gHost.substr(1, 4),
completeValue: `${gScheme}://${gHost}:${gPort}/`
};
info(`Searching for '${test.search}'`);
await promiseAutocompleteResultPopup(test.search, window, true);
// Check if the first result is with type "searchengine"
let controller = gURLBar.popup.input.controller;
// The first item should be 'Search with ...' thus we wan the second.
let value = controller.getFinalCompleteValueAt(1);
info(`The value of the second item is ${value}`);
is(value, test.completeValue, "The second item has the url we visited.");
let listitem = gURLBar.popup.richlistbox.childNodes[1];
EventUtils.synthesizeMouse(listitem, 10, 10, {type: "mousedown"}, window);
is(gURLBar.popup.richlistbox.selectedIndex, 1, "The second item is selected");
await promiseSpeculativeConnection(gHttpServer);
});

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

@ -8,8 +8,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
"resource://gre/modules/Preferences.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "HttpServer",
"resource://testing-common/httpd.js");
/**
* Waits for the next top-level document load in the current browser. The URI
@ -131,19 +129,6 @@ function is_element_hidden(element, msg) {
ok(is_hidden(element), msg || "Element should be hidden");
}
function runHttpServer(scheme, host, port = -1) {
let httpserver = new HttpServer();
try {
httpserver.start(port);
port = httpserver.identity.primaryPort;
httpserver.identity.setPrimary(scheme, host, port);
} catch (ex) {
info("We can't launch our http server successfully.")
}
is(httpserver.identity.has(scheme, host, port), true, `${scheme}://${host}:${port} is listening.`);
return httpserver;
}
function promisePopupEvent(popup, eventSuffix) {
let endState = {shown: "open", hidden: "closed"}[eventSuffix];

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

@ -2317,52 +2317,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// browser-search-autocomplete-result-popup, which apparently had a
// similar problem.
event.preventDefault();
if (!this.input.speculativeConnectEnabled) {
return;
}
if (event.button == 2) {
// Ignore right-clicks.
return;
}
// Ensure the user is clicking on an url instead of other buttons
// on the popup.
let elt = event.originalTarget;
while (elt && elt.localName != "richlistitem" && elt != this) {
elt = elt.parentNode;
}
if (!elt || elt.localName != "richlistitem") {
return;
}
// The user might click on a ghost entry which was removed because of
// the coming new results.
if (this.input.controller.matchCount <= this.selectedIndex) {
return;
}
let url = this.input.controller.getFinalCompleteValueAt(this.selectedIndex);
// Whitelist the cases that we want to speculative connect, and ignore
// other moz-action uris or fancy protocols.
// Note that it's likely we've speculatively connected to the first
// url because it is a heuristic "autofill" result (see bug 1348275).
// "moz-action:searchengine" is also the same case. (see bug 1355443)
// So we won't duplicate the effort here.
if (url.startsWith("http") && this.selectedIndex > 0) {
this.maybeSetupSpeculativeConnect(url);
} else if (url.startsWith("moz-action:remotetab")) {
// URL is in the format moz-action:ACTION,PARAMS
// Where PARAMS is a JSON encoded object.
const MOZ_ACTION_REGEX = /^moz-action:([^,]+),(.*)$/;
if (!MOZ_ACTION_REGEX.test(url))
return;
let params = JSON.parse(url.match(MOZ_ACTION_REGEX)[2]);
if (params.url) {
this.maybeSetupSpeculativeConnect(decodeURIComponent(params.url));
}
}
]]></handler>
</handlers>