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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jun 15 05:22:30 PDT 2007


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

           Summary: declared variable in window.eval statement not preserved
                    after return from calling context
           Product: WebKit
           Version: 522+ (nightly)
          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


(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