Closed Bug 276880 Opened 20 years ago Closed 20 years ago

[FIXr]accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.8alpha6

People

(Reporter: martin.honnen, Assigned: bzbarsky)

References

Details

Attachments

(2 files)

The W3C DOM Level 3 Core specification in
<http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent>
defines a property textContent for nodes and according to
https://bugzilla.mozilla.org/show_bug.cgi?id=210451 Christopher A. Aillon
implemented that property in Mozilla.
However when I try to access that property on a dynamically created node (in the
test case an element node) that has not yet been inserted into the document then
Mozilla throws an error:

Error: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOM3Node.textContent]"  nsresult: "0x80004005
(NS_ERROR_FAILURE)"  location: "JS frame ::
http://localhost/javascript/test2005010302.html :: testReading :: line 12" 
data: no]
Source File: http://localhost/javascript/test2005010302.html
Line: 12

That happens with both Mozilla 1.7.5 (the latest release at the time of this bug
report) as well as with the current nightly (which is Mozilla 1.8a6
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a6) Gecko/20050102).

I do not see anything in the DOM specification that suggests that accessing the
property on a node not inserted into the document should cause an error
therefore I file this bug.

I am going to attach the test case next.
Maybe nsNode3Tearoff::GetTextContent should use GetOwnerDocument instead of
GetDocument?
Summary: accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error → accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error
Attached patch AbsolutelySplinter Review
Assignee: general → bzbarsky
Status: NEW → ASSIGNED
Attachment #170163 - Flags: superreview?(peterv)
Attachment #170163 - Flags: review?(peterv)
Summary: accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error → [FIX]accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error
Target Milestone: --- → mozilla1.8beta
Attachment #170163 - Flags: superreview?(peterv)
Attachment #170163 - Flags: superreview+
Attachment #170163 - Flags: review?(peterv)
Attachment #170163 - Flags: review+
Summary: [FIX]accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error → [FIXr]accessing textContent property of dynamically created node not yet inserted into the document causes NS_ERROR_FAILURE error
Fixed on trunk.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.8beta → mozilla1.8alpha6
Verified that test case https://bugzilla.mozilla.org/attachment.cgi?id=170158
now works with
Mozilla 1.8a6 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a6)
Gecko/20050105).
Status: RESOLVED → VERIFIED
*** Bug 296101 has been marked as a duplicate of this bug. ***
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: