viewer freezes when javascript in infinite loops

VERIFIED DUPLICATE of bug 13350

Status

()

Core
DOM: Core & HTML
P3
normal
VERIFIED DUPLICATE of bug 13350
20 years ago
11 years ago

People

(Reporter: dbaron, Assigned: vidur (gone))

Tracking

Trunk
x86
Windows 95
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [TESTCASE])

Attachments

(1 attachment)

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);
		}
	}
}

Comment 1

20 years ago
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?

Comment 2

20 years ago
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)

Updated

20 years ago
Assignee: norris → vidur
(Assignee)

Comment 3

20 years ago
Nope. That still needs to be done.

Updated

20 years ago
QA Contact: 4590 → 4015

Updated

20 years ago
QA Contact: 4015 → 4616
(Assignee)

Updated

20 years ago
Target Milestone: M6
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
Target Milestone: M6 → M7

Updated

19 years ago
Component: JavaScript → DOM Level 0

Comment 4

19 years ago
Moving to DOM Level 0 component.  Move to DOM Level 1 or Javascript Engine if
that is more correct.
(Assignee)

Updated

19 years ago
Target Milestone: M7 → M9
(Assignee)

Comment 5

19 years ago
The branch callback will happen in M9.

Comment 6

19 years ago
Created attachment 1103 [details]
simple infinite loop test - CLICK AT YOUR OWN RISK!!

Updated

19 years ago
Whiteboard: [TESTCASE]

Comment 7

19 years ago
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.
(Assignee)

Updated

19 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → DUPLICATE
(Assignee)

Comment 9

19 years ago
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 ***

Updated

19 years ago
Status: RESOLVED → VERIFIED

Comment 10

19 years ago
Marking verified.
You need to log in before you can comment on or make changes to this bug.