mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 1347728 - Fix JSON dump of blocklists r=kjozwiak,mgoodwin
MozReview-Commit-ID: rwX5Nn9d6b --HG-- extra : rebase_source : 5df03011e57211e6cf2d67f1bda3f71d188c7f91
This commit is contained in:
parent
8b9281c90a
commit
04cf765d30
@ -102,8 +102,13 @@ class BlocklistClient {
|
||||
});
|
||||
}
|
||||
|
||||
get identifier() {
|
||||
return `${this.bucketName}/${this.collectionName}`;
|
||||
}
|
||||
|
||||
get filename() {
|
||||
return `${this.bucketName}/${this.collectionName}.json`;
|
||||
const identifier = OS.Path.join(...this.identifier.split("/"));
|
||||
return `${identifier}.json`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,5 @@
|
||||
const { Constructor: CC } = Components;
|
||||
|
||||
const KEY_PROFILEDIR = "ProfD";
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
@ -58,9 +56,10 @@ function* clear_state() {
|
||||
yield sqliteHandle.close();
|
||||
}
|
||||
|
||||
// Remove profile data.
|
||||
const path = OS.Path.join(OS.Constants.Path.profileDir, client.filename);
|
||||
yield OS.File.remove(path, { ignoreAbsent: true });
|
||||
// Remove JSON dumps folders in profile dir.
|
||||
const dumpFile = OS.Path.join(OS.Constants.Path.profileDir, client.filename);
|
||||
const folder = OS.Path.dirname(dumpFile);
|
||||
yield OS.File.removeDir(folder, { ignoreAbsent: true });
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +131,8 @@ add_task(clear_state);
|
||||
|
||||
add_task(function* test_list_is_written_to_file_in_profile() {
|
||||
for (let {client, testData} of gBlocklistClients) {
|
||||
const profFile = FileUtils.getFile(KEY_PROFILEDIR, client.filename.split("/"));
|
||||
const filePath = OS.Path.join(OS.Constants.Path.profileDir, client.filename);
|
||||
const profFile = new FileUtils.File(filePath);
|
||||
strictEqual(profFile.exists(), false);
|
||||
|
||||
yield client.maybeSync(2000, Date.now(), {loadDump: false});
|
||||
@ -157,7 +157,8 @@ add_task(clear_state);
|
||||
add_task(function* test_update_json_file_when_addons_has_changes() {
|
||||
for (let {client, testData} of gBlocklistClients) {
|
||||
yield client.maybeSync(2000, Date.now() - 1000, {loadDump: false});
|
||||
const profFile = FileUtils.getFile(KEY_PROFILEDIR, client.filename.split("/"));
|
||||
const filePath = OS.Path.join(OS.Constants.Path.profileDir, client.filename);
|
||||
const profFile = new FileUtils.File(filePath);
|
||||
const fileLastModified = profFile.lastModifiedTime = profFile.lastModifiedTime - 1000;
|
||||
const serverTime = Date.now();
|
||||
|
||||
@ -192,7 +193,8 @@ add_task(clear_state);
|
||||
add_task(function* test_do_nothing_when_blocklist_is_up_to_date() {
|
||||
for (let {client} of gBlocklistClients) {
|
||||
yield client.maybeSync(2000, Date.now() - 1000, {loadDump: false});
|
||||
const profFile = FileUtils.getFile(KEY_PROFILEDIR, client.filename.split("/"));
|
||||
const filePath = OS.Path.join(OS.Constants.Path.profileDir, client.filename);
|
||||
const profFile = new FileUtils.File(filePath);
|
||||
const fileLastModified = profFile.lastModifiedTime = profFile.lastModifiedTime - 1000;
|
||||
const serverTime = Date.now();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user