зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1354016 - Forms validator ignore clientMissing. r=tcsc
MozReview-Commit-ID: C2FD58C9HzS --HG-- extra : rebase_source : f5b627342e7fa4915914cbfd3e54003fe6d94c1e
This commit is contained in:
Родитель
0869a243b9
Коммит
19362d0bfa
|
@ -52,6 +52,12 @@ class CollectionValidator {
|
|||
this.name = name;
|
||||
this.props = props;
|
||||
this.idProp = idProp;
|
||||
|
||||
// This property deals with the fact that form history records are never
|
||||
// deleted from the server. The FormValidator subclass needs to ignore the
|
||||
// client missing records, and it uses this property to achieve it -
|
||||
// (Bug 1354016).
|
||||
this.ignoresMissingClients = false;
|
||||
}
|
||||
|
||||
// Should a custom ProblemData type be needed, return it here.
|
||||
|
@ -177,7 +183,7 @@ class CollectionValidator {
|
|||
if (!client && !server) {
|
||||
throw new Error("Impossible: no client or server record for " + id);
|
||||
} else if (server && !client) {
|
||||
if (server.understood) {
|
||||
if (!this.ignoresMissingClients && server.understood) {
|
||||
problems.clientMissing.push(id);
|
||||
}
|
||||
} else if (client && !server) {
|
||||
|
|
|
@ -266,6 +266,7 @@ class FormsProblemData extends CollectionProblemData {
|
|||
class FormValidator extends CollectionValidator {
|
||||
constructor() {
|
||||
super("forms", "id", ["name", "value"]);
|
||||
this.ignoresMissingClients = true;
|
||||
}
|
||||
|
||||
emptyProblemData() {
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Components.utils.import("resource://services-sync/engines/forms.js");
|
||||
|
||||
function getDummyServerAndClient() {
|
||||
return {
|
||||
server: [
|
||||
{
|
||||
id: "11111",
|
||||
guid: "11111",
|
||||
name: "foo",
|
||||
fieldname: "foo",
|
||||
value: "bar",
|
||||
},
|
||||
{
|
||||
id: "22222",
|
||||
guid: "22222",
|
||||
name: "foo2",
|
||||
fieldname: "foo2",
|
||||
value: "bar2",
|
||||
},
|
||||
{
|
||||
id: "33333",
|
||||
guid: "33333",
|
||||
name: "foo3",
|
||||
fieldname: "foo3",
|
||||
value: "bar3",
|
||||
},
|
||||
],
|
||||
client: [
|
||||
{
|
||||
id: "11111",
|
||||
guid: "11111",
|
||||
name: "foo",
|
||||
fieldname: "foo",
|
||||
value: "bar",
|
||||
},
|
||||
{
|
||||
id: "22222",
|
||||
guid: "22222",
|
||||
name: "foo2",
|
||||
fieldname: "foo2",
|
||||
value: "bar2",
|
||||
},
|
||||
{
|
||||
id: "33333",
|
||||
guid: "33333",
|
||||
name: "foo3",
|
||||
fieldname: "foo3",
|
||||
value: "bar3",
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
add_test(function test_valid() {
|
||||
let { server, client } = getDummyServerAndClient();
|
||||
let validator = new FormValidator();
|
||||
let { problemData, clientRecords, records, deletedRecords } =
|
||||
validator.compareClientWithServer(client, server);
|
||||
equal(clientRecords.length, 3);
|
||||
equal(records.length, 3)
|
||||
equal(deletedRecords.length, 0);
|
||||
deepEqual(problemData, validator.emptyProblemData());
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
||||
add_test(function test_formValidatorIgnoresMissingClients() {
|
||||
// Since history form records are not deleted from the server, the
|
||||
// |FormValidator| shouldn't set the |missingClient| flag in |problemData|.
|
||||
let { server, client } = getDummyServerAndClient();
|
||||
client.pop();
|
||||
|
||||
let validator = new FormValidator();
|
||||
let { problemData, clientRecords, records, deletedRecords } =
|
||||
validator.compareClientWithServer(client, server);
|
||||
|
||||
equal(clientRecords.length, 2);
|
||||
equal(records.length, 3);
|
||||
equal(deletedRecords.length, 0);
|
||||
|
||||
let expected = validator.emptyProblemData();
|
||||
deepEqual(problemData, expected);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
|
@ -158,6 +158,7 @@ requesttimeoutfactor = 4
|
|||
[test_forms_tracker.js]
|
||||
# Too many intermittent "ASSERTION: thread pool wasn't shutdown: '!mPool'" (bug 804479)
|
||||
skip-if = debug
|
||||
[test_form_validator.js]
|
||||
[test_history_store.js]
|
||||
[test_history_tracker.js]
|
||||
# Too many intermittent "ASSERTION: thread pool wasn't shutdown: '!mPool'" (bug 804479)
|
||||
|
|
Загрузка…
Ссылка в новой задаче