/* * Tests for bug 1241100: Post to local file should not overwrite the file. */ "use strict"; async function createTestFile(filename, content) { let path = PathUtils.join(PathUtils.tempDir, filename); await IOUtils.writeUTF8(path, content); return path; } add_task(async function () { var postFilename = "post_file.html"; var actionFilename = "action_file.html"; var postFileContent = ` post file
`; var actionFileContent = ` action file
ok
`; var postPath = await createTestFile(postFilename, postFileContent); var actionPath = await createTestFile(actionFilename, actionFileContent); var postURI = PathUtils.toFileURI(postPath); var actionURI = PathUtils.toFileURI(actionPath); let tab = await BrowserTestUtils.openNewForegroundTab( gBrowser, "about:blank" ); let browserLoadedPromise = BrowserTestUtils.browserLoaded( tab.linkedBrowser, true, actionURI ); BrowserTestUtils.loadURIString(tab.linkedBrowser, postURI); await browserLoadedPromise; var actionFileContentAfter = await IOUtils.readUTF8(actionPath); is(actionFileContentAfter, actionFileContent, "action file is not modified"); await IOUtils.remove(postPath); await IOUtils.remove(actionPath); gBrowser.removeCurrentTab(); });