forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,514 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 77 additions & 10 deletions
87
browser/base/content/test/urlbar/browser_autocomplete_enter_race.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,90 @@ | ||
add_task(function*() { | ||
registerCleanupFunction(function* () { | ||
yield PlacesUtils.bookmarks.remove(bm); | ||
}); | ||
// The order of these tests matters! | ||
|
||
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); | ||
}); | ||
yield PlacesUtils.keywords.insert({ keyword: "keyword", | ||
url: "http://example.com/?q=%s" }); | ||
// Needs at least one success. | ||
ok(true, "Setup complete"); | ||
}); | ||
|
||
yield new Promise(resolve => waitForFocus(resolve, window)); | ||
|
||
add_task(function* test_keyword() { | ||
yield promiseAutocompleteResultPopup("keyword bear"); | ||
gURLBar.focus(); | ||
EventUtils.synthesizeKey("d", {}); | ||
EventUtils.synthesizeKey("VK_RETURN", {}); | ||
info("wait for the page to load"); | ||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, | ||
false, "http://example.com/?q=beard"); | ||
}); | ||
|
||
add_task(function* test_sametext() { | ||
yield promiseAutocompleteResultPopup("example.com", window, true); | ||
|
||
// Simulate re-entering the same text searched the last time. This may happen | ||
// through a copy paste, but clipboard handling is not much reliable, so just | ||
// fire an input event. | ||
info("synthesize input event"); | ||
let event = document.createEvent("Events"); | ||
event.initEvent("input", true, true); | ||
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_after_empty_search() { | ||
yield promiseAutocompleteResultPopup(""); | ||
gURLBar.focus(); | ||
gURLBar.value = "e"; | ||
EventUtils.synthesizeKey("x", {}); | ||
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_disabled_ac() { | ||
// Disable autocomplete. | ||
let suggestHistory = Preferences.get("browser.urlbar.suggest.history"); | ||
Preferences.set("browser.urlbar.suggest.history", false); | ||
let suggestBookmarks = Preferences.get("browser.urlbar.suggest.bookmark"); | ||
Preferences.set("browser.urlbar.suggest.bookmark", false); | ||
let suggestOpenPages = Preferences.get("browser.urlbar.suggest.openpage"); | ||
Preferences.set("browser.urlbar.suggest.openpages", false); | ||
|
||
Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", | ||
"http://example.com/?q={searchTerms}"); | ||
let engine = Services.search.getEngineByName("MozSearch"); | ||
let originalEngine = Services.search.currentEngine; | ||
Services.search.currentEngine = engine; | ||
|
||
registerCleanupFunction(function* () { | ||
Preferences.set("browser.urlbar.suggest.history", suggestHistory); | ||
Preferences.set("browser.urlbar.suggest.bookmark", suggestBookmarks); | ||
Preferences.set("browser.urlbar.suggest.openpage", suggestOpenPages); | ||
|
||
Services.search.currentEngine = originalEngine; | ||
let engine = Services.search.getEngineByName("MozSearch"); | ||
Services.search.removeEngine(engine); | ||
}); | ||
|
||
gURLBar.focus(); | ||
gURLBar.value = "e"; | ||
EventUtils.synthesizeKey("x", {}); | ||
EventUtils.synthesizeKey("VK_RETURN", {}); | ||
|
||
yield promiseTabLoadEvent(gBrowser.selectedTab); | ||
is(gBrowser.selectedBrowser.currentURI.spec, | ||
"http://example.com/?q=beard", | ||
"Latest typed characters should have been used"); | ||
info("wait for the page to load"); | ||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, | ||
false, "http://example.com/?q=ex"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.