Closed Bug 4042 Opened 26 years ago Closed 25 years ago

viewer freezes when javascript in infinite loops

Categories

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

x86
Windows 95
defect

Tracking

()

VERIFIED DUPLICATE of bug 13350

People

(Reporter: dbaron, Assigned: vidur)

Details

(Whiteboard: [TESTCASE])

Attachments

(1 file)

viewer freezes when javascript in infinite loops. Once it crashed my whole system (was that the same bug?). I don't think this behavior is desirable (although it is understandable). Here's the code (fixed version is commented out). The second file is altsel_dom.js (if you change it, you have to change the HTML). The crash is in RemoveAll() - the problem is that length never goes to zero (one of those weird things that I think is probably right). First File: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC- html40/strict.dtd"> <HTML> <HEAD> <TITLE>Alternate Stylesheet Selector Demonstration</TITLE> <LINK REL="stylesheet" HREF="http://www.w3.org/StyleSheets/Core/Ultramarine" TITLE="Ultramarine" TYPE="text/css"> <LINK rel="alternate stylesheet" HREF="http://www.w3.org/StyleSheets/Core/Steely" TITLE="Steely" TYPE="text/css"> <LINK rel="alternate stylesheet" HREF="http://www.w3.org/StyleSheets/Core/Oldstyle" TITLE="Oldstyle" TYPE="text/css"> <META http-equiv="Content-Script-Type" content="text/javascript"> <SCRIPT SRC="altsel_dom.js" TYPE="text/javascript"></SCRIPT> </HEAD> <BODY onLoad="UpdateSSList(document.getElementById('ssSelector'))"> <!-- can document be omitted here? --> <h1>Alternate Stylesheet Selector Demo</h1> <DIV> <FORM METHOD="GET" ACTION="dummy.cgi"> Selected stylesheet: <SELECT ID="ssSelector" onChange="selectStyleSheet(this)"> <OPTION SELECTED>This stylesheet selector requires JavaScript.</OPTION> </SELECT> <INPUT TYPE="button" onClick="UpdateSSList(document.getElementById ('ssSelector'))" value="Update"> <!-- can document be omitted here ? --> </FORM> </DIV> </BODY> </HTML> SECOND FILE: // copyright (c) 1999 L. David Baron // based on original by Chris Wilson function strISSContains ( str, word ) { // case-insensitive search for word as one of the space separated values // within str. // If word contains spaces, you won't get a match var list, i; list = str.toLowerCase().split(" "); word = word.toLowerCase(); for ( i = 0 ; i < list.length ; i++ ) { // D window.alert("comparing " + word + " with " + list [i]); // D if (word == list[i]) return 1; } return 0; } function selectStyleSheet( selector ) { var i; var title = selector.options[ selector.selectedIndex ].text; linkElements = document.getElementsByTagName("LINK"); for ( i = 0; i < linkElements.length; i++ ) { if ( strISSContains(linkElements.title, "stylesheet")) { if ( linkElements[ i ].title == title ) { linkElements[ i ].disabled = false; } else if ( linkElements[ i ].title != "" ) { linkElements[ i ].disabled = true; } } } } function UpdateSSList( selector ) { function RemoveAll () { //var j; //for (j=0; j < selector.length; j++ ) { //selector.remove(j); while (selector.length > 0) { selector.remove(0); } } function AddIfUnique( ssLink ) { var i, opt; for ( i = 0; i < selector.length; i++ ) { if ( selector.options[i].text == ssLink.title ) return; } //D window.alert("adding " + ssLink.title); opt = document.createElement("OPTION"); // must be uppercase // opt.text = ssLink.title; // THIS (opt.text) IS READONLY opt.label = ssLink.title; opt.value = ssLink.title; // could use document.createTextNode and opt.appendChild ?? window.alert("ssLink.title=" + ssLink.title); // window.alert("opt.text=" + opt.text); window.alert("opt.label=" + opt.label); // window.alert("selector.options[0].label="+selector.options [0].label); window.alert("selector.options[0].text="+selector.options [0].text); selector.add( opt , selector.options[ selector.length - 1] ); if ( ! ssLink.disabled ) // only one unique title may be enabled selector.selectedIndex = selector.length - 1; } function AddNone() { var opt; opt = document.createElement("OPTION"); // must be uppercase opt.text = "--NONE--"; selector.add( opt , null ); selector.selectedIndex = 0; } var j, linkElements; // XXX NEEDED selector.options.length = 0; // nonstandard RemoveAll(); AddNone(); linkElements = document.getElementsByTagName("LINK"); for ( j = 0; j < linkElements.length; j++ ) { // nonstandard ... if ( ( linkElements[ j ].title != "" ) && (strISSContains(linkElements [j].rel, "stylesheet")) ) { AddIfUnique( linkElements[j] ); //D window.alert("adding " + linkElements[j].title); } } }
Vidur, have you implemented a branch callback that will give the user the option to terminate long-running scripts as in earlier versions of Navigator?
Vidur, Tom, have you implemented a branch callback that will give the user the option to terminate long-running scripts as in earlier versions of Navigator?
Assignee: norris → vidur
Nope. That still needs to be done.
QA Contact: 4590 → 4015
QA Contact: 4015 → 4616
Target Milestone: M6
Status: NEW → ASSIGNED
Target Milestone: M6 → M7
Component: JavaScript → DOM Level 0
Moving to DOM Level 0 component. Move to DOM Level 1 or Javascript Engine if that is more correct.
Target Milestone: M7 → M9
The branch callback will happen in M9.
Whiteboard: [TESTCASE]
Loading the above page, and clicking the 'Lock it up' button does indeed lock the viewer. Vanilla M8 on Win98, but other platforms should be similar until the callback is in.
Target Milestone: M10 → M11
I'll take this one, if someone can tell me in general terms how to pop up the dialog and such.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → DUPLICATE
Shaver - branch callback work in on Brendan's list (see bug# 13350). I'm going to DUP this bug, but feel free to take it from Brendan. *** This bug has been marked as a duplicate of 13350 ***
Status: RESOLVED → VERIFIED
Marking verified.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: