Bug 37935 - [Qt] JavaScript global variables get re-initialized with each function call.
Summary: [Qt] JavaScript global variables get re-initialized with each function call.
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: S60 Hardware S60 3rd edition
: P2 Normal
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2010-04-21 11:00 PDT by nokiabugz
Modified: 2011-03-03 05:37 PST (History)
8 users (show)

See Also:


Attachments
test case (272.79 KB, application/x-zip-compressed)
2010-04-22 05:55 PDT, nokiabugz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description nokiabugz 2010-04-21 11:00:39 PDT
When an external JavaScript file is included in an HTML file’s markup, any global variables that are defined get set back to their original values.  For example:


    var myCounter = 0;

    function incrementCounter() {
        return ++myCounter;
    }


Each time the incrementCounter function is called, the myCounter variable gets reset to zero, so the function always returns 1.

This does NOT appear to happen with a small script such as the example above.  The test case that is included DOES reproduce the error; it is unclear whether this is due to the amount of memory used, or the use of the httpRequest object, or something else entirely.

(The enclosed test loads a canned website into an iframe, waits 10 seconds, then loads the next site from a list in sites.js.  Some debug output is displayed in the textarea above the iframe.)

This is reproducable on the week 14 QtWebKit build.
Comment 1 Alexey Proskuryakov 2010-04-21 19:10:44 PDT
There is no test attached to this bug.
Comment 2 nokiabugz 2010-04-22 05:55:15 PDT
Created attachment 54054 [details]
test case
Comment 3 Alexey Proskuryakov 2010-04-22 11:33:06 PDT
This test does not work in Firefox at all, so I can't compare results to Safari. What are expected results, and how do they differ from actual results?
Comment 4 Laszlo Gombos 2010-04-22 11:38:43 PDT
The unexpected output is if "ERROR: serverURL must be set before calling postResults" is posted as a serverResponse.

I tried Safari 4.0.4 on Windows and QtLauncher on Linux and could not reproduce the problem.

Marked the issue for Qt and Symbian only for now.
Comment 5 Janne Koskinen 2010-05-19 03:37:51 PDT
>This is reproducable on the week 14 QtWebKit build.

Samuel has been trying to reproduce this without any success of reproduction. Can you be more specific on the environment ? emulator or HW?

Sounds like real nasty bug but if it only can be reproduced in emulator environment I'd put this to low priority or ignore it completely. WINSCW environment is not the most trustworthy thing when webkit gets to eat all address space.

Laszlo is the broken JIT in W14? that could be source of this.
Comment 6 Balazs Kelemen 2010-06-03 05:20:27 PDT
It would be useful to try this with the interpreter
(build-webkit --makeargs="-DENABLE_JIT=0").
Comment 7 Janne Koskinen 2010-11-25 00:51:45 PST
Can someone actually reproduce this?
To test this you need to modify sites.js unless running this with webserver.
Comment 8 Janne Koskinen 2011-03-03 05:37:19 PST
Closing as no further info has been provided. Please re-open if issue is still valid and provide more specific instructions how to run the test set.