Closed Bug 593689 Opened 15 years ago Closed 15 years ago

new Image(undefined) should not fire an error

Categories

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

x86
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla2.0b7

People

(Reporter: espadrine, Assigned: bzbarsky)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b6pre) Gecko/20100904 Firefox/4.0b6pre Build Identifier: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b6pre) Gecko/20100904 Firefox/4.0b6pre Having a script that uses the constructor of an image (var foo = new Image(undefined);) yields an error: "can't convert undefined into an integer". Reproducible: Always Steps to Reproduce: 1. Go to the error console. 2. Evaluate "new Image(undefined)" 3. See the following error: "Can't convert undefined to an integer". Actual Results: An error is fired, "Error: can't convert undefined to an integer". Expected Results: No error should be fired. Undefined should be interpreted as 0.
Should we be using JS_ValueToECMAUint32 here instead of JS_ValueToInt32? The former treats NaN (which is what we have here) as 0 instead of as an error...
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch FixSplinter Review
Attachment #472676 - Attachment description: . Convert arguments to new Image() to integers the way other conversions to integer happen. → Fix
Attachment #472676 - Flags: review?(jst)
Whiteboard: [needs review]
Assignee: nobody → bzbarsky
Priority: -- → P1
Whiteboard: [needs review] → [need review]
Comment on attachment 472676 [details] [diff] [review] Fix Yup, this makes us match IE in this regard, so I think we should take this change.
Attachment #472676 - Flags: review?(jst)
Attachment #472676 - Flags: review+
Attachment #472676 - Flags: approval2.0+
Whiteboard: [need review] → [need landing]
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b6
Whiteboard: [need landing]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: