diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /docshell/test/browser/browser_uriFixupIntegration.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'docshell/test/browser/browser_uriFixupIntegration.js')
-rw-r--r-- | docshell/test/browser/browser_uriFixupIntegration.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/docshell/test/browser/browser_uriFixupIntegration.js b/docshell/test/browser/browser_uriFixupIntegration.js new file mode 100644 index 000000000..e041e1f67 --- /dev/null +++ b/docshell/test/browser/browser_uriFixupIntegration.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const kSearchEngineID = "browser_urifixup_search_engine"; +const kSearchEngineURL = "http://example.com/?search={searchTerms}"; + +add_task(function* setup() { + // Add a new fake search engine. + Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get", + kSearchEngineURL); + + let oldDefaultEngine = Services.search.defaultEngine; + Services.search.defaultEngine = Services.search.getEngineByName(kSearchEngineID); + + // Remove the fake engine when done. + registerCleanupFunction(() => { + if (oldDefaultEngine) { + Services.search.defaultEngine = oldDefaultEngine; + } + + let engine = Services.search.getEngineByName(kSearchEngineID); + if (engine) { + Services.search.removeEngine(engine); + } + }); +}); + +add_task(function* test() { + for (let searchParams of ["foo bar", "brokenprotocol:somethingelse"]) { + // Add a new blank tab. + gBrowser.selectedTab = gBrowser.addTab("about:blank"); + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + + // Enter search terms and start a search. + gURLBar.value = searchParams; + gURLBar.focus(); + EventUtils.synthesizeKey("VK_RETURN", {}); + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + + // Check that we arrived at the correct URL. + let escapedParams = encodeURIComponent(searchParams).replace("%20", "+"); + let expectedURL = kSearchEngineURL.replace("{searchTerms}", escapedParams); + is(gBrowser.selectedBrowser.currentURI.spec, expectedURL, + "New tab should have loaded with expected url."); + + // Cleanup. + gBrowser.removeCurrentTab(); + } +}); |