Closed
Bug 946294
Opened 11 years ago
Closed 11 years ago
Use sequences in the Contacts interfaces
Categories
(Core Graveyard :: DOM: Contacts, defect)
Core Graveyard
DOM: Contacts
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla29
People
(Reporter: reuben, Assigned: reuben)
References
Details
(Whiteboard: [qa-])
Attachments
(1 file, 1 obsolete file)
(deleted),
patch
|
bzbarsky
:
review+
gwagner
:
review+
|
Details | Diff | Splinter Review |
Bug 942631 finally allows us to have real arrays \o/
Assignee | ||
Comment 1•11 years ago
|
||
Need deps before tests pass.
Assignee | ||
Comment 2•11 years ago
|
||
Comment on attachment 8343334 [details] [diff] [review]
Use sequences for the array attributes
I did some tests using find() and 1500 contacts and this makes us ~8% faster, probably due to the manual validation with proxies that can be removed now.
Attachment #8343334 -
Flags: feedback?(anygregor)
Comment 3•11 years ago
|
||
Hmm.
save() might still need to do some sort of validation. In particular, unfortunately nothing guarantees that aContact.tel will only contain vanilla JS reflections of ContactTelField. It could have whatever the page stuck in there, right?
Assignee | ||
Comment 4•11 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #3)
> Hmm.
>
> save() might still need to do some sort of validation. In particular,
> unfortunately nothing guarantees that aContact.tel will only contain vanilla
> JS reflections of ContactTelField.
I hope not! Right now if I try to do something like this:
var c = new mozContact({tel: []});
c.tel.push({aeiou: "abcde"});
I get an empty object in save(). As long as there are no cross-compartment shenanigans, I think this is fine. There's only so much hand-holding we can do with the API users…
Comment 5•11 years ago
|
||
Reuben and I talked that part over. We do in fact need to do validation, but this will do it fine:
try {
for (let field of PROPERTIES) {
aContact[field] = aContact[field];
}
} catch (e) {
throw this._window.DOMError(e.name, e.message);
}
with some comments explaining why the "no-op" assignment and why the weird throwing behavior.
Assignee | ||
Updated•11 years ago
|
Attachment #8343334 -
Attachment is obsolete: true
Attachment #8343334 -
Flags: feedback?(anygregor)
Assignee | ||
Comment 7•11 years ago
|
||
Incorporates the changes to save() needed to make sure we validate everything in the sequences before we save the contact.
Attachment #8349615 -
Flags: review?(bzbarsky)
Comment 8•11 years ago
|
||
Comment on attachment 8349615 [details] [diff] [review]
Use sequences for the array attributes, v2
r=me, though I only skimmed the test changes.
Attachment #8349615 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 9•11 years ago
|
||
Comment on attachment 8349615 [details] [diff] [review]
Use sequences for the array attributes, v2
Thanks! Gregor, can you take a look? Specifically any unwanted changes to the behavior? The test changes cover the obvious ones. Something new that we may want to add a test for is the fact that save() can now throw if you pass a mozContact with invalid data.
Attachment #8349615 -
Flags: review?(anygregor)
Comment 10•11 years ago
|
||
(In reply to :Reuben Morais [slow to respond until Jan 10] from comment #9)
> Comment on attachment 8349615 [details] [diff] [review]
> Use sequences for the array attributes, v2
>
> Thanks! Gregor, can you take a look? Specifically any unwanted changes to
> the behavior? The test changes cover the obvious ones. Something new that we
> may want to add a test for is the fact that save() can now throw if you pass
> a mozContact with invalid data.
Hm thats a good question. I guess it should be similar to other APIs we design.
Ehsan, Jonas, any comments here?
But if it throws we should at least add a test case for it.
Flags: needinfo?(jonas)
Flags: needinfo?(ehsan)
Comment 11•11 years ago
|
||
I can't think of another difference except for save (and also remove) to start throwing if handed off an invalid object.
Flags: needinfo?(ehsan)
Throwing if you attempt to save something that isn't a valid contact sounds fine to me. As long as we are backwards compatible with old code.
I think we should even throw if the page attempts to use a simple string value where an array of strings is what the API normally uses. Though it's probably too late to make such a change now.
Flags: needinfo?(jonas)
Updated•11 years ago
|
Attachment #8349615 -
Flags: review?(anygregor) → review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 14•11 years ago
|
||
Comment 15•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Updated•11 years ago
|
Whiteboard: [qa-]
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•