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/tabs/browser_reload_deleted_file.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/tabs/browser_reload_deleted_file.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_reload_deleted_file.js b/browser/base/content/test/tabs/browser_reload_deleted_file.js new file mode 100644 index 0000000000..2051dbfac7 --- /dev/null +++ b/browser/base/content/test/tabs/browser_reload_deleted_file.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ + +const uuidGenerator = Services.uuid; + +const DUMMY_FILE = "dummy_page.html"; + +// Test for bug 1327942. +add_task(async function () { + // Copy dummy page to unique file in TmpD, so that we can safely delete it. + let dummyPage = getChromeDir(getResolvedURI(gTestPath)); + dummyPage.append(DUMMY_FILE); + let disappearingPage = Services.dirsvc.get("TmpD", Ci.nsIFile); + let uniqueName = uuidGenerator.generateUUID().toString(); + dummyPage.copyTo(disappearingPage, uniqueName); + disappearingPage.append(uniqueName); + + // Get file:// URI for new page and load in a new tab. + const uriString = Services.io.newFileURI(disappearingPage).spec; + let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uriString); + registerCleanupFunction(async function () { + BrowserTestUtils.removeTab(tab); + }); + + // Delete the page, simulate a click of the reload button and check that we + // get a neterror page. + disappearingPage.remove(false); + document.getElementById("reload-button").doCommand(); + await BrowserTestUtils.waitForErrorPage(tab.linkedBrowser); + await SpecialPowers.spawn(tab.linkedBrowser, [], function () { + ok( + content.document.documentURI.startsWith("about:neterror"), + "Check that a neterror page was loaded." + ); + }); +}); |