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/components/search/test/browser_private_search_perwindowpb.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/components/search/test/browser_private_search_perwindowpb.js')
-rw-r--r-- | browser/components/search/test/browser_private_search_perwindowpb.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/browser/components/search/test/browser_private_search_perwindowpb.js b/browser/components/search/test/browser_private_search_perwindowpb.js new file mode 100644 index 000000000..c0410371b --- /dev/null +++ b/browser/components/search/test/browser_private_search_perwindowpb.js @@ -0,0 +1,76 @@ +// This test performs a search in a public window, then a different +// search in a private window, and then checks in the public window +// whether there is an autocomplete entry for the private search. + +add_task(function* () { + // Don't use about:home as the homepage for new windows + Services.prefs.setIntPref("browser.startup.page", 0); + registerCleanupFunction(() => Services.prefs.clearUserPref("browser.startup.page")); + + let windowsToClose = []; + + function performSearch(aWin, aIsPrivate) { + let searchBar = aWin.BrowserSearch.searchBar; + ok(searchBar, "got search bar"); + + let loadPromise = BrowserTestUtils.browserLoaded(aWin.gBrowser.selectedBrowser); + + searchBar.value = aIsPrivate ? "private test" : "public test"; + searchBar.focus(); + EventUtils.synthesizeKey("VK_RETURN", {}, aWin); + + return loadPromise; + } + + function* testOnWindow(aIsPrivate) { + let win = yield BrowserTestUtils.openNewBrowserWindow({ private: aIsPrivate }); + yield SimpleTest.promiseFocus(win); + windowsToClose.push(win); + return win; + } + + yield promiseNewEngine("426329.xml", { iconURL: "data:image/x-icon,%00" }); + + let newWindow = yield* testOnWindow(false); + yield performSearch(newWindow, false); + + newWindow = yield* testOnWindow(true); + yield performSearch(newWindow, true); + + newWindow = yield* testOnWindow(false); + + let searchBar = newWindow.BrowserSearch.searchBar; + searchBar.value = "p"; + searchBar.focus(); + + let popup = searchBar.textbox.popup; + let popupPromise = BrowserTestUtils.waitForEvent(popup, "popupshown"); + searchBar.textbox.showHistoryPopup(); + yield popupPromise; + + let entries = getMenuEntries(searchBar); + for (let i = 0; i < entries.length; i++) { + isnot(entries[i], "private test", + "shouldn't see private autocomplete entries"); + } + + searchBar.textbox.toggleHistoryPopup(); + searchBar.value = ""; + + windowsToClose.forEach(function(win) { + win.close(); + }); +}); + +function getMenuEntries(searchBar) { + let entries = []; + let autocompleteMenu = searchBar.textbox.popup; + // Could perhaps pull values directly from the controller, but it seems + // more reliable to test the values that are actually in the tree? + let column = autocompleteMenu.tree.columns[0]; + let numRows = autocompleteMenu.tree.view.rowCount; + for (let i = 0; i < numRows; i++) { + entries.push(autocompleteMenu.tree.view.getValueAt(i, column)); + } + return entries; +} |