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 /netwerk/test/browser/browser_test_offline_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 'netwerk/test/browser/browser_test_offline_tab.js')
-rw-r--r-- | netwerk/test/browser/browser_test_offline_tab.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/netwerk/test/browser/browser_test_offline_tab.js b/netwerk/test/browser/browser_test_offline_tab.js new file mode 100644 index 0000000000..bf60b4f462 --- /dev/null +++ b/netwerk/test/browser/browser_test_offline_tab.js @@ -0,0 +1,36 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function test_set_tab_offline() { + await BrowserTestUtils.withNewTab("https://example.com", async browser => { + // Set the tab to offline + gBrowser.selectedBrowser.browsingContext.forceOffline = true; + + await SpecialPowers.spawn(browser, [], async () => { + try { + await content.fetch("https://example.com/empty.html"); + ok(false, "Should not load since tab is offline"); + } catch (err) { + is(err.name, "TypeError", "Should fail since tab is offline"); + } + }); + }); +}); + +add_task(async function test_set_tab_online() { + await BrowserTestUtils.withNewTab("https://example.com", async browser => { + // Set the tab to online + gBrowser.selectedBrowser.browsingContext.forceOffline = false; + + await SpecialPowers.spawn(browser, [], async () => { + try { + await content.fetch("https://example.com/empty.html"); + ok(true, "Should load since tab is online"); + } catch (err) { + ok(false, "Should not fail since tab is online"); + } + }); + }); +}); |