Closed Bug 826302 Opened 12 years ago Closed 11 years ago

.valueAsDate should throw TypeError if passed something else than a Date

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: mounir, Assigned: mounir)

References

Details

Attachments

(1 file, 2 obsolete files)

      No description provided.
Blocks: 826305
No longer blocks: 825247
Depends on: 742206
Is this fixed now that bug 742206 landed?
Yes. Though I would like a test in content/html/content/test/forms/test_valueasdate_attribute.html before fixing the bug.
Attached patch Test (obsolete) — Splinter Review
The basic idea was already tested, we only need to test the error name ;)
Assignee: nobody → mounir
Status: NEW → ASSIGNED
Attachment #745233 - Flags: review?(bzbarsky)
Comment on attachment 745233 [details] [diff] [review]
Test

r=me

Do we need a followup bug on these bits:

354     // TODO: check the Date object value (UTCFullYear, UTCMonth and UTCDate)
355     // when .valueAsDate will stop returning null.
Attachment #745233 - Flags: review?(bzbarsky) → review+
Attached patch Test (obsolete) — Splinter Review
Let's do that here so we don't waste time with administrative overhead.
Attachment #745233 - Attachment is obsolete: true
Attachment #747403 - Flags: review?(bzbarsky)
Comment on attachment 747403 [details] [diff] [review]
Test

>+    is(element.valueAsDate.getUTCFullYear.toString(),
>+       Date.prototype.getUTCFullYear.toString(), "prototype is the same");

Why the toString bits for the methods?

>+    is(element.valueAsDate.toString(), witnessDate.toString(), "correct Date");

And here?
Flags: needinfo?(mounir)
(In reply to Boris Zbarsky (:bz) from comment #6)
> Comment on attachment 747403 [details] [diff] [review]
> Test
> 
> >+    is(element.valueAsDate.getUTCFullYear.toString(),
> >+       Date.prototype.getUTCFullYear.toString(), "prototype is the same");
> 
> Why the toString bits for the methods?

This is indeed not needed.

> >+    is(element.valueAsDate.toString(), witnessDate.toString(), "correct Date");
> 
> And here?

.valueAsDate and witnessDate do not return the same object. .toString() is a simple way to check that those objects have the same value. I do not know if the objects are supposed to be seen equals when they have the same value even if they are not the same but it is possible that Mochitests have special path in is() for objects to check that they are the same instance.
Flags: needinfo?(mounir)
Attached patch TestSplinter Review
Attachment #747403 - Attachment is obsolete: true
Attachment #747403 - Flags: review?(bzbarsky)
Attachment #747962 - Flags: review?(bzbarsky)
Comment on attachment 747962 [details] [diff] [review]
Test

Oh, I see.  I'd prefer we use valueOf() there, not toString(), then.

r=me with that.
Attachment #747962 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/da886ed177a6
Flags: in-testsuite+
Target Milestone: --- → mozilla24
https://hg.mozilla.org/mozilla-central/rev/da886ed177a6
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: