зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 7768b6a6cfc7 (bug 1568959) for ESlint failures CLOSED TREE
This commit is contained in:
Родитель
78c513784e
Коммит
2a4fcddae1
|
@ -191,15 +191,9 @@ class SearchOneOffs {
|
|||
* @param {UrlbarView} val
|
||||
*/
|
||||
set view(val) {
|
||||
if (this._view) {
|
||||
this._view.controller.removeQueryListener(this);
|
||||
}
|
||||
this._view = val;
|
||||
if (val) {
|
||||
if (val.isOpen) {
|
||||
this._rebuild();
|
||||
}
|
||||
val.controller.addQueryListener(this);
|
||||
if (val && val.isOpen) {
|
||||
this._rebuild();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1377,10 +1371,6 @@ class SearchOneOffs {
|
|||
_on_popupshowing() {
|
||||
this._rebuild();
|
||||
}
|
||||
|
||||
onViewOpen() {
|
||||
this._rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
window.SearchOneOffs = SearchOneOffs;
|
||||
|
|
|
@ -22,21 +22,12 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
|
||||
const TELEMETRY_1ST_RESULT = "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS";
|
||||
const TELEMETRY_6_FIRST_RESULTS = "PLACES_AUTOCOMPLETE_6_FIRST_RESULTS_TIME_MS";
|
||||
const NOTIFICATIONS = {
|
||||
QUERY_STARTED: "onQueryStarted",
|
||||
QUERY_RESULTS: "onQueryResults",
|
||||
QUERY_RESULT_REMOVED: "onQueryResultRemoved",
|
||||
QUERY_CANCELLED: "onQueryCancelled",
|
||||
QUERY_FINISHED: "onQueryFinished",
|
||||
VIEW_OPEN: "onViewOpen",
|
||||
VIEW_CLOSE: "onViewClose",
|
||||
};
|
||||
|
||||
/**
|
||||
* The address bar controller handles queries from the address bar, obtains
|
||||
* results and returns them to the UI for display.
|
||||
*
|
||||
* Listeners may be added to listen for the results. They may support the
|
||||
* Listeners may be added to listen for the results. They must support the
|
||||
* following methods which may be called when a query is run:
|
||||
*
|
||||
* - onQueryStarted(queryContext)
|
||||
|
@ -44,8 +35,6 @@ const NOTIFICATIONS = {
|
|||
* - onQueryCancelled(queryContext)
|
||||
* - onQueryFinished(queryContext)
|
||||
* - onQueryResultRemoved(index)
|
||||
* - onViewOpen()
|
||||
* - onViewClose()
|
||||
*/
|
||||
class UrlbarController {
|
||||
/**
|
||||
|
@ -80,10 +69,6 @@ class UrlbarController {
|
|||
this.engagementEvent = new TelemetryEvent(options.eventTelemetryCategory);
|
||||
}
|
||||
|
||||
get NOTIFICATIONS() {
|
||||
return NOTIFICATIONS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks up the controller with an input.
|
||||
*
|
||||
|
@ -128,7 +113,7 @@ class UrlbarController {
|
|||
// For proper functionality we must ensure this notification is fired
|
||||
// synchronously, as soon as startQuery is invoked, but after any
|
||||
// notifications related to the previous query.
|
||||
this.notify(NOTIFICATIONS.QUERY_STARTED, queryContext);
|
||||
this._notify("onQueryStarted", queryContext);
|
||||
await this.manager.startQuery(queryContext, this);
|
||||
// If the query has been cancelled, onQueryFinished was notified already.
|
||||
// Note this._lastQueryContextWrapper may have changed in the meanwhile.
|
||||
|
@ -139,7 +124,7 @@ class UrlbarController {
|
|||
contextWrapper.done = true;
|
||||
// TODO (Bug 1549936) this is necessary to avoid leaks in PB tests.
|
||||
this.manager.cancelQuery(queryContext);
|
||||
this.notify(NOTIFICATIONS.QUERY_FINISHED, queryContext);
|
||||
this._notify("onQueryFinished", queryContext);
|
||||
}
|
||||
return queryContext;
|
||||
}
|
||||
|
@ -160,8 +145,8 @@ class UrlbarController {
|
|||
TelemetryStopwatch.cancel(TELEMETRY_1ST_RESULT, queryContext);
|
||||
TelemetryStopwatch.cancel(TELEMETRY_6_FIRST_RESULTS, queryContext);
|
||||
this.manager.cancelQuery(queryContext);
|
||||
this.notify(NOTIFICATIONS.QUERY_CANCELLED, queryContext);
|
||||
this.notify(NOTIFICATIONS.QUERY_FINISHED, queryContext);
|
||||
this._notify("onQueryCancelled", queryContext);
|
||||
this._notify("onQueryFinished", queryContext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +175,7 @@ class UrlbarController {
|
|||
);
|
||||
}
|
||||
|
||||
this.notify(NOTIFICATIONS.QUERY_RESULTS, queryContext);
|
||||
this._notify("onQueryResults", queryContext);
|
||||
// Update lastResultCount after notifying, so the view can use it.
|
||||
queryContext.lastResultCount = queryContext.results.length;
|
||||
}
|
||||
|
@ -225,6 +210,7 @@ class UrlbarController {
|
|||
*/
|
||||
viewContextChanged() {
|
||||
this.cancelQuery();
|
||||
this._notify("onViewContextChanged");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -575,7 +561,7 @@ class UrlbarController {
|
|||
}
|
||||
|
||||
queryContext.results.splice(index, 1);
|
||||
this.notify(NOTIFICATIONS.QUERY_RESULT_REMOVED, index);
|
||||
this._notify("onQueryResultRemoved", index);
|
||||
|
||||
PlacesUtils.history
|
||||
.remove(selectedResult.payload.url)
|
||||
|
@ -584,12 +570,12 @@ class UrlbarController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notifies listeners of results.
|
||||
* Internal function to notify listeners of results.
|
||||
*
|
||||
* @param {string} name Name of the notification.
|
||||
* @param {object} params Parameters to pass with the notification.
|
||||
*/
|
||||
notify(name, ...params) {
|
||||
_notify(name, ...params) {
|
||||
for (let listener of this._listeners) {
|
||||
// Can't use "in" because some tests proxify these.
|
||||
if (typeof listener[name] != "undefined") {
|
||||
|
|
|
@ -200,9 +200,6 @@ class UrlbarView {
|
|||
* Closes the view, cancelling the query if necessary.
|
||||
*/
|
||||
close() {
|
||||
if (!this.isOpen) {
|
||||
return;
|
||||
}
|
||||
this.controller.cancelQuery();
|
||||
this.panel.setAttribute("hidden", "true");
|
||||
this.removeAccessibleFocus();
|
||||
|
@ -213,7 +210,6 @@ class UrlbarView {
|
|||
this.window.removeEventListener("mousedown", this);
|
||||
this.panel.removeEventListener("mousedown", this);
|
||||
this.input.textbox.removeEventListener("mousedown", this);
|
||||
this.controller.notify(this.controller.NOTIFICATIONS.VIEW_CLOSE);
|
||||
}
|
||||
|
||||
// UrlbarController listener methods.
|
||||
|
@ -402,14 +398,16 @@ class UrlbarView {
|
|||
this.input.inputField.setAttribute("aria-expanded", "true");
|
||||
this.input.dropmarker.setAttribute("open", "true");
|
||||
|
||||
if (this.oneOffSearchButtons.style.display != "none") {
|
||||
this.oneOffSearchButtons._rebuild();
|
||||
}
|
||||
|
||||
this.window.addEventListener("mousedown", this);
|
||||
this.panel.addEventListener("mousedown", this);
|
||||
this.input.textbox.addEventListener("mousedown", this);
|
||||
|
||||
this.window.addEventListener("resize", this);
|
||||
this._windowOuterWidth = this.window.outerWidth;
|
||||
|
||||
this.controller.notify(this.controller.NOTIFICATIONS.VIEW_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -331,10 +331,9 @@ Represents the base *View* implementation, communicates with the *Controller*.
|
|||
// Invoked when the query is done. This is invoked in any case, even if the
|
||||
// query was canceled earlier.
|
||||
onQueryFinished(queryContext);
|
||||
// Invoked when the view opens.
|
||||
onViewOpen();
|
||||
// Invoked when the view closes.
|
||||
onViewClose();
|
||||
// Invoked when the view context changed, so that cached information about
|
||||
// the latest search is no more relevant and can be dropped.
|
||||
onViewContextChanged();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ var UrlbarTestUtils = {
|
|||
* @returns {Promise} Resolved when done.
|
||||
*/
|
||||
async promiseSearchComplete(win) {
|
||||
return this.promisePopupOpen(win, () => {}).then(
|
||||
() => win.gURLBar.lastQueryContextPromise
|
||||
);
|
||||
return BrowserTestUtils.waitForCondition(
|
||||
() => win.gURLBar.view.isOpen
|
||||
).then(() => win.gURLBar.lastQueryContextPromise);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -256,17 +256,7 @@ var UrlbarTestUtils = {
|
|||
throw new Error("openFn should be supplied to promisePopupOpen");
|
||||
}
|
||||
await openFn();
|
||||
if (win.gURLBar.view.isOpen) {
|
||||
return;
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
win.gURLBar.controller.addQueryListener({
|
||||
onViewOpen() {
|
||||
win.gURLBar.controller.removeQueryListener(this);
|
||||
resolve();
|
||||
},
|
||||
});
|
||||
});
|
||||
return BrowserTestUtils.waitForCondition(() => win.gURLBar.view.isOpen);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -282,17 +272,7 @@ var UrlbarTestUtils = {
|
|||
} else {
|
||||
win.gURLBar.view.close();
|
||||
}
|
||||
if (!win.gURLBar.view.isOpen) {
|
||||
return;
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
win.gURLBar.controller.addQueryListener({
|
||||
onViewClose() {
|
||||
win.gURLBar.controller.removeQueryListener(this);
|
||||
resolve();
|
||||
},
|
||||
});
|
||||
});
|
||||
return BrowserTestUtils.waitForCondition(() => !win.gURLBar.view.isOpen);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче