зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1019885 - Fix broken import of disabled hosts from previous profiles. r=dolske
This commit is contained in:
Родитель
e929ac9097
Коммит
5423268143
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче