Firefox dies on simple script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    Firefox dies on simple script

    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)cybers pace.org | don't, I need to know. Flames welcome.
  • kaeli

    #2
    Re: Firefox dies on simple script

    In article <d0qede$on8$1@c hessie.cirr.com >, ataru@nospam.cy berspace.org
    enlightened us with...[color=blue]
    > window.onerror= function( msg, url, line ) {
    > switch( msg ) {
    > default: break;
    > case foo: break;[/color]

    Why is your default at the beginning?

    Just curious.


    --
    --
    ~kaeli~
    Shotgun wedding: A case of wife or death.



    Comment

    • Christopher Benson-Manica

      #3
      Re: Firefox dies on simple script

      kaeli <tiny_one@nospa m.comcast.net> spoke thus:
      [color=blue]
      > Why is your default at the beginning?[/color]

      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)cybers pace.org | don't, I need to know. Flames welcome.

      Comment

      • RobG

        #4
        Re: Firefox dies on simple script

        Christopher Benson-Manica wrote:[color=blue]
        > 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.
        >[/color]

        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

        Comment

        • Martin Honnen

          #5
          Re: Firefox dies on simple script



          Christopher Benson-Manica wrote:
          [color=blue]
          > 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.[/color]

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

          --

          Martin Honnen

          Comment

          • rh

            #6
            Re: Firefox dies on simple script

            RobG wrote:

            <..>
            [color=blue]
            > 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.
            >[/color]

            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.
            [color=blue]
            > 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;
            > }
            > }
            >[/color]

            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

            Comment

            • Christopher Benson-Manica

              #7
              Re: Firefox dies on simple script

              Martin Honnen <mahotrash@yaho o.de> spoke thus:
              [color=blue]
              > Crash is always a bug, I seached whether you had filed one but couldn't
              > find it so I filed this as
              > <https://bugzilla.mozill a.org/show_bug.cgi?id =285755>[/color]

              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)cybers pace.org | don't, I need to know. Flames welcome.

              Comment

              Working...