diff --git a/toolkit/components/osfile/modules/osfile_unix_front.jsm b/toolkit/components/osfile/modules/osfile_unix_front.jsm index 11ed684e964e..43ba86406ccc 100644 --- a/toolkit/components/osfile/modules/osfile_unix_front.jsm +++ b/toolkit/components/osfile/modules/osfile_unix_front.jsm @@ -1148,10 +1148,12 @@ let timevals = new Type.timevals.implementation(); let timevalsPtr = timevals.address(); + // JavaScript date values are expressed in milliseconds since epoch. + // Split this up into second and microsecond components. timevals[0].tv_sec = (accessDate / 1000) | 0; - timevals[0].tv_usec = 0; + timevals[0].tv_usec = ((accessDate % 1000) * 1000) | 0; timevals[1].tv_sec = (modificationDate / 1000) | 0; - timevals[1].tv_usec = 0; + timevals[1].tv_usec = ((modificationDate % 1000) * 1000) | 0; return { value: timevals, ptr: timevalsPtr }; } diff --git a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm b/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm index b2958608efb6..d75ebef97b97 100644 --- a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm +++ b/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm @@ -1443,7 +1443,7 @@ var AddonTestUtils = { }, async promiseSetExtensionModifiedTime(path, time) { - await OS.File.setDates(path, time, time); + await IOUtils.touch(path, time); let iterator = new OS.File.DirectoryIterator(path); try { diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js b/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js index 60922cc7f045..85c1a03f41c0 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js @@ -79,12 +79,9 @@ add_task(async function run_tests() { what: "Modified timestamp on the XPI causes a reload of the manifest.", expectedVersion: "2.0", async action() { - let stat = await OS.File.stat(xpiPath); - await OS.File.setDates( - xpiPath, - stat.lastAccessDate, - stat.lastModificationDate.valueOf() + 60 * 1000 - ); + let stat = await IOUtils.stat(xpiPath); + let newLastModTime = stat.lastModified + 60 * 1000; + await IOUtils.touch(xpiPath, newLastModTime); }, }, ]; @@ -104,16 +101,13 @@ add_task(async function run_tests() { await promiseShutdownManager(); - let orig = await OS.File.stat(xpiPath); + let fileInfo = await IOUtils.stat(xpiPath); xpi2.copyTo(profileDir, `${ID}.xpi`); - // Make sure the timestamp is unchanged, so it is not re-scanned for that reason. - await OS.File.setDates( - xpiPath, - orig.lastAccessDate, - orig.lastModificationDate - ); + // Make sure the timestamp of the extension is unchanged, so it is not + // re-scanned for that reason. + await IOUtils.touch(xpiPath, fileInfo.lastModified); await test.action(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js index c109890080a1..70e40fa29b67 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js @@ -35,10 +35,10 @@ add_task(async function test_upgrade_incompatible() { // swap the incompatible extension in for the original let path = OS.Path.join(gProfD.path, "extensions", `${ID}.xpi`); - let sb = await OS.File.stat(path); - let timestamp = sb.lastModificationDate.valueOf(); + let fileInfo = await IOUtils.stat(path); + let timestamp = fileInfo.lastModified; - await OS.File.move(newfile.path, path); + await IOUtils.move(newfile.path, path); await promiseSetExtensionModifiedTime(path, timestamp); Services.obs.notifyObservers(new FileUtils.File(path), "flush-cache-entry"); @@ -60,7 +60,7 @@ add_task(async function test_upgrade_incompatible() { }); // swap the old extension back in and check that we don't persist the disabled state forever. - await OS.File.move(file.path, path); + await IOUtils.move(file.path, path); await promiseSetExtensionModifiedTime(path, timestamp); Services.obs.notifyObservers(new FileUtils.File(path), "flush-cache-entry");