зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1657663: Update OS.File.setDates precision and fix failing extension tests r=barret,mixedpuppy
This changes fixes some failing extension tests on unixes. These failures were caused by a mismatch in time precision used by nsIFile and OS.File's implementations. The fixes are as follows: 1. Use IOUtils (the C++ port of OS.File) methods where possible. 2. Update the OS.File.setDates implementation to use a higher time precision when setDates is called. Eventually, all calls to OS.File.setDates will be replaced by IOUtils.touch. Differential Revision: https://phabricator.services.mozilla.com/D86831
This commit is contained in:
Родитель
53c14a2428
Коммит
546af7a825
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче