diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/about/browser_aboutHome_search_POST.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/about/browser_aboutHome_search_POST.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/browser/base/content/test/about/browser_aboutHome_search_POST.js b/browser/base/content/test/about/browser_aboutHome_search_POST.js new file mode 100644 index 0000000000..191b86be65 --- /dev/null +++ b/browser/base/content/test/about/browser_aboutHome_search_POST.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +ignoreAllUncaughtExceptions(); + +add_task(async function () { + info("Check POST search engine support"); + await SpecialPowers.pushPrefEnv({ + set: [ + [ + "browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar", + false, + ], + ], + }); + + let currEngine = await Services.search.getDefault(); + + await BrowserTestUtils.withNewTab( + { gBrowser, url: "about:home" }, + async browser => { + let engine; + await promiseContentSearchChange(browser, async () => { + engine = await SearchTestUtils.promiseNewSearchEngine({ + url: "https://example.com/browser/browser/base/content/test/about/POSTSearchEngine.xml", + setAsDefault: true, + }); + return engine.name; + }); + + // Ready to execute the tests! + let needle = "Search for something awesome."; + + let promise = BrowserTestUtils.browserLoaded(browser); + await SpecialPowers.spawn(browser, [{ needle }], async function (args) { + let doc = content.document; + let el = doc.querySelector(["#searchText", "#newtab-search-text"]); + el.value = args.needle; + doc.getElementById("searchSubmit").click(); + }); + + await promise; + + // When the search results load, check them for correctness. + await SpecialPowers.spawn(browser, [{ needle }], async function (args) { + let loadedText = content.document.body.textContent; + ok(loadedText, "search page loaded"); + is( + loadedText, + "searchterms=" + escape(args.needle.replace(/\s/g, "+")), + "Search text should arrive correctly" + ); + }); + + await Services.search.setDefault( + currEngine, + Ci.nsISearchService.CHANGE_REASON_UNKNOWN + ); + try { + await Services.search.removeEngine(engine); + } catch (ex) {} + } + ); + await SpecialPowers.popPrefEnv(); +}); |