By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

Firefox dies on simple script

P: n/a
Is Firefox 1.0.1 within its rights to crash when presented with the
following script?

<html>
<head>
<script>
var foo="foo";
window.onerror=function( msg, url, line ) {
switch( msg ) {
default: break;
case foo: break;
}
}
</script></head></html>

I'm betting not; I'm planning to file a bug report.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
In article <d0**********@chessie.cirr.com>, at***@nospam.cyberspace.org
enlightened us with...
window.onerror=function( msg, url, line ) {
switch( msg ) {
default: break;
case foo: break;


Why is your default at the beginning?

Just curious.
--
--
~kaeli~
Shotgun wedding: A case of wife or death.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

P: n/a
kaeli <ti******@nospam.comcast.net> spoke thus:
Why is your default at the beginning?


In the actual code, the default case falls through to another case
after alerting the user appropriately.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #3

P: n/a
Christopher Benson-Manica wrote:
Is Firefox 1.0.1 within its rights to crash when presented with the
following script?

<html>
<head>
<script>
var foo="foo";
window.onerror=function( msg, url, line ) {
switch( msg ) {
default: break;
case foo: break;
}
}
</script></head></html>

I'm betting not; I'm planning to file a bug report.


No script should cause the browser itself to crash, regardless
of syntactical correctness, so yes it's a bug in Firefox.

The ECMA spec does not state explicitly that the default
statement must be in any particular position:

<URL:http://www.mozilla.org/js/language/E262-3.pdf>

Section 12.11

However, putting it first with a single 'break' statement means
that none of the following clauses will be evaluated and
therefore it's something that is only likely to happen whilst
debugging.

There are a number of work-arounds, the simplest being to put a
trivial clause ahead of the default so that it is no longer
first:

window.onerror=function( msg, url, line ) {
switch( msg ) {
case foo2: continue;
default: break;
case foo: break;
}
}

--
Rob
Jul 23 '05 #4

P: n/a


Christopher Benson-Manica wrote:
Is Firefox 1.0.1 within its rights to crash when presented with the
following script?

<html>
<head>
<script>
var foo="foo";
window.onerror=function( msg, url, line ) {
switch( msg ) {
default: break;
case foo: break;
}
}
</script></head></html>

I'm betting not; I'm planning to file a bug report.


Crash is always a bug, I seached whether you had filed one but couldn't
find it so I filed this as
<https://bugzilla.mozilla.org/show_bug.cgi?id=285755>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5

P: n/a
rh
RobG wrote:

<..>
The ECMA spec does not state explicitly that the default
statement must be in any particular position:

<URL:http://www.mozilla.org/js/language/E262-3.pdf>

Section 12.11

However, putting it first with a single 'break' statement means
that none of the following clauses will be evaluated and
therefore it's something that is only likely to happen whilst
debugging.

I don't think 12.11 reads quite that way. All "case" clauses should be
tested prior to forcing the default, regardless of the source-text
position of the "default" clause.

So the only time the source-text position of the default should be of
consequence is when there is a fall-through from a preceding case
statement execution sequence.
There are a number of work-arounds, the simplest being to put a
trivial clause ahead of the default so that it is no longer
first:

window.onerror=function( msg, url, line ) {
switch( msg ) {
case foo2: continue;
default: break;
case foo: break;
}
}


And while that's the right idea for a work-around, recall that
"continue" can only be used within an iterative construct. Something
like

case msg+'#':
default: break;
would seem to be a better choice as a (never-successful case) buffer.

../rh

Jul 23 '05 #6

P: n/a
Martin Honnen <ma*******@yahoo.de> spoke thus:
Crash is always a bug, I seached whether you had filed one but couldn't
find it so I filed this as
<https://bugzilla.mozilla.org/show_bug.cgi?id=285755>


I didn't file a bug report since the latest nightly build seemed to
have fixed it :)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.