Closed Bug 377413 Opened 18 years ago Closed 10 years ago

Dynamic delete of form elements leaves references sometimes - add tests for this old bug to guard against regressions

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: lmb, Unassigned)

References

()

Details

Attachments

(2 files, 4 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 The URL above is a somewhat simple application that inserts and deletes rows in a table using JavaScript. Rows all contain form input fields. Any reference to an existing form element - statically created, or dynamically created using innerHTML or document.createElement("input") - causes the element to become somewhat indelible. Deleting the table row containing the input field (or even deleting the input element itself and then deleting the row) leaves a residual reference for any element that had been referenced while it existed. The referenced URL document contains several sample tests that can be run. URL contains all necessary JavaScript and HTML. Reproducible: Always Steps to Reproduce: 1. See referenced URL - steps to reproduce are contained within the document. Actual Results: If, after creating an input element (using innerHTML or createElement), you reference it by testing for existence or assigning a value, then subsequent deletion (via table deleteRow or via getElementById(elementid).parentNode.removeChild(getElementById(elementid)) ) does not completely delete all references to element; a test still yields a true result for document.formname.elementname, though you can no longer getElementById(elementid), and the element does not appear anywhere in the DOM Inspector. Expected Results: No references should remain for the deleted element. IE7 correctly renders this result. Tested on Firefox 2.0.0.3 on WinXP and Mac OS X, as well as Firefox 1.5.0.11 WinXP.
Version: unspecified → 2.0 Branch
Tested. Still exists.
Assignee: nobody → general
Component: General → DOM: HTML
Product: Firefox → Core
QA Contact: general → ian
Version: 2.0 Branch → Trunk
Bug 307415 is very similar to this bug.
In this instance, the form property was no longer visible in the DOM Inspector after removal of the element. However, the effect was almost identical - the old element still appeared to have a property the form when doing programmatic testing. I agree, #307415 does appear to be almost identical.
Component: DOM: HTML → DOM: Core & HTML
QA Contact: ian → general
Added test case back to web server (was accidentally deleted during cleanup).
Assignee: general → nobody
Original test is gone but I wrote a small test case and this seems to have been fixed at some point.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Attached patch bug_377413_test.patch (obsolete) — Splinter Review
Attaching a patch for adding mochitests for this bug
I've tried to add some tests. I'm not sure if existing tests cover this (might quite possibly do) (at least it was a useful learning exercise for me to figure out how to add tests to the codebase). Could someone - maybe billm, bz or jmaher - take a look and decide whether it's useful to add this patch to mozilla-central? TIA.
Flags: needinfo?(jmaher)
A few things to consider: 1) is this going to run reliably on desktop, android, and b2g? 2) do we have similar coverage in other tests (most likely in the same directory) I am not sure about either of these questions, but if this test provides us coverage which we do not have, lets get it added. We can always use the manifest to turn it off on platforms where it doesn't run (although I suspect this specific test case will run fine on all platforms).
Flags: needinfo?(jmaher)
(In reply to Joel Maher (:jmaher) from comment #10) > 1) is this going to run reliably on desktop, android, and b2g? I can think of no reasons it won't, (and if it doesn't that might indicate a bug..) it tests core DOM stuff that should work consistently. > 2) do we have similar coverage in other tests (most likely in the same > directory) I was hoping somebody with knowledge of those tests could answer that so I would not have to read everything ;-)
(That said, having looked at all file names and opened some of them I didn't find equivalent tests)
I would ask for a review from someone who has reviewed similar tests. Also push to try and ensure it works as you expect.
Try server output: https://tbpl.mozilla.org/?tree=Try&rev=0b7b1e16c29c There is one entry here saying the test ran ok on Fx Android: https://tbpl.mozilla.org/php/getParsedLog.php?id=38313881&tree=Try&full=1 but I don't find an easy way to find all results for this test across builds.
Flags: needinfo?(Ms2ger)
Ms2ger: Sorry for needinfo'ing you without comment - I meant to ask for a review since you've reviewed some of the other tests here.
I'd much rather you wrote testharness.js tests, fwiw ;)
Well, given that I know testharness.js much better than this mochitest thingy I'm perfectly happy to do so :-p - how/where? Do testharness.js test suites live in mozilla-central repo?
Just include /resources/testharness.js and /resources/testharnessreport.js, and put the test in a mochitest-plain manifest (like you did here).
Flags: needinfo?(Ms2ger)
Attached patch bug_377413_test_2.patch (obsolete) — Splinter Review
Does that help?
Attachment #8410120 - Attachment is obsolete: true
Flags: needinfo?(Ms2ger)
Comment on attachment 8419906 [details] [diff] [review] bug_377413_test_2.patch Review of attachment 8419906 [details] [diff] [review]: ----------------------------------------------------------------- LGTM, thanks, and sorry for forgetting about your needinfo. ::: content/html/content/test/forms/test_377413.html @@ +29,5 @@ > +test(function(){ > + tb.innerHTML = '<tr><td><input name="fooboo"></td></tr>'; > + document.forms[0].fooboo.value = 'testme'; > + document.getElementsByTagName('table')[0].deleteRow(0); > + assert_true(typeof document.forms[0].fooboo === 'undefined') assert_equals(document.forms[0].fooboo, undefined); @@ +44,5 @@ > +}, 'element name has created property on form'); > + > +test(function(){ > + tb.innerHTML = ''; > + assert_true(! ( 'boofoo' in document.forms[0])) assert_false
Attachment #8419906 - Flags: review+
Flags: needinfo?(Ms2ger)
Attached patch bug_377413_test_2.patch (obsolete) — Splinter Review
Review comments addressed now :)
Attachment #8419906 - Attachment is obsolete: true
Gah, looks like I missed the fact that you didn't add the test to the mochitest.ini in that dir. Please fix that and update the commit message.
Keywords: checkin-needed
Attached patch bug_377413_test_2.patch (obsolete) — Splinter Review
D'oh
Attachment #8419968 - Attachment is obsolete: true
and now with a better description..
Attachment #8420103 - Attachment is obsolete: true
Should I reopen this bug to make sure people see the checkin-needed keyword?
Flags: needinfo?(Ms2ger)
As a minimum, you shouldn't resolve a bug as WFM when there is actually work done. Maybe you should modify the summary to reflect that you are just adding tests for this without modifying the code?
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: WORKSFORME → ---
I guess it would have been better to open another bug saying "add tests.."? Anyway, I had no idea contributing a simple test here would take so much time when I decided to use this bug to learn how to add tests. Hence I didn't re-open or report a new one. The real lesson I take away is: don't give Gecko tests, add them to W3C's web-platform-tests instead :-p
Summary: Dynamic delete of form elements leaves references sometimes → Dynamic delete of form elements leaves references sometimes - add tests for this old bug to guard against regressions
I've got it in my queue.
Based on comment 28, I'm assuming Ms2ger is going to take care of pushing this. Clearing checkin-needed to get it off our radar.
Keywords: checkin-needed
(In reply to Hallvord R. M. Steen from comment #27) > I guess it would have been better to open another bug saying "add tests.."? In general it's ok to retarget a bug in this way, thus no problem. However, you were sending mixed messages by resolving the bug, basically saying it's not a problem, and then you kept going.
Status: REOPENED → RESOLVED
Closed: 11 years ago10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Flags: needinfo?(Ms2ger)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: