Closed
Bug 370098
Opened 18 years ago
Closed 17 years ago
Some constructors raise a "XXX is not a function" exception when called (DOMParser, XMLSerializer, XMLHttpRequest, XPathEvaluator, XSLTProcessor)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
FIXED
mozilla1.9alpha5
People
(Reporter: asqueella, Assigned: peterv)
References
Details
(Keywords: testcase)
Attachments
(2 files, 4 obsolete files)
13.72 KB,
patch
|
Details | Diff | Splinter Review | |
2.09 KB,
patch
|
jst
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
> typeof DOMParser
function
> DOMParser()
TypeError on line 1: DOMParser is not a function
At least the following constructors are affected: DOMParser, XMLSerializer, XMLHttpRequest, XPathEvaluator, XSLTProcessor. Might be worth checking constructors registered via "JavaScript global constructor" category.
Calling these constructors definitely shouldn't say they are not functions, since they are. shaver says they should either throw or just create an object as when called as constructors (this is what some of native JS objects do).
Assignee | ||
Comment 1•18 years ago
|
||
This makes calling them as functions work. Note that all DOM prototype objects are of type function, even when they're not callable/constructable. We could easily change that, but not sure what the side-effects will be or whether we care.
Assignee: general → peterv
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•18 years ago
|
||
This one makes only constructable DOM classes return "Function" for typeof, others return "Object".
Assignee | ||
Comment 3•18 years ago
|
||
Brendan or Blake: any idea what |typeof Element| should return if you can't really call |Element()| or |new Element()|?
Comment 4•18 years ago
|
||
(In reply to comment #3)
> Brendan or Blake: any idea what |typeof Element| should return if you can't
> really call |Element()| or |new Element()|?
"object"
If you can call Element(), then ECMA-262 says "function", but real-world browsers do not agree. We should err on the side of reality here and go with "object" unless IE and another browser or two say "function".
/be
Assignee | ||
Comment 5•18 years ago
|
||
Attachment #254799 -
Attachment is obsolete: true
Attachment #255928 -
Attachment is obsolete: true
Attachment #264044 -
Flags: superreview?(jst)
Attachment #264044 -
Flags: review?(jst)
Comment 6•18 years ago
|
||
Comment on attachment 264044 [details] [diff] [review]
v1.1
private:
+ nsresult GetNameStruct(const nsGlobalNameStruct **aNameStruct)
Looks like this, and the other method with the same signature, always return either NS_OK an a non-null aNameStruct, or NS_ERROR_UNEXPECTED on failure. Any reason not to make this method return a const nsGlobalNameStruct* and make the callers throw when necessary?
r+sr=jst with that considered.
Attachment #264044 -
Flags: superreview?(jst)
Attachment #264044 -
Flags: superreview+
Attachment #264044 -
Flags: review?(jst)
Attachment #264044 -
Flags: review+
Assignee | ||
Comment 7•18 years ago
|
||
(In reply to comment #6)
> Looks like this, and the other method with the same signature, always return
> either NS_OK an a non-null aNameStruct, or NS_ERROR_UNEXPECTED on failure. Any
> reason not to make this method return a const nsGlobalNameStruct* and make the
> callers throw when necessary?
Did that for the first, but not the second function, because that one sometimes returns NS_OK for a null aNameStruct (looking up the name worked but didn't return anything, so shouldn't throw).
Attachment #264044 -
Attachment is obsolete: true
Assignee | ||
Comment 8•18 years ago
|
||
Attachment #254757 -
Attachment is obsolete: true
Attachment #264235 -
Flags: review?(jst)
Reporter | ||
Updated•18 years ago
|
Flags: in-testsuite?
Target Milestone: --- → mozilla1.9alpha5
Comment 9•17 years ago
|
||
Comment on attachment 264235 [details] [diff] [review]
Mochitest
r+sr=jst
Attachment #264235 -
Flags: superreview+
Attachment #264235 -
Flags: review?(jst)
Attachment #264235 -
Flags: review+
Assignee | ||
Updated•17 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 10•17 years ago
|
||
The mochitest was checked in on 2007-05-25 09:06 and is passing here and on the tinderbox.
Status: RESOLVED → VERIFIED
Flags: in-testsuite? → in-testsuite+
Comment 11•17 years ago
|
||
Could this have caused bug 400366? I can't seem to find any relevant bugs in the regression window.
javascript:typeof Prototype
.. results in "object"
Assignee | ||
Comment 12•17 years ago
|
||
Yes, probably.
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•