Closed
Bug 258463
Opened 21 years ago
Closed 21 years ago
appendChild Component returned failure code: 0x80004003 NS_ERROR_INVALID_POINTER
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: historystamp, Unassigned)
Details
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624 Netscape/7.1
Build Identifier: Mozilla 1.8a4 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8a4) Gecko/20040907
I run the html file you see in the Additional Information section. This message
is displayed in the javascript console:
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLBodyElement.appendChild]"
nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame ::
file:///Users/mac/Desktop/Try/firefox%20exception.html :: <TOP_LEVEL> :: line
31" data: no]
The problem arrises because I pass appendChild a variable with a non-existant
property.
I tried this in:
Mozilla 1.8a4
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8a4) Gecko/20040907
While the Javascript code is in error, I would expect to see a message about a
missing property.
I got the same results in Netscape 7.1 and Firefox 0.9.3.
Thanks. This is my first but submission.
Reproducible: Always
Steps to Reproduce:
I wrote the script seen in the Additional Information section.
Just run the file. The error occurs every time.
The code does:
1) Opens a new window. You need to have popup windows enabled, I think.
2) Creates a new paragraph node in the new window via createElement
3) Invoke appendChild with a valid variable name but with an undefined property.
Display the javascript console.
To get this error, you seems to have to use a function name for the variable name.
Actual Results:
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLBodyElement.appendChild]"
nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame ::
file:///Users/mac/Desktop/Try/firefox%20exception.html :: <TOP_LEVEL> :: line
31" data: no]
Expected Results:
I would expect a message about a missing or non-existant property.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>generates an exception</title>
<script type="text/javascript">
function startDebug()
{
startDebug.newWindow = window.open(
"javascript:opener.init();",
"debug",
"scrollbars=yes,resizable=yes,width=700,height=500");
}
function init(debugWindowName)
{
;
}
</SCRIPT>
</head>
<body>
<script>
startDebug();
var append;
append = document.createElement("p");
startDebug.newWindow.document.body.appendChild(startDebug.append);
</script>
<p>The Javascript code references an undefined variable.
Never-the-less, it should not
generate an exception.</p>
<p>Error: uncaught exception: [Exception...
"Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER)
[nsIDOMHTMLBodyElement.appendChild]" nsresult: "0x80004003
(NS_ERROR_INVALID_POINTER)" location: "JS frame ::
file:///Users/mac/Desktop/Try/firefox%20exception.html :: <TOP_LEVEL> ::
line 31" data: no]</p>
</body>
</html>
![]() |
||
Comment 1•21 years ago
|
||
The behavior is correct. startDebug.append is undefined, so you're calling:
startDebug.newWindow.document.body.appendChild(undefined);
which does in fact need to throw, per the DOM spec (since you're not passing in
a valid DOMNode).
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Summary: appendChild Component returned failure code: 0x80004003 NS_ERROR_INVALID_POINTER → appendChild Component returned failure code: 0x80004003 NS_ERROR_INVALID_POINTER
Reporter | ||
Comment 2•21 years ago
|
||
(In reply to comment #1)
> The behavior is correct. startDebug.append is undefined, so you're calling:
>
> startDebug.newWindow.document.body.appendChild(undefined);
>
> which does in fact need to throw, per the DOM spec (since you're not passing in
> a valid DOMNode).
When I enter the line with a simple undefined variable like:
startDebug.newWindow.document.body.appendChild(unknown);
I get a console message of: Error: unknown is not defined
Source File: file:///Users/mac/Desktop/Try/firefox%20exception%20more.html
Line: 31
I would expect the same or similar error message in both cases. Perhaps the
object has no properties message.
Perhaps some component higher in the calling list should be catching the
exception and giving a more meaningful error message. Of course, to give a
generic error message without meaning is worse than a detailed message that you
get used to.
The error message doesn't read like a message the Javascript programmer should
receive. It read to me like a problem with the interpreter.
For comparision, I did:
try
{
var abc = new Object();
startDebug.newWindow.document.body.appendChild(abc.def);
}
catch (error)
{alert(error);}
try
{
startDebug.newWindow.document.body.appendChild(unknown);
}
catch (error)
{alert(error);}
try
{
startDebug.newWindow.document.body.appendChild(startDebug.append);
}
catch (error)
{alert(error);}
IE on the Mac gives object error
( but stops running when I ask to see the source. )
Safari gives DOM exception 8
I have found the Javascript error message confusing in general, so it seems I'll
have to add this one to the list.
Thanks for reviewing my comments.
Robert
![]() |
||
Comment 3•21 years ago
|
||
> When I enter the line with a simple undefined variable like:
"An undefined variable" and "the JS value 'undefined'" are not the same thing.
The W3C DOM does not define what exception should be thrown if
null/undefined/etc is passed to appendChild, so an application-specific
exception is thrown.
You need to log in
before you can comment on or make changes to this bug.
Description
•