diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js')
-rw-r--r-- | browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js b/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js new file mode 100644 index 0000000000..399e7e16e5 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_marked_detached_tab.js @@ -0,0 +1,58 @@ +/** + * Test that autofill autocomplete works after detaching a tab + */ + +"use strict"; + +const URL = BASE_URL + "autocomplete_basic.html"; + +function checkPopup(autoCompletePopup) { + let first = autoCompletePopup.view.results[0]; + const { primary, secondary } = JSON.parse(first.label); + ok( + primary.startsWith(TEST_ADDRESS_1["street-address"].split("\n")[0]), + "Check primary label is street address" + ); + is( + secondary, + TEST_ADDRESS_1["address-level2"], + "Check secondary label is address-level2" + ); +} + +add_task(async function setup_storage() { + await setStorage(TEST_ADDRESS_1, TEST_ADDRESS_2, TEST_ADDRESS_3); +}); + +add_task(async function test_detach_tab_marked() { + let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, url: URL }); + let browser = tab.linkedBrowser; + const { autoCompletePopup } = browser; + + // Check the page after the initial load + await openPopupOn(browser, "#street-address"); + checkPopup(autoCompletePopup); + await closePopup(browser); + + // Detach the tab to a new window + info("expecting tab replaced with new window"); + let windowLoadedPromise = BrowserTestUtils.waitForNewWindow(); + let newWin = gBrowser.replaceTabWithWindow( + gBrowser.getTabForBrowser(browser) + ); + await windowLoadedPromise; + + info("tab was detached"); + let newBrowser = newWin.gBrowser.selectedBrowser; + ok(newBrowser, "Found new <browser>"); + let newAutoCompletePopup = newBrowser.autoCompletePopup; + ok(newAutoCompletePopup, "Found new autocomplete popup"); + + await openPopupOn(newBrowser, "#street-address"); + checkPopup(newAutoCompletePopup); + + await closePopup(newBrowser); + let windowRefocusedPromise = BrowserTestUtils.waitForEvent(window, "focus"); + await BrowserTestUtils.closeWindow(newWin); + await windowRefocusedPromise; +}); |