From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../tests/quicksuggest/unit/test_rust_ingest.js | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js') diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js b/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js index e6ec61bcd4..f2e3f96c1f 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js @@ -78,11 +78,15 @@ add_task(async function firstRun() { await checkSuggestions(); - // Disable and re-enable the backend. No new ingestion should start - // immediately since this isn't the first time the backend has been enabled. + // Disable and re-enable the backend. Another ingest should start immediately + // since ingest is done every time the backend is re-enabled. UrlbarPrefs.set("quicksuggest.rustEnabled", false); UrlbarPrefs.set("quicksuggest.rustEnabled", true); - await assertNoNewIngestStarted(ingestPromise); + ({ ingestPromise } = await waitForIngestStart(ingestPromise)); + + info("Awaiting ingest promise"); + await ingestPromise; + info("Done awaiting ingest promise"); await checkSuggestions(); @@ -101,14 +105,18 @@ add_task(async function interval() { "Sanity check: Rust backend is initially disabled" ); - // Set a small interval and enable the backend. No new ingestion should start - // immediately since this isn't the first time the backend has been enabled. + // Set a small interval and enable the backend. A new ingest will immediately + // start. let intervalSecs = 1; UrlbarPrefs.set("quicksuggest.rustIngestIntervalSeconds", intervalSecs); UrlbarPrefs.set("quicksuggest.rustEnabled", true); - await assertNoNewIngestStarted(ingestPromise); + ({ ingestPromise } = await waitForIngestStart(ingestPromise)); - // Wait for a few ingests to happen. + info("Awaiting ingest promise"); + await ingestPromise; + info("Done awaiting ingest promise"); + + // Wait for a few ingests to happen due to the timer firing. for (let i = 0; i < 3; i++) { info("Preparing for ingest at index " + i); @@ -193,17 +201,6 @@ async function waitForIngestStart(oldIngestPromise) { return { ingestPromise: newIngestPromise }; } -async function assertNoNewIngestStarted(oldIngestPromise) { - for (let i = 0; i < 3; i++) { - await TestUtils.waitForTick(); - } - Assert.equal( - QuickSuggest.rustBackend.ingestPromise, - oldIngestPromise, - "No new ingest started" - ); -} - async function checkSuggestions(expected = [REMOTE_SETTINGS_SUGGESTION]) { let actual = await QuickSuggest.rustBackend.query("amp"); Assert.deepEqual( -- cgit v1.2.3