зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1524536 - Port some tests to QuantumBar (Search Engine results, a11y label, autoselect, tab switch reset). r=mak
This starts porting other tests to work with QuantumBar and starts expanding UrlbarTestUtils.jsm with more helper functions. For the tests, I'm generally using replacing with UrlbarTestUtils except for promiseAutocompleteResultPopup/promiseSearchComplete. These functions feel like they need a more in-depth change (bug 1522902), but probably not until we can remove the old bar. browser_autocomplete_a11y_label.js and browser_autocomplete_autoselect.js are partially ported, but won't run on QuantumBar yet due to missing functionality. Depends on D18262 Differential Revision: https://phabricator.services.mozilla.com/D18338 --HG-- rename : browser/components/urlbar/tests/legacy/browser_action_searchengine.js => browser/components/urlbar/tests/browser/browser_action_searchengine.js rename : browser/components/urlbar/tests/legacy/browser_action_searchengine_alias.js => browser/components/urlbar/tests/browser/browser_action_searchengine_alias.js rename : browser/components/urlbar/tests/legacy/browser_autocomplete_edit_completed.js => browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js rename : browser/components/urlbar/tests/legacy/browser_new_tab_urlbar_reset.js => browser/components/urlbar/tests/browser/browser_new_tab_urlbar_reset.js rename : browser/components/urlbar/tests/legacy/browser_urlbar_remove_match.js => browser/components/urlbar/tests/browser/browser_urlbar_remove_match.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
c8d8aee4ef
Коммит
38d03bf5ca
|
@ -101,6 +101,12 @@ var UrlbarUtils = {
|
|||
OTHER_NETWORK: 6,
|
||||
},
|
||||
|
||||
// This defines icon locations that are common used in the UI.
|
||||
ICON: {
|
||||
DEFAULT: Ci.nsIFaviconService.FAVICON_DEFAULT_URL,
|
||||
SEARCH_GLASS: "chrome://browser/skin/search-glass.svg",
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a url to history as long as it isn't in a private browsing window,
|
||||
* and it is valid.
|
||||
|
|
|
@ -286,9 +286,9 @@ class UrlbarView {
|
|||
favicon.className = "urlbarView-favicon";
|
||||
if (result.type == UrlbarUtils.RESULT_TYPE.SEARCH ||
|
||||
result.type == UrlbarUtils.RESULT_TYPE.KEYWORD) {
|
||||
favicon.src = "chrome://browser/skin/search-glass.svg";
|
||||
favicon.src = UrlbarUtils.ICON.SEARCH_GLASS;
|
||||
} else {
|
||||
favicon.src = result.payload.icon || "chrome://mozapps/skin/places/defaultFavicon.svg";
|
||||
favicon.src = result.payload.icon || UrlbarUtils.ICON.DEFAULT;
|
||||
}
|
||||
content.appendChild(favicon);
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ var UrlbarTestUtils = {
|
|||
|
||||
/**
|
||||
* Starts a search for a given string and waits for the search to be complete.
|
||||
* @param {string} inputText the search string
|
||||
* @param {object} win The window containing the urlbar
|
||||
* @param {string} inputText the search string
|
||||
* @param {function} waitForFocus The Simpletest function
|
||||
* @param {boolean} fireInputEvent whether an input event should be used when
|
||||
* starting the query (necessary to set userTypedValued)
|
||||
*/
|
||||
async promiseAutocompleteResultPopup(inputText, win, waitForFocus, fireInputEvent = false) {
|
||||
async promiseAutocompleteResultPopup(win, inputText, waitForFocus, fireInputEvent = false) {
|
||||
let urlbar = getUrlbarAbstraction(win);
|
||||
let restoreAnimationsFn = urlbar.disableAnimations();
|
||||
await new Promise(resolve => waitForFocus(resolve, win));
|
||||
|
@ -91,6 +91,16 @@ var UrlbarTestUtils = {
|
|||
return urlbar.getSelectedElement();
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the index of the currently selected item.
|
||||
* @param {object} win The window containing the urlbar.
|
||||
* @returns {number} The selected index.
|
||||
*/
|
||||
getSelectedIndex(win) {
|
||||
let urlbar = getUrlbarAbstraction(win);
|
||||
return urlbar.getSelectedIndex();
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the number of results.
|
||||
* You must wait for the query to be complete before using this.
|
||||
|
@ -127,6 +137,18 @@ var UrlbarTestUtils = {
|
|||
"Waiting for speculative connection setup"
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Waits for the popup to be hidden.
|
||||
* @param {object} win The window containing the urlbar
|
||||
* @param {function} [closeFn] Function to be used to close the popup, if not
|
||||
* supplied it will default to a closing the popup directly.
|
||||
* @returns {Promise} resolved once the popup is closed
|
||||
*/
|
||||
promisePopupClose(win, closeFn = null) {
|
||||
let urlbar = getUrlbarAbstraction(win);
|
||||
return urlbar.promisePopupClose(closeFn);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -252,13 +274,21 @@ class UrlbarAbstraction {
|
|||
this.panel.richlistbox.itemChildren[this.panel.selectedIndex] : null;
|
||||
}
|
||||
|
||||
getSelectedIndex() {
|
||||
if (!this.quantumbar) {
|
||||
return this.panel.selectedIndex;
|
||||
}
|
||||
|
||||
return parseInt(this.urlbar.view._selected.getAttribute("resultIndex"));
|
||||
}
|
||||
|
||||
getResultCount() {
|
||||
return this.quantumbar ? this.urlbar.view._rows.children.length
|
||||
: this.urlbar.controller.matchCount;
|
||||
}
|
||||
|
||||
async getDetailsOfResultAt(index) {
|
||||
await this.promiseResultAt(index);
|
||||
let element = await this.promiseResultAt(index);
|
||||
function getType(style, action) {
|
||||
if (style.includes("searchengine") || style.includes("suggestions")) {
|
||||
return UrlbarUtils.RESULT_TYPE.SEARCH;
|
||||
|
@ -279,12 +309,30 @@ class UrlbarAbstraction {
|
|||
details.url = (UrlbarUtils.getUrlFromResult(context.results[index])).url;
|
||||
details.type = context.results[index].type;
|
||||
details.autofill = index == 0 && context.autofillValue;
|
||||
details.image = element.getElementsByClassName("urlbarView-favicon")[0].src;
|
||||
if (details.type == UrlbarUtils.RESULT_TYPE.SEARCH) {
|
||||
details.searchParams = {
|
||||
engine: context.results[index].payload.engine,
|
||||
query: context.results[index].payload.query,
|
||||
suggestion: context.results[index].payload.suggestion,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
details.url = this.urlbar.controller.getFinalCompleteValueAt(index);
|
||||
let style = this.urlbar.controller.getStyleAt(index);
|
||||
let action = PlacesUtils.parseActionUrl(this.urlbar.controller.getValueAt(index));
|
||||
details.type = getType(style, action);
|
||||
details.autofill = style.includes("autofill");
|
||||
details.image = element.getAttribute("image");
|
||||
if (details.type == UrlbarUtils.RESULT_TYPE.SEARCH) {
|
||||
details.searchParams = {
|
||||
engine: action.params.engineName,
|
||||
query: action.params.input,
|
||||
suggestion: action.params.input == action.params.searchQuery ?
|
||||
undefined :
|
||||
action.params.searchQuery,
|
||||
};
|
||||
}
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
@ -317,4 +365,24 @@ class UrlbarAbstraction {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
closePopup() {
|
||||
if (this.quantumbar) {
|
||||
this.urlbar.view.close();
|
||||
} else {
|
||||
this.urlbar.popup.hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
promisePopupClose(closeFn) {
|
||||
if (closeFn) {
|
||||
closeFn();
|
||||
} else {
|
||||
this.closePopup();
|
||||
}
|
||||
if (!this.quantumbar) {
|
||||
return BrowserTestUtils.waitForPopupEvent(this.urlbar.popup, "hidden");
|
||||
}
|
||||
return BrowserTestUtils.waitForPopupEvent(this.urlbar.view.panel, "hidden");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,14 @@ support-files =
|
|||
head.js
|
||||
head-common.js
|
||||
|
||||
[browser_action_searchengine.js]
|
||||
[browser_action_searchengine_alias.js]
|
||||
[browser_autocomplete_edit_completed.js]
|
||||
[browser_canonizeURL.js]
|
||||
[browser_locationBarCommand.js]
|
||||
[browser_locationBarExternalLoad.js]
|
||||
[browser_moz_action_link.js]
|
||||
[browser_new_tab_urlbar_reset.js]
|
||||
[browser_populateAfterPushState.js]
|
||||
[browser_redirect_error.js]
|
||||
support-files = redirect_error.sjs
|
||||
|
@ -27,6 +31,7 @@ support-files =
|
|||
file_urlbar_edit_dos.html
|
||||
[browser_urlbar_remoteness_switch.js]
|
||||
run-if = e10s
|
||||
[browser_urlbar_remove_match.js]
|
||||
[browser_urlbar_searchsettings.js]
|
||||
[browser_urlbar_speculative_connect.js]
|
||||
support-files =
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests that a search result has the correct attributes and visits the
|
||||
* expected URL for the engine.
|
||||
*/
|
||||
|
||||
add_task(async function() {
|
||||
Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
|
||||
"http://example.com/?q={searchTerms}");
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
let originalEngine = Services.search.defaultEngine;
|
||||
Services.search.defaultEngine = engine;
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.defaultEngine = originalEngine;
|
||||
Services.search.removeEngine(engine);
|
||||
try {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
} catch (ex) { /* tab may have already been closed in case of failure */ }
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("open a search");
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
|
||||
|
||||
Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.SEARCH,
|
||||
"Should have type search");
|
||||
Assert.deepEqual(result.searchParams, {
|
||||
engine: "MozSearch",
|
||||
query: "open a search",
|
||||
suggestion: undefined,
|
||||
}, "Should have the correct result parameters.");
|
||||
|
||||
if (UrlbarPrefs.get("quantumbar")) {
|
||||
Assert.equal(result.image, UrlbarUtils.ICON.SEARCH_GLASS,
|
||||
"Should have the search icon image");
|
||||
} else {
|
||||
Assert.equal(result.image, "", "Should not have an image defined");
|
||||
}
|
||||
|
||||
let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
let element = await UrlbarTestUtils.waitForAutocompleteResultAt(window, 0);
|
||||
EventUtils.synthesizeMouseAtCenter(element, {}, window);
|
||||
await tabPromise;
|
||||
|
||||
Assert.equal(gBrowser.selectedBrowser.currentURI.spec,
|
||||
"http://example.com/?q=open+a+search", "Should have loaded the correct page");
|
||||
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
});
|
|
@ -0,0 +1,45 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests that search result obtained using a search keyword gives an entry with
|
||||
* the correct attributes and visits the expected URL for the engine.
|
||||
*/
|
||||
|
||||
add_task(async function() {
|
||||
const ICON_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
|
||||
Services.search.addEngineWithDetails("MozSearch", ICON_URI, "moz", "", "GET",
|
||||
"http://example.com/?q={searchTerms}");
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
let originalEngine = Services.search.defaultEngine;
|
||||
Services.search.defaultEngine = engine;
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.defaultEngine = originalEngine;
|
||||
Services.search.removeEngine(engine);
|
||||
try {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
} catch (ex) { /* tab may have already been closed in case of failure */ }
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("moz open a search");
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
|
||||
if (UrlbarPrefs.get("quantumbar")) {
|
||||
Assert.equal(result.image, UrlbarUtils.ICON.SEARCH_GLASS,
|
||||
"Should have the search icon image");
|
||||
} else {
|
||||
Assert.equal(result.image, ICON_URI, "Should have the correct image");
|
||||
}
|
||||
|
||||
let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await tabPromise;
|
||||
|
||||
Assert.equal(gBrowser.selectedBrowser.currentURI.spec,
|
||||
"http://example.com/?q=open+a+search", "Should have loaded the correct page");
|
||||
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
});
|
|
@ -1,3 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests selecting a result, and editing the value of that autocompleted result.
|
||||
*/
|
||||
|
||||
add_task(async function() {
|
||||
await PlacesUtils.history.clear();
|
||||
|
||||
|
@ -13,35 +20,36 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("http://example.com");
|
||||
await waitForAutocompleteResultAt(1);
|
||||
|
||||
let popup = gURLBar.popup;
|
||||
let list = popup.richlistbox;
|
||||
let initialIndex = list.selectedIndex;
|
||||
const initialIndex = UrlbarTestUtils.getSelectedIndex(window);
|
||||
|
||||
info("Key Down to select the next item.");
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
|
||||
let nextIndex = initialIndex + 1;
|
||||
let nextValue = gURLBar.controller.getFinalCompleteValueAt(nextIndex);
|
||||
is(list.selectedIndex, nextIndex, "The next item is selected.");
|
||||
is(gURLBar.value, nextValue, "The selected URL is completed.");
|
||||
let nextResult = await UrlbarTestUtils.getDetailsOfResultAt(window, nextIndex);
|
||||
Assert.equal(UrlbarTestUtils.getSelectedIndex(window), nextIndex,
|
||||
"Should have selected the next item");
|
||||
Assert.equal(gURLBar.value, nextResult.url,
|
||||
"Should have completed the URL");
|
||||
|
||||
info("Press backspace");
|
||||
EventUtils.synthesizeKey("KEY_Backspace");
|
||||
await promiseSearchComplete();
|
||||
|
||||
let editedValue = gURLBar.textValue;
|
||||
is(list.selectedIndex, initialIndex, "The initial index is selected again.");
|
||||
isnot(editedValue, nextValue, "The URL has changed.");
|
||||
Assert.equal(UrlbarTestUtils.getSelectedIndex(window), initialIndex,
|
||||
"Should have selected the initialIndex again");
|
||||
Assert.notEqual(editedValue, nextResult.url, "The URL has changed.");
|
||||
|
||||
let docLoad = BrowserTestUtils.waitForDocLoadAndStopIt("http://" + editedValue,
|
||||
gBrowser.selectedBrowser);
|
||||
|
||||
info("Press return to load edited URL.");
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await Promise.all([
|
||||
promisePopupHidden(gURLBar.popup),
|
||||
docLoad,
|
||||
]);
|
||||
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
});
|
||||
|
||||
await docLoad;
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Verify that urlbar state is reset when opening a new tab, so searching for the
|
||||
* same text will reopen the results popup.
|
||||
*/
|
||||
add_task(async function() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false);
|
||||
await promiseAutocompleteResultPopup("m");
|
||||
assertOpen();
|
||||
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false);
|
||||
await promiseAutocompleteResultPopup("m");
|
||||
assertOpen();
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
function assertOpen() {
|
||||
if (UrlbarPrefs.get("quantumbar")) {
|
||||
Assert.equal(gURLBar.view.panel.state, "open",
|
||||
"Should be showing the popup");
|
||||
} else {
|
||||
Assert.ok(gURLBar.popupOpen,
|
||||
"Should be showing the popup");
|
||||
}
|
||||
}
|
|
@ -13,20 +13,28 @@ add_task(async function test_remove_history() {
|
|||
"onDeleteURI", uri => uri.spec == TEST_URL, "history");
|
||||
|
||||
await promiseAutocompleteResultPopup("from_urlbar");
|
||||
let result = await waitForAutocompleteResultAt(1);
|
||||
Assert.equal(result.getAttribute("ac-value"), TEST_URL, "Found the expected result");
|
||||
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
|
||||
Assert.equal(result.url, TEST_URL, "Found the expected result");
|
||||
|
||||
let expectedResultCount = UrlbarTestUtils.getResultCount(window) - 1;
|
||||
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
Assert.equal(gURLBar.popup.richlistbox.selectedIndex, 1);
|
||||
Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 1);
|
||||
let options = AppConstants.platform == "macosx" ? { shiftKey: true } : {};
|
||||
EventUtils.synthesizeKey("KEY_Delete", options);
|
||||
await promiseVisitRemoved;
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => !gURLBar.popup.richlistbox.itemChildren.some(c => !c.collapsed && c.getAttribute("ac-value") == TEST_URL),
|
||||
await TestUtils.waitForCondition(
|
||||
() => UrlbarTestUtils.getResultCount(window) == expectedResultCount,
|
||||
"Waiting for the result to disappear");
|
||||
|
||||
gURLBar.popup.hidePopup();
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
for (let i = 0; i < expectedResultCount; i++) {
|
||||
let details = await UrlbarTestUtils.getDetailsOfResultAt(window, i);
|
||||
Assert.notEqual(details.url, TEST_URL,
|
||||
"Should not find the test URL in the remaining results");
|
||||
}
|
||||
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
});
|
||||
|
||||
// We shouldn't be able to remove a bookmark item.
|
||||
|
@ -43,11 +51,11 @@ add_task(async function test_remove_bookmark_doesnt() {
|
|||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("from_urlbar");
|
||||
let result = await waitForAutocompleteResultAt(1);
|
||||
Assert.equal(result.getAttribute("ac-value"), TEST_URL, "Found the expected result");
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
|
||||
Assert.equal(result.url, TEST_URL, "Found the expected result");
|
||||
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
Assert.equal(gURLBar.popup.richlistbox.selectedIndex, 1);
|
||||
Assert.equal(UrlbarTestUtils.getSelectedIndex(window), 1);
|
||||
let options = AppConstants.platform == "macosx" ? { shiftKey: true } : {};
|
||||
EventUtils.synthesizeKey("KEY_Delete", options);
|
||||
|
||||
|
@ -56,8 +64,7 @@ add_task(async function test_remove_bookmark_doesnt() {
|
|||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
await PlacesTestUtils.promiseAsyncUpdates();
|
||||
|
||||
gURLBar.popup.hidePopup();
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
|
||||
Assert.ok(await PlacesUtils.bookmarks.fetch({url: TEST_URL}),
|
||||
"Should still have the URL bookmarked.");
|
|
@ -72,8 +72,8 @@ function promiseSearchComplete(win = window, dontAnimate = false) {
|
|||
function promiseAutocompleteResultPopup(inputText,
|
||||
win = window,
|
||||
fireInputEvent = false) {
|
||||
return UrlbarTestUtils.promiseAutocompleteResultPopup(inputText,
|
||||
win, waitForFocus, fireInputEvent);
|
||||
return UrlbarTestUtils.promiseAutocompleteResultPopup(win, inputText,
|
||||
waitForFocus, fireInputEvent);
|
||||
}
|
||||
|
||||
async function waitForAutocompleteResultAt(index) {
|
||||
|
|
|
@ -17,14 +17,11 @@ skip-if = os == "linux" # Bug 1188154
|
|||
support-files =
|
||||
../browser/print_postdata.sjs
|
||||
[browser_action_keyword_override.js]
|
||||
[browser_action_searchengine.js]
|
||||
[browser_action_searchengine_alias.js]
|
||||
[browser_autocomplete_a11y_label.js]
|
||||
skip-if = (verify && !debug && (os == 'win'))
|
||||
[browser_autocomplete_autoselect.js]
|
||||
[browser_autocomplete_cursor.js]
|
||||
skip-if = verify
|
||||
[browser_autocomplete_edit_completed.js]
|
||||
[browser_autocomplete_enter_race.js]
|
||||
[browser_autocomplete_no_title.js]
|
||||
[browser_autocomplete_readline_navigation.js]
|
||||
|
@ -32,7 +29,6 @@ skip-if = os != "mac" # Mac only feature
|
|||
[browser_autocomplete_tag_star_visibility.js]
|
||||
[browser_dragdropURL.js]
|
||||
[browser_keyword_select_and_type.js]
|
||||
[browser_new_tab_urlbar_reset.js]
|
||||
[browser_pasteAndGo.js]
|
||||
subsuite = clipboard
|
||||
[browser_remotetab.js]
|
||||
|
@ -94,7 +90,6 @@ support-files =
|
|||
[browser_urlbarTokenAlias.js]
|
||||
[browser_urlbar_autoFill_backspaced.js]
|
||||
[browser_urlbar_canonize_on_autofill.js]
|
||||
[browser_urlbar_remove_match.js]
|
||||
[browser_urlbar_stop_pending.js]
|
||||
support-files =
|
||||
../browser/slow-page.sjs
|
||||
|
@ -109,12 +104,16 @@ support-files =
|
|||
# against both the legacy urlbar and the new QuantumBar. The references in this
|
||||
# directory will run them against the old urlbar as per the pref above.
|
||||
|
||||
[../browser/browser_action_searchengine.js]
|
||||
[../browser/browser_action_searchengine_alias.js]
|
||||
[../browser/browser_autocomplete_edit_completed.js]
|
||||
[../browser/browser_canonizeURL.js]
|
||||
[../browser/browser_URLBarSetURI.js]
|
||||
skip-if = (os == "linux" || os == "mac") && debug # bug 970052, bug 970053
|
||||
[../browser/browser_locationBarCommand.js]
|
||||
[../browser/browser_locationBarExternalLoad.js]
|
||||
[../browser/browser_moz_action_link.js]
|
||||
[../browser/browser_new_tab_urlbar_reset.js]
|
||||
[../browser/browser_populateAfterPushState.js]
|
||||
[../browser/browser_redirect_error.js]
|
||||
support-files = ../browser/redirect_error.sjs
|
||||
|
@ -152,6 +151,7 @@ support-files =
|
|||
[../browser/browser_urlbar_speculative_connect_not_with_client_cert.js]
|
||||
[../browser/browser_urlbar_remoteness_switch.js]
|
||||
run-if = e10s
|
||||
[../browser/browser_urlbar_remove_match.js]
|
||||
[../browser/browser_userTypedValue.js]
|
||||
support-files = ../browser/file_userTypedValue.html
|
||||
[../browser/browser_wyciwyg_urlbarCopying.js]
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
add_task(async function() {
|
||||
Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
|
||||
"http://example.com/?q={searchTerms}");
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
let originalEngine = Services.search.defaultEngine;
|
||||
Services.search.defaultEngine = engine;
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.defaultEngine = originalEngine;
|
||||
Services.search.removeEngine(engine);
|
||||
try {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
} catch (ex) { /* tab may have already been closed in case of failure */ }
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("open a search");
|
||||
let result = await waitForAutocompleteResultAt(0);
|
||||
isnot(result, null, "Should have a result");
|
||||
Assert.deepEqual(
|
||||
PlacesUtils.parseActionUrl(result.getAttribute("url")),
|
||||
{
|
||||
type: "searchengine",
|
||||
params: {
|
||||
engineName: "MozSearch",
|
||||
input: "open a search",
|
||||
searchQuery: "open a search",
|
||||
},
|
||||
},
|
||||
"Result should be a moz-action: for the correct search engine"
|
||||
);
|
||||
is(result.hasAttribute("image"), false, "Result shouldn't have an image attribute");
|
||||
|
||||
let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
result.click();
|
||||
await tabPromise;
|
||||
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search", "Correct URL should be loaded");
|
||||
|
||||
gURLBar.popup.hidePopup();
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
});
|
|
@ -1,37 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
add_task(async function() {
|
||||
let iconURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
|
||||
Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET",
|
||||
"http://example.com/?q={searchTerms}");
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
let originalEngine = Services.search.defaultEngine;
|
||||
Services.search.defaultEngine = engine;
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.defaultEngine = originalEngine;
|
||||
Services.search.removeEngine(engine);
|
||||
try {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
} catch (ex) { /* tab may have already been closed in case of failure */ }
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("moz open a search");
|
||||
let result = await waitForAutocompleteResultAt(0);
|
||||
ok(result.hasAttribute("image"), "Result should have an image attribute");
|
||||
ok(result.getAttribute("image") === engine.iconURI.spec,
|
||||
"Image attribute should have the search engine's icon");
|
||||
|
||||
let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
EventUtils.synthesizeKey("KEY_Enter");
|
||||
await tabPromise;
|
||||
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search");
|
||||
|
||||
gURLBar.popup.hidePopup();
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
});
|
|
@ -1,6 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* This test ensures that we produce good labels for a11y purposes.
|
||||
*/
|
||||
|
||||
const SUGGEST_ALL_PREF = "browser.search.suggest.enabled";
|
||||
const SUGGEST_URLBAR_PREF = "browser.urlbar.suggest.searches";
|
||||
const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
|
||||
|
@ -9,12 +13,17 @@ add_task(async function switchToTab() {
|
|||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:about");
|
||||
|
||||
await promiseAutocompleteResultPopup("% about");
|
||||
let result = await waitForAutocompleteResultAt(1);
|
||||
is(result.getAttribute("type"), "switchtab", "Expect right type attribute");
|
||||
is(result.label, "about:about about:about Tab", "Result a11y label should be: <title> <url> Tab");
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
|
||||
Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.TAB_SWITCH,
|
||||
"Should have a switch tab result");
|
||||
|
||||
gURLBar.popup.hidePopup();
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
// XXX Bug 1524539. This fails on QuantumBar because we're producing different
|
||||
// outputs. Once we confirm accessibilty is ok with the new format, we
|
||||
// should update and have this test running on QuantumBar.
|
||||
let element = await UrlbarTestUtils.waitForAutocompleteResultAt(window, 1);
|
||||
is(element.label, "about:about about:about Tab", "Result a11y label should be: <title> <url> Tab");
|
||||
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
|
@ -33,11 +42,11 @@ add_task(async function searchSuggestions() {
|
|||
});
|
||||
|
||||
await promiseAutocompleteResultPopup("foo");
|
||||
await waitForAutocompleteResultAt(2);
|
||||
let length = await UrlbarTestUtils.getResultCount(window);
|
||||
// Don't assume that the search doesn't match history or bookmarks left around
|
||||
// by earlier tests.
|
||||
Assert.ok(gURLBar.popup.richlistbox.itemChildren.length >= 3,
|
||||
"Should get at least heuristic result + two search suggestions");
|
||||
Assert.greaterOrEqual(length, 3,
|
||||
"Should get at least heuristic result + two search suggestions");
|
||||
// The first expected search is the search term itself since the heuristic
|
||||
// result will come before the search suggestions.
|
||||
let expectedSearches = [
|
||||
|
@ -45,15 +54,21 @@ add_task(async function searchSuggestions() {
|
|||
"foofoo",
|
||||
"foobar",
|
||||
];
|
||||
for (let child of gURLBar.popup.richlistbox.itemChildren) {
|
||||
if (child.getAttribute("type").split(/\s+/).includes("searchengine")) {
|
||||
Assert.ok(expectedSearches.length > 0);
|
||||
for (let i = 0; i < length; i++) {
|
||||
let result = await UrlbarTestUtils.getDetailsOfResultAt(window, i);
|
||||
if (result.type === UrlbarUtils.RESULT_TYPE.SEARCH) {
|
||||
Assert.greaterOrEqual(expectedSearches.length, 0,
|
||||
"Should still have expected searches remaining");
|
||||
let suggestion = expectedSearches.shift();
|
||||
Assert.equal(child.label, suggestion + " browser_searchSuggestionEngine searchSuggestionEngine.xml Search",
|
||||
"Result label should be: <search term> <engine name> Search");
|
||||
// XXX Bug 1524539. This fails on QuantumBar because we're producing different
|
||||
// outputs. Once we confirm accessibilty is ok with the new format, we
|
||||
// should update and have this test running on QuantumBar.
|
||||
let element = await UrlbarTestUtils.waitForAutocompleteResultAt(window, i);
|
||||
Assert.equal(element.label,
|
||||
suggestion + " browser_searchSuggestionEngine searchSuggestionEngine.xml Search",
|
||||
"Result label should be: <search term> <engine name> Search");
|
||||
}
|
||||
}
|
||||
Assert.ok(expectedSearches.length == 0);
|
||||
gURLBar.popup.hidePopup();
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests that the first item is correctly autoselected and some navigation
|
||||
* around the results list.
|
||||
*/
|
||||
|
||||
const ONEOFF_URLBAR_PREF = "browser.urlbar.oneOffSearches";
|
||||
|
||||
function repeat(limit, func) {
|
||||
|
@ -9,12 +14,14 @@ function repeat(limit, func) {
|
|||
}
|
||||
}
|
||||
|
||||
function is_selected(index) {
|
||||
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
|
||||
function assertSelected(index) {
|
||||
Assert.equal(UrlbarTestUtils.getSelectedIndex(window),
|
||||
index, "Should have selected the correct item");
|
||||
// Also check the "selected" attribute, to ensure it is not a "fake" selection
|
||||
// due to binding misbehaviors.
|
||||
ok(gURLBar.popup.richlistbox.selectedItem.hasAttribute("selected"),
|
||||
`Item ${index + 1} should have the "selected" attribute`);
|
||||
let element = UrlbarTestUtils.getSelectedElement(window);
|
||||
Assert.ok(element.hasAttribute("selected"),
|
||||
"Should have the selected attribute on the row element");
|
||||
|
||||
// This is true because although both the listbox and the one-offs can have
|
||||
// selections, the test doesn't check that.
|
||||
|
@ -22,7 +29,7 @@ function is_selected(index) {
|
|||
"A result is selected, so the one-offs should not have a selection");
|
||||
}
|
||||
|
||||
function is_selected_one_off(index) {
|
||||
function assertSelected_one_off(index) {
|
||||
is(gURLBar.popup.oneOffSearchButtons.selectedButtonIndex, index,
|
||||
"Expected one-off button should be selected");
|
||||
|
||||
|
@ -51,49 +58,49 @@ add_task(async function() {
|
|||
await PlacesTestUtils.addVisits(visits);
|
||||
|
||||
await promiseAutocompleteResultPopup("example.com/autocomplete");
|
||||
await waitForAutocompleteResultAt(maxResults - 1);
|
||||
|
||||
let popup = gURLBar.popup;
|
||||
let results = popup.richlistbox.itemChildren;
|
||||
is(results.length, maxResults,
|
||||
"Should get maxResults=" + maxResults + " results");
|
||||
is_selected(0);
|
||||
let resultCount = await UrlbarTestUtils.getResultCount(window);
|
||||
|
||||
Assert.equal(resultCount, maxResults,
|
||||
"Should get the expected amount of results");
|
||||
assertSelected(0);
|
||||
|
||||
info("Key Down to select the next item");
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
is_selected(1);
|
||||
assertSelected(1);
|
||||
|
||||
info("Key Down maxResults-1 times should select the first one-off");
|
||||
repeat(maxResults - 1, () => EventUtils.synthesizeKey("KEY_ArrowDown"));
|
||||
is_selected_one_off(0);
|
||||
assertSelected_one_off(0);
|
||||
|
||||
info("Key Down numButtons-1 should select the last one-off");
|
||||
let numButtons =
|
||||
gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length;
|
||||
repeat(numButtons - 1, () => EventUtils.synthesizeKey("KEY_ArrowDown"));
|
||||
is_selected_one_off(numButtons - 1);
|
||||
assertSelected_one_off(numButtons - 1);
|
||||
|
||||
info("Key Down twice more should select the second result");
|
||||
repeat(2, () => EventUtils.synthesizeKey("KEY_ArrowDown"));
|
||||
is_selected(1);
|
||||
assertSelected(1);
|
||||
|
||||
info("Key Down maxResults + numButtons times should wrap around");
|
||||
repeat(maxResults + numButtons,
|
||||
() => EventUtils.synthesizeKey("KEY_ArrowDown"));
|
||||
is_selected(1);
|
||||
assertSelected(1);
|
||||
|
||||
info("Key Up maxResults + numButtons times should wrap around the other way");
|
||||
repeat(maxResults + numButtons, () => EventUtils.synthesizeKey("KEY_ArrowUp"));
|
||||
is_selected(1);
|
||||
assertSelected(1);
|
||||
|
||||
info("Page Up will go up the list, but not wrap");
|
||||
EventUtils.synthesizeKey("KEY_PageUp");
|
||||
is_selected(0);
|
||||
assertSelected(0);
|
||||
|
||||
info("Page Up again will wrap around to the end of the list");
|
||||
EventUtils.synthesizeKey("KEY_PageUp");
|
||||
is_selected(maxResults - 1);
|
||||
assertSelected(maxResults - 1);
|
||||
|
||||
EventUtils.synthesizeKey("KEY_Escape");
|
||||
await promisePopupHidden(gURLBar.popup);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
EventUtils.synthesizeKey("KEY_Escape");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Verify that urlbar state is reset when openig a new tab, so searching for the
|
||||
* same text will reopen the results popup.
|
||||
*/
|
||||
add_task(async function() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false);
|
||||
await promiseAutocompleteResultPopup("m");
|
||||
ok(gURLBar.popupOpen, "The popup is open");
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false);
|
||||
await promiseAutocompleteResultPopup("m");
|
||||
ok(gURLBar.popupOpen, "The popup is open");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
BrowserTestUtils.removeTab(tab2);
|
||||
});
|
Загрузка…
Ссылка в новой задаче