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 /browser/base/content/test/urlbar/browser_urlbarKeepStateAcrossTabSwitches.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 'browser/base/content/test/urlbar/browser_urlbarKeepStateAcrossTabSwitches.js')
-rw-r--r-- | browser/base/content/test/urlbar/browser_urlbarKeepStateAcrossTabSwitches.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/browser/base/content/test/urlbar/browser_urlbarKeepStateAcrossTabSwitches.js b/browser/base/content/test/urlbar/browser_urlbarKeepStateAcrossTabSwitches.js new file mode 100644 index 000000000..9c8996059 --- /dev/null +++ b/browser/base/content/test/urlbar/browser_urlbarKeepStateAcrossTabSwitches.js @@ -0,0 +1,49 @@ +"use strict"; + +/** + * Verify user typed text remains in the URL bar when tab switching, even when + * loads fail. + */ +add_task(function* () { + let input = "i-definitely-dont-exist.example.com"; + let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false); + // NB: CPOW usage because new tab pages can be preloaded, in which case no + // load events fire. + yield BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden) + let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser); + gURLBar.value = input; + gURLBar.select(); + EventUtils.sendKey("return"); + yield errorPageLoaded; + is(gURLBar.textValue, input, "Text is still in URL bar"); + yield BrowserTestUtils.switchTab(gBrowser, tab.previousSibling); + yield BrowserTestUtils.switchTab(gBrowser, tab); + is(gURLBar.textValue, input, "Text is still in URL bar after tab switch"); + yield BrowserTestUtils.removeTab(tab); +}); + +/** + * Invalid URIs fail differently (that is, immediately, in the loadURI call) + * if keyword searches are turned off. Test that this works, too. + */ +add_task(function* () { + let input = "To be or not to be-that is the question"; + yield new Promise(resolve => SpecialPowers.pushPrefEnv({set: [["keyword.enabled", false]]}, resolve)); + let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false); + // NB: CPOW usage because new tab pages can be preloaded, in which case no + // load events fire. + yield BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden) + let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser); + gURLBar.value = input; + gURLBar.select(); + EventUtils.sendKey("return"); + yield errorPageLoaded; + is(gURLBar.textValue, input, "Text is still in URL bar"); + is(tab.linkedBrowser.userTypedValue, input, "Text still stored on browser"); + yield BrowserTestUtils.switchTab(gBrowser, tab.previousSibling); + yield BrowserTestUtils.switchTab(gBrowser, tab); + is(gURLBar.textValue, input, "Text is still in URL bar after tab switch"); + is(tab.linkedBrowser.userTypedValue, input, "Text still stored on browser"); + yield BrowserTestUtils.removeTab(tab); +}); + |