1
0
Fork 0
firefox/netwerk/test/browser/browser_test_offline_tab.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

36 lines
1.1 KiB
JavaScript

/* 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");
}
});
});
});