Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
/**
* Tests that content tabs with mailnews URLs that would be loaded in a content
* process are neither persisted nor restored, and that nntp: URLs are kept in
* the parent process.
*/
const tabmail = document.getElementById("tabmail");
const contentTabType = tabmail.tabTypes.contentTab;
/**
* @param {string} url
* @returns {?object} The persisted state of a content tab showing `url`.
*/
function persist(url) {
return contentTabType.persistTab({
browser: {
currentURI: Services.io.newURI(url),
getAttribute: () => null,
},
});
}
add_task(function testPersistTab() {
for (const url of [
]) {
Assert.equal(persist(url), null, `${url} should not be persisted`);
}
const mailboxURL = `${PathUtils.toFileURI(
PathUtils.join(PathUtils.tempDir, "message.eml")
).replace(/^file:/, "mailbox:")}?number=0&part=1.2`;
Assert.equal(persist(url)?.tabURI, url, `${url} should be persisted`);
}
});
add_task(function testRestoreTab() {
tabmail.restoreTab({
mode: "contentTab",
},
});
Assert.equal(tabmail.tabInfo.length, 1, "no tab should be restored");
});
/**
* Restoring a content tab with an nntp: URL must keep it in the parent process.
* There's no server configured for the URL, so it can't be loaded, but this
* must not crash.
*/
add_task(async function testRestoreNntpTab() {
tabmail.restoreTab({
mode: "contentTab",
},
});
Assert.equal(tabmail.tabInfo.length, 2, "the tab should be restored");
const tab = tabmail.tabInfo[1];
await TestUtils.waitForCondition(
() => !tab.browser.webProgress?.isLoadingDocument,
"the load should finish"
);
Assert.ok(
!tab.browser.isRemoteBrowser,
"the tab should be in the parent process"
);
tabmail.closeTab(tab);
});