Closed Bug 16605 Opened 26 years ago Closed 23 years ago

text node child-adding functions throw wrong exception

Categories

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

defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: dbaron, Assigned: fabian)

Details

(Keywords: testcase, Whiteboard: [HAVE FIX])

Attachments

(2 files)

DESCRIPTION: When the functions insertBefore(), replaceChild(), and appendChild() are called on a text node, they are currently throwing NO_MODIFICATION_ALLOWED_ERR. Really, from my reading of the spec they should be throwing HIERARCHY_REQUEST_ERR (in the case of replaceChild(), for 2 reasons: the oldChild isn't a child of the text node and it can't take children!). STEPS TO REPRODUCE: * Load http://www.fas.harvard.edu/~dbaron/dom/test/one-core-html/exceptions or http://www.fas.harvard.edu/~dbaron/dom/test/one-core-xml/exceptions * Hit "test" ACTUAL RESULTS: * The first test under each of the following bold headers is red: + "Testing exception throwing in Node::insertBefore():" + "Testing exception throwing in Node::replaceChild():" + "Testing exception throwing in Node::appendChild():" EXPECTED RESULTS: * Those 3 tests should be green DOES NOT WORK CORRECTLY ON: * Linux, viewer, 1999-10-15-11-M11
In an attempt to get my bug list in order again, marking all the bugs I have currently as ASSIGNED.
From looking at the code it seems like RemoveChild() has the same problem, IMO RemoveChild() should return NOT_FOUND_ERR and not NO_MODIFICATION_ERR since the child simply is not there! I created a patch, I'll attach it as soon as I can verify that it works, right now I'm unable to access harvard.edu!
OS: Linux → All
Hardware: PC → All
This is not linux specific.
I'll attach a patch soon that fixes these problems (and adds some NULL pointer checks). The patch does not completely fix dbarons tests because IMO ReplaceChild() on a text node should throw NOT_FOUND_ERR and not HERARCHY_REQUEST_ERR since the child is simply not there! The patch also fixes RemoveChild(). I don't know if this ReplaceChild() behavior is correct or not, comments?
Attached patch Proposed fix.Splinter Review
Johnny, your patch looks fine, but you should consider using the macros NS_ENSURE_ARG and NS_ENSURE_ARG_POINTER.
Whiteboard: [HAVE FIX]
Target Milestone: M15
The fix for this is checked in now. Marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Mass update of qa contact
QA Contact: gerardok → janc
Component: DOM Level 1 → DOM HTML
QA contact Update
QA Contact: janc → desale
Updating QA contact to Shivakiran Tummala.
QA Contact: desale → stummala
replaceChild does not throw the rite exception ...used the testcases provided at the URL http://www.fas.harvard.edu/~dbaron/dom/test/one-core-html/exceptions and http://www.fas.harvard.edu/~dbaron/dom/test/one-core-xml/exceptions ... reopening bug
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
0x80530008 looks like NS_ERROR_DOM_NOT_FOUND_ERR.
Reassigning to jst.
Assignee: vidur → jst
Status: REOPENED → NEW
simply change NS_ERROR_DOM_NOT_FOUND_ERR to NS_ERROR_DOM_HIERARCHY_REQUEST_ERR at http://lxr.mozilla.org/mozilla/source/content/base/src/nsGenericDOMDataNode.h#102
jst, I don't know what you think, but it seems the spec is unclear here dbaron's test does the following: textNode.replaceChild(document.createElement("p"), null); We throw NOT_FOUND_ERR all the time because it's impossible that oldChild (null in the testcase) be a child of this text node. However we could as well throw HIERARCHY_REQUEST_ERR since newChild (a paragraph element in this case) can never become a child of this node. We can chose...
More realistic milestone (M15? Sounds like stone age). Adding [invalid?] to whiteboard to remember to take a decision. Priority P4. Sending to DOM Core, not a DOM HTML issue.
Component: DOM HTML → DOM Core
Keywords: testcase
Priority: P3 → P4
Whiteboard: [HAVE FIX] → [HAVE FIX] [invalid?]
Target Milestone: M15 → mozilla1.0
Fabian, we should have a look at the W3C tests and see what they expect, if they don't care, then we can go either way... I'm handing this over to you, and it's up to you to decide what to do about this now :-)
Assignee: jst → hidday
I just realized my previous comment did not make sense: when null is passed as refChild, we have to appendChild(), so we should not throw NOT_FOUND_ERR in any case. Even though the DOM1 test suite does not explicitely test this, they make it clear they expect HIERARCHY_REQUEST_ERR. Patch coming up.
Status: NEW → ASSIGNED
Whiteboard: [HAVE FIX] [invalid?] → [HAVE FIX]
Attached patch Proposed fix.Splinter Review
Patch modifies nsGenericDOMDataNode::ReplaceChild to throw HIERARCHY_REQUEST_ERR instead of NOT_FOUND_ERR
Comment on attachment 70091 [details] [diff] [review] Proposed fix. sr=jst. IMO this can go in as is, no r= needed for this trivial fix.
Attachment #70091 - Flags: superreview+
Attachment #70091 - Flags: review+
a=asa (on behalf of drivers) for checkin to 0.9.9
Keywords: mozilla0.9.9+
Checked in, marking FIXED. Off with this one's head.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago23 years ago
Resolution: --- → FIXED
verified fixed. insertBefore(), replaceChild nad appendChild() are throwing right exceptions.
Status: RESOLVED → VERIFIED
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: