Help needed with event testing script

Discussion in 'Javascript' started by Mark Szlazak, Apr 4, 2005.

  1. Mark Szlazak

    Mark Szlazak Guest

    Apparently there is a textarea onscroll event bubbling bug in Firefox
    and Mozilla:

    https://bugzilla.mozilla.org/show_bug.cgi?id=229089

    I'm trying to check for this bug with the following script and it
    *seems* to work. In IE it reports "bubbling" and in Firefox "not
    bubbling" but I really have no direct way to confirm the Firefox
    results until the bubbling bug is fixed.

    Basically the test script assigns an onscroll event handler to a
    textarea and then scrolls the textarea down then back up, checking to
    see if a the event handler works (assigns the "bubbling" variable a
    "true").

    I had to code things with a few settimeouts otherwise Firefox, unlike
    IE, wouldn't display the down then back up scrolling of the textarea.
    Which may have been a problem.

    Lacking a "debugged" Firefox browser, is there some further (indirect?)
    tests and/or rational that would support or discredit this script as a
    valid onscroll event check?

    <html>
    <head>
    <script>
    var bubbling, ta;

    function checkBubbling () {
    var str = '';
    bubbling = false;
    ta.onscroll = function () { bubbling = true; }

    for (var i=0; i <= ta.rows; i++) str += '\n';
    ta.value = str;
    ta.scrollTop = ta.scrollHeight;

    setTimeout("scrollBack ()", 1);
    }

    function scrollBack () {
    ta.scrollTop = 0;
    setTimeout("resetAndReport ()", 1);
    }

    function resetAndReport () {
    ta.value = "";
    if (bubbling)
    {
    alert('bubbling');
    }
    else
    {
    alert('not bubbling');
    }
    }

    onload = function ()
    {
    ta = document.getElementById('ta');
    ta.value = "";
    checkBubbling();
    }
    </script>
    </head>
    <body>
    <textarea id="ta" rows=5 cols=40></textarea>
    </body>
    </html>
     
    Mark Szlazak, Apr 4, 2005
    #1
    1. Advertising

  2. Mark Szlazak wrote:

    > Apparently there is a textarea onscroll event bubbling bug in Firefox
    > and Mozilla:
    >
    > https://bugzilla.mozilla.org/show_bug.cgi?id=229089
    >
    > I'm trying to check for this bug with the following script and it
    > *seems* to work. In IE it reports "bubbling" and in Firefox "not
    > bubbling" but I really have no direct way to confirm the Firefox
    > results until the bubbling bug is fixed.
    >
    > Basically the test script assigns an onscroll event handler to a
    > textarea and then scrolls the textarea down then back up, checking to
    > see if a the event handler works (assigns the "bubbling" variable a
    > "true").


    If script scrolls then I am not sure Mozilla fires the scroll event, it
    should fire it when the user scrolls. At least for a window a quick test
    shows that window.scrollTo() doesn't fire the scroll event and even if
    onscroll worked for textareas then I don't think the scroll event would
    be fired if script manipulates the scroll settings.




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Apr 5, 2005
    #2
    1. Advertising

  3. Mark Szlazak

    Mark Szlazak Guest

    Martin Honnen wrote:
    > Mark Szlazak wrote:
    >
    > > Apparently there is a textarea onscroll event bubbling bug in

    Firefox
    > > and Mozilla:
    > >
    > > https://bugzilla.mozilla.org/show_bug.cgi?id=229089
    > >
    > > I'm trying to check for this bug with the following script and it
    > > *seems* to work. In IE it reports "bubbling" and in Firefox "not
    > > bubbling" but I really have no direct way to confirm the Firefox
    > > results until the bubbling bug is fixed.
    > >
    > > Basically the test script assigns an onscroll event handler to a
    > > textarea and then scrolls the textarea down then back up, checking

    to
    > > see if a the event handler works (assigns the "bubbling" variable a
    > > "true").

    >
    > If script scrolls then I am not sure Mozilla fires the scroll event,

    it
    > should fire it when the user scrolls. At least for a window a quick

    test
    > shows that window.scrollTo() doesn't fire the scroll event and even

    if
    > onscroll worked for textareas then I don't think the scroll event

    would
    > be fired if script manipulates the scroll settings.
    >
    >
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/


    OK, with regard to textarea scripts firing onscroll events, why is
    there this difference between IE and Firefox?

    Also, do you have any suggestions for checking if the textarea onscroll
    event in Firefox is working?

    Thanks. Mark.
     
    Mark Szlazak, Apr 5, 2005
    #3
  4. Mark Szlazak wrote:


    > Also, do you have any suggestions for checking if the textarea onscroll
    > event in Firefox is working?


    That bug you have found has a test case:
    <https://bugzilla.mozilla.org/show_bug.cgi?id=229089>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Apr 5, 2005
    #4
  5. Mark Szlazak

    Mark Szlazak Guest

    Martin Honnen wrote:
    > Mark Szlazak wrote:
    >
    >
    > > Also, do you have any suggestions for checking if the textarea

    onscroll
    > > event in Firefox is working?

    >
    > That bug you have found has a test case:
    > <https://bugzilla.mozilla.org/show_bug.cgi?id=229089>
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/


    Yes! It demonstrates the bug but provides no work-around.
    I was hoping for bug detection without browser version detection but no
    luck ... I guess.

    Mark.
     
    Mark Szlazak, Apr 5, 2005
    #5
  6. Mark Szlazak

    Mark Szlazak Guest

    Martin Honnen wrote:
    > Mark Szlazak wrote:
    >
    > > Apparently there is a textarea onscroll event bubbling bug in

    Firefox
    > > and Mozilla:
    > >
    > > https://bugzilla.mozilla.org/show_bug.cgi?id=229089
    > >
    > > I'm trying to check for this bug with the following script and it
    > > *seems* to work. In IE it reports "bubbling" and in Firefox "not
    > > bubbling" but I really have no direct way to confirm the Firefox
    > > results until the bubbling bug is fixed.
    > >
    > > Basically the test script assigns an onscroll event handler to a
    > > textarea and then scrolls the textarea down then back up, checking

    to
    > > see if a the event handler works (assigns the "bubbling" variable a
    > > "true").

    >
    > If script scrolls then I am not sure Mozilla fires the scroll event,

    it
    > should fire it when the user scrolls. At least for a window a quick

    test
    > shows that window.scrollTo() doesn't fire the scroll event and even

    if
    > onscroll worked for textareas then I don't think the scroll event

    would
    > be fired if script manipulates the scroll settings.
    >
    >
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/


    If the user has to scroll the textarea to get a fire from onscroll in a
    bugfree firefox then what about user inputs that show the scrollbars
    once enough lines are entered into the textarea. I'm thinking about a
    script something like this:

    <html>
    <head>
    <script>
    var bubbling, ta;

    onload = function ()
    {
    bubbling = false;
    ta = document.getElementById('ta');
    ta.value = "";
    ta.onscroll = function () { bubbling = true; }
    if (ta.addEventListener) {
    ta.addEventListener("input",
    function () { if (ta.scrollHeight > ta.clientHeight)
    {
    if (bubbling)
    {
    window.status = 'bubbling';
    }
    else
    {
    window.status = 'not bubbling';
    }
    }
    },
    false);
    }
    }
    </script>
    </head>
    <body>
    <textarea id="ta" rows=5 cols=40></textarea>
    </body>
    </html>
     
    Mark Szlazak, Apr 5, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian van den Broek
    Replies:
    3
    Views:
    862
    Jeremy Bowers
    Apr 3, 2005
  2. Brian van den Broek
    Replies:
    2
    Views:
    398
    Brian van den Broek
    Apr 5, 2005
  3. Chris

    Testing and Load Testing

    Chris, Mar 4, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    336
  4. John Maclean
    Replies:
    1
    Views:
    351
    Martin P. Hellwig
    Apr 13, 2010
  5. Avi
    Replies:
    0
    Views:
    500
Loading...

Share This Page