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/base/content/test/general/browser_restore_isAppTab.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 '')
-rw-r--r-- | browser/base/content/test/general/browser_restore_isAppTab.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_restore_isAppTab.js b/browser/base/content/test/general/browser_restore_isAppTab.js new file mode 100644 index 0000000000..d46f53db7d --- /dev/null +++ b/browser/base/content/test/general/browser_restore_isAppTab.js @@ -0,0 +1,87 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { TabStateFlusher } = ChromeUtils.importESModule( + "resource:///modules/sessionstore/TabStateFlusher.sys.mjs" +); + +const DUMMY = + "https://example.com/browser/browser/base/content/test/general/dummy_page.html"; + +function isBrowserAppTab(browser) { + return browser.browsingContext.isAppTab; +} + +// Restarts the child process by crashing it then reloading the tab +var restart = async function (browser) { + // If the tab isn't remote this would crash the main process so skip it + if (!browser.isRemoteBrowser) { + return; + } + + // Make sure the main process has all of the current tab state before crashing + await TabStateFlusher.flush(browser); + + await BrowserTestUtils.crashFrame(browser); + + let tab = gBrowser.getTabForBrowser(browser); + SessionStore.reviveCrashedTab(tab); + + await promiseTabLoaded(tab); +}; + +add_task(async function navigate() { + let tab = BrowserTestUtils.addTab(gBrowser, "about:robots"); + let browser = tab.linkedBrowser; + gBrowser.selectedTab = tab; + await BrowserTestUtils.browserStopped(gBrowser); + let isAppTab = isBrowserAppTab(browser); + ok(!isAppTab, "Docshell shouldn't think it is an app tab"); + + gBrowser.pinTab(tab); + isAppTab = isBrowserAppTab(browser); + ok(isAppTab, "Docshell should think it is an app tab"); + + BrowserTestUtils.startLoadingURIString(gBrowser, DUMMY); + await BrowserTestUtils.browserStopped(gBrowser); + isAppTab = isBrowserAppTab(browser); + ok(isAppTab, "Docshell should think it is an app tab"); + + gBrowser.unpinTab(tab); + isAppTab = isBrowserAppTab(browser); + ok(!isAppTab, "Docshell shouldn't think it is an app tab"); + + gBrowser.pinTab(tab); + isAppTab = isBrowserAppTab(browser); + ok(isAppTab, "Docshell should think it is an app tab"); + + BrowserTestUtils.startLoadingURIString(gBrowser, "about:robots"); + await BrowserTestUtils.browserStopped(gBrowser); + isAppTab = isBrowserAppTab(browser); + ok(isAppTab, "Docshell should think it is an app tab"); + + gBrowser.removeCurrentTab(); +}); + +add_task(async function crash() { + if (!gMultiProcessBrowser || !AppConstants.MOZ_CRASHREPORTER) { + return; + } + + let tab = BrowserTestUtils.addTab(gBrowser, DUMMY); + let browser = tab.linkedBrowser; + gBrowser.selectedTab = tab; + await BrowserTestUtils.browserStopped(gBrowser); + let isAppTab = isBrowserAppTab(browser); + ok(!isAppTab, "Docshell shouldn't think it is an app tab"); + + gBrowser.pinTab(tab); + isAppTab = isBrowserAppTab(browser); + ok(isAppTab, "Docshell should think it is an app tab"); + + await restart(browser); + isAppTab = isBrowserAppTab(browser); + ok(isAppTab, "Docshell should think it is an app tab"); + + gBrowser.removeCurrentTab(); +}); |