mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-07 19:59:18 +02:00
MozReview-Commit-ID: JB3GPKsfmTs --HG-- extra : rebase_source : 02fd2e102829f2c4880b8166755d5d57083c880a extra : source : b386e97721cfad7464829c88a1a0b8c42e75315c
43 lines
1.7 KiB
JavaScript
43 lines
1.7 KiB
JavaScript
"use strict";
|
|
|
|
/**
|
|
* Test that when opening a private browsing window and typing in it before about:privatebrowsing
|
|
* loads, we don't clear the URL bar.
|
|
*/
|
|
add_task(function*() {
|
|
let urlbarTestValue = "Mary had a little lamb";
|
|
let win = OpenBrowserWindow({private: true});
|
|
let delayedStartupFinished = TestUtils.topicObserved("browser-delayed-startup-finished",
|
|
subject => subject == win);
|
|
yield BrowserTestUtils.waitForEvent(win, "load");
|
|
let urlbar = win.document.getElementById("urlbar");
|
|
urlbar.value = urlbarTestValue;
|
|
// Need this so the autocomplete controller attaches:
|
|
let focusEv = new FocusEvent("focus", {});
|
|
urlbar.dispatchEvent(focusEv);
|
|
// And so we know input happened:
|
|
let inputEv = new InputEvent("input", {data: "", view: win, bubbles: true});
|
|
urlbar.onInput(inputEv);
|
|
// Check it worked:
|
|
is(urlbar.value, urlbarTestValue, "URL bar value should be there");
|
|
is(win.gBrowser.selectedBrowser.userTypedValue, urlbarTestValue, "browser object should know the url bar value");
|
|
|
|
let continueTest;
|
|
let continuePromise = new Promise(resolve => continueTest = resolve);
|
|
let wpl = {
|
|
onLocationChange(aWebProgress, aRequest, aLocation) {
|
|
if (aLocation && aLocation.spec == "about:privatebrowsing") {
|
|
continueTest();
|
|
}
|
|
},
|
|
};
|
|
win.gBrowser.addProgressListener(wpl);
|
|
|
|
yield continuePromise;
|
|
is(urlbar.value, urlbarTestValue,
|
|
"URL bar value should be the same once about:privatebrowsing has loaded");
|
|
is(win.gBrowser.selectedBrowser.userTypedValue, urlbarTestValue,
|
|
"browser object should still know url bar value once about:privatebrowsing has loaded");
|
|
win.gBrowser.removeProgressListener(wpl);
|
|
yield BrowserTestUtils.closeWindow(win);
|
|
});
|