From 4076f4a2c17cfc59fcea06dbcc4928edd3c606c3 Mon Sep 17 00:00:00 2001 From: Trevor Rowbotham Date: Thu, 20 Aug 2015 13:46:29 -0700 Subject: [PATCH] Bug 1180901 - Test that a locked file cannot be removed from the extensions trash directory on Windows r=mossop --HG-- extra : amend_source : 2ec19a524037838b7ac9d4d5cb1c053f0728f891 --- .../test/xpcshell/test_bug1180901.js | 35 +++++++++++++++++++ .../test/xpcshell/xpcshell-shared.ini | 2 ++ .../extensions/test/xpcshell/xpcshell.ini | 1 + 3 files changed, 38 insertions(+) create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js new file mode 100644 index 000000000000..e2e60a393986 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js @@ -0,0 +1,35 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +function run_test() { + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + startupManager(); + run_next_test(); +} + +add_task(function* () { + let profileDir = OS.Constants.Path.profileDir; + let trashDir = OS.Path.join(profileDir, "extensions", "trash"); + let testFile = OS.Path.join(trashDir, "test.txt"); + + yield OS.File.makeDir(trashDir, { + from: profileDir, + ignoreExisting: true + }); + + let trashDirExists = yield OS.File.exists(trashDir); + ok(trashDirExists, "trash directory should have been created"); + + let file = yield OS.File.open(testFile, {create: true}, {winShare: 0}); + let fileExists = yield OS.File.exists(testFile); + ok(fileExists, "test.txt should have been created in " + trashDir); + + yield promiseInstallAllFiles([do_get_addon("test_install1")]); + yield promiseRestartManager(); + fileExists = yield OS.File.exists(testFile); + ok(fileExists, "test.txt still exists"); + yield file.close(); + yield OS.File.removeDir(OS.Path.join(OS.Constants.Path.profileDir, "extensions")); + yield promiseShutdownManager(); +}); diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini index 6882347a647d..6402ff7ac4bf 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini @@ -288,3 +288,5 @@ run-sequentially = Uses global XCurProcD dir. [test_sourceURI.js] [test_webextension.js] [test_bootstrap_globals.js] +[test_bug1180901.js] +skip-if = os != "win" diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini index 39b3af2e236f..03041c8f9f1b 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini @@ -28,4 +28,5 @@ skip-if = appname != "firefox" [test_XPIStates.js] + [include:xpcshell-shared.ini]