-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1852442 - Remove delay for heuristic result. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D192462
- Loading branch information
1 parent
7b81e19
commit 56b31e1
Showing
9 changed files
with
115 additions
and
226 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
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
84 changes: 84 additions & 0 deletions
84
browser/components/urlbar/tests/browser/browser_slow_heuristic.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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
// Test that slow heuristic results are still waited for on selection. | ||
|
||
"use strict"; | ||
|
||
add_task(async function test_slow_heuristic() { | ||
// Must be between CHUNK_RESULTS_DELAY_MS and DEFERRING_TIMEOUT_MS | ||
let timeout = 150; | ||
Assert.greater(timeout, UrlbarProvidersManager.CHUNK_RESULTS_DELAY_MS); | ||
Assert.greater(UrlbarEventBufferer.DEFERRING_TIMEOUT_MS, timeout); | ||
|
||
// First, add a provider that adds a heuristic result on a delay. | ||
let heuristicResult = new UrlbarResult( | ||
UrlbarUtils.RESULT_TYPE.URL, | ||
UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL, | ||
{ url: "https://example.com/" } | ||
); | ||
heuristicResult.heuristic = true; | ||
let heuristicProvider = new UrlbarTestUtils.TestProvider({ | ||
results: [heuristicResult], | ||
name: "heuristicProvider", | ||
priority: Infinity, | ||
addTimeout: timeout, | ||
}); | ||
UrlbarProvidersManager.registerProvider(heuristicProvider); | ||
registerCleanupFunction(() => { | ||
UrlbarProvidersManager.unregisterProvider(heuristicProvider); | ||
}); | ||
|
||
// Do a search without waiting for a result. | ||
const win = await BrowserTestUtils.openNewBrowserWindow(); | ||
let promiseLoaded = BrowserTestUtils.browserLoaded( | ||
win.gBrowser.selectedBrowser | ||
); | ||
|
||
win.gURLBar.focus(); | ||
EventUtils.sendString("test", win); | ||
EventUtils.synthesizeKey("KEY_Enter", {}, win); | ||
await promiseLoaded; | ||
|
||
await UrlbarTestUtils.promisePopupClose(win); | ||
await BrowserTestUtils.closeWindow(win); | ||
}); | ||
|
||
add_task(async function test_fast_heuristic() { | ||
let longTimeoutMs = 1000000; | ||
let originalHeuristicTimeout = UrlbarProvidersManager.CHUNK_RESULTS_DELAY_MS; | ||
UrlbarProvidersManager.CHUNK_RESULTS_DELAY_MS = longTimeoutMs; | ||
registerCleanupFunction(() => { | ||
UrlbarProvidersManager.CHUNK_RESULTS_DELAY_MS = originalHeuristicTimeout; | ||
}); | ||
|
||
// Add a fast heuristic provider. | ||
let heuristicResult = new UrlbarResult( | ||
UrlbarUtils.RESULT_TYPE.URL, | ||
UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL, | ||
{ url: "https://example.com/" } | ||
); | ||
heuristicResult.heuristic = true; | ||
let heuristicProvider = new UrlbarTestUtils.TestProvider({ | ||
results: [heuristicResult], | ||
name: "heuristicProvider", | ||
priority: Infinity, | ||
}); | ||
UrlbarProvidersManager.registerProvider(heuristicProvider); | ||
registerCleanupFunction(() => { | ||
UrlbarProvidersManager.unregisterProvider(heuristicProvider); | ||
}); | ||
|
||
// Do a search. | ||
const win = await BrowserTestUtils.openNewBrowserWindow(); | ||
|
||
let startTime = Cu.now(); | ||
Assert.greater( | ||
longTimeoutMs, | ||
Cu.now() - startTime, | ||
"Heuristic result is returned faster than CHUNK_RESULTS_DELAY_MS" | ||
); | ||
|
||
await UrlbarTestUtils.promisePopupClose(win); | ||
await BrowserTestUtils.closeWindow(win); | ||
}); |
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.