new Image(undefined) should not fire an error

RESOLVED FIXED in mozilla2.0b7

Status

()

Core
DOM: Core & HTML
P1
normal
RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: espadrine, Assigned: bz)

Tracking

unspecified
mozilla2.0b7
x86
Mac OS X
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

8 years ago
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
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]
Pushed http://hg.mozilla.org/mozilla-central/rev/4a8e7348beba
Status: NEW → RESOLVED
Last Resolved: 8 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.