Bug 1450154: Clone file objects before checking lastModifiedTime. r?aswan
MozReview-Commit-ID: CnIT0bqUaPZ
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -364,17 +364,19 @@ function getFile(path, base = null) {
*
* @param {nsIFile} file
* The file to retrieve the modification time for.
* @returns {double}
* The file's modification time, in seconds since the Unix epoch.
*/
function tryGetMtime(file) {
try {
- return file.lastModifiedTime;
+ // Clone the file object so we always get the actual mtime, rather
+ // than whatever value it may have cached.
+ return file.clone().lastModifiedTime;
} catch (e) {
return 0;
}
}
/**
* Returns the path to `file` relative to the directory `dir`, or an
* absolute path to the file if no directory is passed, or the file is
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -423,22 +423,18 @@ add_task(async function test_4() {
notEqual(a2, null);
equal(a2.type, "extension");
equal(a2.version, "3.0");
equal(a2.name, "Real Test 3");
ok(a2.isActive);
ok(isExtensionInBootstrappedList(profileDir, a2.id));
ok(XPIS.test_install2_2.exists());
do_check_in_crash_annotation(a2.id, a2.version);
- // Windows currently has timing issues, and sees the add-on as changed
- // after restart.
- if (AppConstants.platform !== "win") {
- equal(a2.sourceURI.spec,
- "http://example.com/addons/test_install2_2.xpi");
- }
+ equal(a2.sourceURI.spec,
+ "http://example.com/addons/test_install2_2.xpi");
ok(!a2.foreignInstall);
equal(a2.installDate.getTime(), gInstallDate);
// Update date should be later (or the same if this test is too fast)
ok(a2.installDate <= a2.updateDate);
a2.uninstall();
});