Bug 1333345 - Part 2: Add test to demonstrate buggy keyboard shortcut behavior in address bar. r?mak
Shift+Enter should add 'www.' and '.net' to search string, but uses the autocomplete suggestion 'example.com' instead. This test case documents the bug, which will be fixed in a subsequent commit.
MozReview-Commit-ID: 6jMrezneHk1
--- a/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js
+++ b/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js
@@ -1,10 +1,12 @@
// The order of these tests matters!
+"use strict";
+
add_task(function* setup() {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/?q=%s",
title: "test" });
registerCleanupFunction(function* () {
yield PlacesUtils.bookmarks.remove(bm);
yield BrowserTestUtils.removeTab(tab);
@@ -37,16 +39,29 @@ add_task(function* test_sametext() {
gURLBar.dispatchEvent(event);
EventUtils.synthesizeKey("VK_RETURN", {});
info("wait for the page to load");
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser,
false, "http://example.com/");
});
+add_task(function* test_expand_search_string() {
+ yield promiseAutocompleteResultPopup("example");
+ is(gURLBar.textValue, "example.com/", "Autocomplete should suggest 'example.com/' for 'example'");
+
+ gURLBar.focus();
+ EventUtils.synthesizeKey("VK_RETURN", {shiftKey: true});
+
+ info("wait for the page to load");
+ yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser);
+
+ is(gURLBar.textValue, "example.com", "Shift+Enter should add 'www.' and '.net' to search string, but uses the autocomplete suggestion 'example.com' instead! This is bug 1333345.");
+});
+
add_task(function* test_after_empty_search() {
yield promiseAutocompleteResultPopup("");
gURLBar.focus();
gURLBar.value = "e";
EventUtils.synthesizeKey("x", {});
EventUtils.synthesizeKey("VK_RETURN", {});
info("wait for the page to load");