<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>16677</bug_id>
          
          <creation_ts>2007-12-30 06:52:39 -0800</creation_ts>
          <short_desc>declared variable in window.eval statement not preserved after return from calling context</short_desc>
          <delta_ts>2007-12-30 06:57:58 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>14163</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter>qomo.team</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>mrowe</cc>
    
    <cc>qomo.team</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>65739</commentid>
    <comment_count>0</comment_count>
    <who name="">qomo.team</who>
    <bug_when>2007-12-30 06:52:39 -0800</bug_when>
    <thetext>Well, the Bug #14163 is NOT fixed ...It is reproducable in nightly builds till now &amp; the shipped Safari 3.
There seems to be misunderstanding, take a look at the original test case:
By declaring either with or without  &quot;var&quot;, both of them is available in the context of function f() (thus two alert dialog with &quot;1&quot; and &quot;2&quot; showed).
And then, after function f() ends, the test1 exsist, BUT test2 disappeared! This is different from what
 IE&apos;s execScript() and Gecko&apos;s eval() with syntax &quot;window.eval(script);&quot; does. (the other ways in Gecko such like &quot;window.eval(script, lang);&quot; &quot;eval(script)&quot; 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&apos;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 &amp; 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&apos;t use var while declare global variables in eval()


test.html:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;Testcase&lt;/title&gt;
&lt;script&gt;
function f()
{
window.eval(&apos;test1=1&apos;, &apos;JavaScript&apos;);
window.eval(&apos;var test2=2&apos;, &apos;JavaScript&apos;);
alert(test1);
alert(test2);
}
f();
alert(test1);
alert(test2);
&lt;/script&gt;
&lt;/head&gt;
&lt;body /&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65741</commentid>
    <comment_count>1</comment_count>
    <who name="">qomo.team</who>
    <bug_when>2007-12-30 06:57:58 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of 14163 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>