Bug 1019885 - Fix broken import of disabled hosts from previous profiles. r=dolske

This commit is contained in:
Paolo Amadini 2014-06-05 16:44:42 +01:00
parent a1498cb1b0
commit b160100f46
3 changed files with 28 additions and 8 deletions

View File

@ -165,10 +165,7 @@ this.LoginImport.prototype = {
let id = row.getResultByName("id");
let hostname = row.getResultByName("hostname");
this.store.data.disabledHosts.push({
id: this.store.data.nextId++,
hostname: hostname,
});
this.store.data.disabledHosts.push(hostname);
} catch (ex) {
Cu.reportError("Error importing disabled host: " + ex);
}

View File

@ -267,6 +267,31 @@ LoginStore.prototype = {
// Indicate that the current version of the code has touched the file.
this.data.version = kDataVersion;
// Due to bug 1019885, invalid data was created by the import process in
// Nightly. This automated procedure fixes the error. This is provided as
// a convenience to Nightly users and can be safely removed after Nightly
// users are updated to the new version.
let originalDisabledHosts = this.data.disabledHosts;
if (originalDisabledHosts.some(hostItem => typeof hostItem != "string")) {
this.data.disabledHosts = [];
for (let hostItem of originalDisabledHosts) {
// Fix each item if it is in the broken format.
if (typeof hostItem != "string") {
hostItem = hostItem.hostname;
}
// Ensure we don't create duplicates in the process.
if (this.data.disabledHosts.indexOf(hostItem) == -1) {
this.data.disabledHosts.push(hostItem);
}
}
// Ensure the updated data is saved.
this.saveSoon();
}
this.dataReady = true;
},

View File

@ -170,10 +170,8 @@ add_task(function test_import()
// Verify that disabled hosts have been imported.
do_check_eq(store.data.disabledHosts.length, 2);
do_check_true(store.data.disabledHosts.some(
dataItem => dataItem.hostname == "http://www.example.com"));
do_check_true(store.data.disabledHosts.some(
dataItem => dataItem.hostname == "https://www.example.org"));
do_check_true(store.data.disabledHosts.indexOf("http://www.example.com") != -1);
do_check_true(store.data.disabledHosts.indexOf("https://www.example.org") != -1);
});
/**