Closed Bug 94308 Opened 23 years ago Closed 22 years ago

document.write document.documentElement properties causes infinite loop

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED INVALID
Future

People

(Reporter: basic, Unassigned)

Details

(Keywords: hang)

Attachments

(1 file)

Got this from the n.p.m.dom newsgroup The code below throws moz into an infinite loop. It might be related or dup of bug 92425 <script type="text/JavaScript" language="javascript"> function propertySlideShow(anyObject) { var s = ""; for (var prop in anyObject){s = prop + " = " + anyObject[prop] + "\n\n";document.write(s)} } propertySlideShow(document.documentElement) </script>
Attached file testcase
This cause an error for me (was previously working): with (window.frames[0].document) { open(); write('foo'); close(); } The error is (note nsIDOMNSHTMLDocument.write part) ###*** Error/XPConnect JavaScript: chrome://komodo/content/editor/scintillaview. js(485): [Exception... "Component returned failure code: 0x804e03f7 [nsIDOMNSHTM LDocument.write]" nsresult: "0x804e03f7 (<unknown>)" location: "JS frame :: ch rome://komodo/content/editor/scintillaview.js :: anonymous :: line 485" data: n o] ###*** Warning/: chrome://komodo/content/koGlobalOverlay.js(202): An error occur red executing the cmd_print command\012[Exception... "Component returned failure code: 0x804e03f7 [nsIDOMNSHTMLDocument.write]" nsresult: "0x804e03f7 (<unknown >)" location: "JS frame :: chrome://komodo/content/editor/scintillaview.js :: a nonymous :: line 485" data: no]
Not DOM Events -> JS Engine for initial debugging. Phil, I really need your help on this one. I tried to figure out where we hang, but neither gdb nor the debugger on windows give any useful information (the stacktrace is somewhere in nspr land). Also note that we don't hang if I call that script from an onclick in a button (after the page has loaded). I'm really at a loss here. Feel free to reassign to.. hmm.. DOM0 I guess if it isn't the js engine fault
Assignee: joki → rogerl
Component: DOM Events → Javascript Engine
QA Contact: vladimire → pschwartau
The problem is this: As the page is loading, propertySlideShow() accesses all the enumerable properties of document.documentElement and document.writes each one. But then each of these strings become new properties of document.documentElement! So the loop can never end. I would like to say this is just a coding error. But then why do NN4.7 and IE4.7 load the testcase and finish, whereas Mozilla hangs? Reassigning to DOM Level 0 for further analysis -
Component: Javascript Engine → DOM Level 0
Keywords: hang
Really reassigning
Assignee: rogerl → jst
QA Contact: pschwartau → amar
Future.
Target Milestone: --- → Future
Phil: maybe because NN4.7 and IE4.7 does not implement document.documentElement ? in WinIE5.0 sometimes the testcase finish loading with a blank page, sometimes filled with properties = values and sometimes never finish loading at all.
That's right, NN4x did not have a document.documentElement property, not sure about IE4...
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
I agree with comment 4. This is a coding error. To examine the props, you'll have to open a new window. // loop through a collection for (var prop in anyObject) { s = prop + " = " + anyObject[prop] + "\n\n"; // modify the collection. document.write(s)} } This should cause infinite recursion. try writing to a new window. var x = window.open(); for(prop in obj) x.document.writeln(prop + " = " + anyObject[prop] + "\n\n"); Can we mark this INVALID?
Okay. marking invalid. If anyone disagrees, please explain why it is a Mozilla bug and then feel free to re-open.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: