[Webkit-unassigned] [Bug 16677] New: declared variable in window.eval statement not preserved after return from calling context

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Dec 30 06:52:39 PST 2007


http://bugs.webkit.org/show_bug.cgi?id=16677

           Summary: declared variable in window.eval statement not preserved
                    after return from calling context
           Product: WebKit
           Version: 523.x (Safari 3)
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: qomo.team at gmail.com
                CC: mrowe at apple.com, qomo.team at gmail.com


Well, the Bug #14163 is NOT fixed ...It is reproducable in nightly builds till
now & the shipped Safari 3.
There seems to be misunderstanding, take a look at the original test case:
By declaring either with or without  "var", both of them is available in the
context of function f() (thus two alert dialog with "1" and "2" showed).
And then, after function f() ends, the test1 exsist, BUT test2 disappeared!
This is different from what
 IE's execScript() and Gecko's eval() with syntax "window.eval(script);" does.
(the other ways in Gecko such like "window.eval(script, lang);" "eval(script)"
has the bug same as what described here, with even worse effects such as
leading a crash. But they seems not going to resolve that, referenced as
https://bugzilla.mozilla.org/show_bug.cgi?id=352045).

+++ This bug was initially created as a clone of Bug #14163 +++

(This bug is reported as #4458636 to Apple Bug Reporter in Feb. 2006, but
exists till now)

Webkit doesn't work correctly on the lifetime control of global variables
declared explicitly in window.eval() method while calling from a function.
Those variables declared explicitly will be destoryed out of the caller
function of window.eval().

The attached test.html shows the problem:
alert() in f() works fine, both test1 & test2 will popup, but only test1 will
popup by alert() in the global context.
And if window.eval() is called in the global context, both places of alert()
works fine.

Workaround:
Don't use var while declare global variables in eval()


test.html:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testcase</title>
<script>
function f()
{
window.eval('test1=1', 'JavaScript');
window.eval('var test2=2', 'JavaScript');
alert(test1);
alert(test2);
}
f();
alert(test1);
alert(test2);
</script>
</head>
<body />
</html>


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list