1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
});
|