<?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>27203</bug_id>
          
          <creation_ts>2009-07-12 21:27:22 -0700</creation_ts>
          <short_desc>Inspector: Remove Unintended Global Variables</short_desc>
          <delta_ts>2009-07-14 22:26:58 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector (Deprecated)</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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 name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>pmuellr</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>131239</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2009-07-12 21:27:22 -0700</bug_when>
    <thetext>Removing some variables that were declared without &apos;var&apos; and thus pushed into the global scope by accident.  Some in the Web Inspector window only (of little important but to be clean), but some in the actual inspected window as well (may give developers problems).  I did some hunting all over and these were the ones I found.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131240</commentid>
    <comment_count>1</comment_count>
      <attachid>32644</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2009-07-12 21:40:20 -0700</bug_when>
    <thetext>Created attachment 32644
Remove Unintended Globals

This removes the unintended globals that I found.

Most are harmless and are only global variables inside the Web Inspector window.

Note that in the case of Console.js, there is code that gets evaluated in the inspected window.  Thus the &quot;k&quot; variable could get overwritten when running either the keys() or values() functions created by the Web Inspector.  For example, running some sample code in the Inspector:

&gt; k
ReferenceError: Can&apos;t find variable: k
&gt; var obj = { a:1 }
undefined
&gt; keys(obj)
[&quot;a&quot;]
&gt; k /* Now defined as a side effect of running keys() */
a

Although its probably bad programming if a developer used window.k, and even more unusual if they then called these functions, this side effect should still be removed. =)

Cheers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131243</commentid>
    <comment_count>2</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2009-07-12 22:23:06 -0700</bug_when>
    <thetext>Just a heads up, I ran some scripts to check the differences of the global scope of a Web Inspector window and a normal global scope.  I also removed all the expected global functions from inspector.js and utilities.js and I was left with the following leftovers:

&gt; [&quot;WebInspector&quot;, &quot;localizedStrings&quot;, &quot;UserInitiatedProfileName&quot;, &quot;TreeElement&quot;, &quot;TreeOutline&quot;, &quot;Preferences&quot;, &quot;InspectorController&quot;, &quot;key&quot;, &quot;subPropertyName&quot;]

&quot;key&quot; and &quot;subPropertyName&quot; are now squashed.  And I assume the rest are expected to be in the global scope. Let me know if any of these should be moved, but I think its all good now. =)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131401</commentid>
    <comment_count>3</comment_count>
    <who name="Patrick Mueller">pmuellr</who>
    <bug_when>2009-07-13 13:36:19 -0700</bug_when>
    <thetext>It would be useful to have a testcase that could be run to actually test for the presence of new unintended globals introduced.  It would probably need to be manual.  Test page would capture existing globals, tell the user to open web inspector, run some code, and then have a link/button on the test page that would compare the new state of the globals to the initial captured state.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131402</commentid>
    <comment_count>4</comment_count>
    <who name="Patrick Mueller">pmuellr</who>
    <bug_when>2009-07-13 13:40:45 -0700</bug_when>
    <thetext>I&apos;m curious as to whether, in addition to &quot;window&quot; (the global object), if Web Inspector is adding properties to any other objects.  Even if it isn&apos;t today, perhaps we should start proactively checking obvious places, like existing classes and their prototypes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131405</commentid>
    <comment_count>5</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2009-07-13 13:59:02 -0700</bug_when>
    <thetext>As far as modifying anything on the actually inspected page I have doubts that anything else is affected.  From what I&apos;ve seen, code in the Inspector is separate from the inspected page and anything to go in the inspected page needs to be specially evaluted.  The correction above is the only place where this is done with any significance.

However, this could be useful to clean up Javascript inside the Inspector page or better yet javascript in general.

Does WebKit have the ability to do a JSLint like compilation of a Javascript file and identify potential problems such as &quot;implied globals&quot; or access outside of an existing scope?  Seeing as there are JIT compilers then this kind of static analysis would be useful for developers.

I haven&apos;t written an test cases before. I could look into doing something like this (no promises yet).  The problem I see with a test case for this is that the inspector adds a lot of functions on html/dom prototypes (see utilities.js).  If any more are created or modified then the test-case should be corrected.  Is that kind of dependency normal for test cases?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131438</commentid>
    <comment_count>6</comment_count>
    <who name="Patrick Mueller">pmuellr</who>
    <bug_when>2009-07-13 16:28:26 -0700</bug_when>
    <thetext>As I mentioned, checking for properties added to objects other than &quot;window&quot; is more of a proactive test.  I assume.  :-)

Are the functions added in utilities.js added to the under-test JavaScript environment?  Seems like a huge problem; something that itself needs to be cleaned up, somehow.  Or minimized.  Or all the functions should have double underscores added to them.

In terms of test cases, manual ones aren&apos;t bad.  See one I wrote: 

   WebKit/WebCore/manual-tests/inspector/named-evals.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131811</commentid>
    <comment_count>7</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-07-14 22:26:58 -0700</bug_when>
    <thetext>Landed in http://trac.webkit.org/changeset/45889.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>32644</attachid>
            <date>2009-07-12 21:40:20 -0700</date>
            <delta_ts>2009-07-12 21:57:48 -0700</delta_ts>
            <desc>Remove Unintended Globals</desc>
            <filename>InspectorRemoveGlobals.patch</filename>
            <type>text/plain</type>
            <size>3867</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0NTc4NSkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTkgQEAKKzIwMDktMDctMTIgIEpvc2VwaCBQZWNvcmFybyAgPGpvZXBlY2swMkBn
bWFpbC5jb20+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAg
ICAgSW5zcGVjdG9yOiBSZW1vdmUgVW5pbnRlbmRlZCBHbG9iYWwgVmFyaWFibGVzCisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0yNzIwMworCisgICAgICAg
ICogaW5zcGVjdG9yL2Zyb250LWVuZC9Db25zb2xlLmpzOgorICAgICAgICAoV2ViSW5zcGVjdG9y
LkNvbnNvbGUucHJvdG90eXBlLl9lbnN1cmVDb21tYW5kTGluZUFQSUluc3RhbGxlZCk6CisgICAg
ICAgICogaW5zcGVjdG9yL2Zyb250LWVuZC9EYXRhYmFzZXNQYW5lbC5qczoKKyAgICAgICAgKFdl
Ykluc3BlY3Rvci5EYXRhYmFzZXNQYW5lbC5wcm90b3R5cGUuZGF0YUdyaWRGb3JET01TdG9yYWdl
KToKKyAgICAgICAgKiBpbnNwZWN0b3IvZnJvbnQtZW5kL09iamVjdFByb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ICAgICAgICAgZm9yICh2YXIgc3ViUHJvcGVydHlOYW1lIGlu
IGNoaWxkT2JqZWN0KSB7CiAgICAgICAgICAgICAgICAgaWYgKHN1YlByb3BlcnR5TmFtZSA9PT0g
Il9fdHJlZUVsZW1lbnRJZGVudGlmaWVyIikKICAgICAgICAgICAgICAgICAgICAgY29udGludWU7
CiAgICAgICAgICAgICAgICAgaGFzU3ViUHJvcGVydGllcyA9IHRydWU7CkluZGV4OiBXZWJDb3Jl
L2luc3BlY3Rvci9mcm9udC1lbmQvaW5zcGVjdG9yLmpzCj09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUv
aW5zcGVjdG9yL2Zyb250LWVuZC9pbnNwZWN0b3IuanMJKHJldmlzaW9uIDQ1Nzg1KQorKysgV2Vi
Q29yZS9pbnNwZWN0b3IvZnJvbnQtZW5kL2luc3BlY3Rvci5qcwkod29ya2luZyBjb3B5KQpAQCAt
NTg4LDYgKzU4OCw3IEBAIFdlYkluc3BlY3Rvci5hbmltYXRlU3R5bGUgPSBmdW5jdGlvbihhbmkK
ICAgICAgICAgdmFyIHN0YXJ0ID0gbnVsbDsKICAgICAgICAgdmFyIGN1cnJlbnQgPSBudWxsOwog
ICAgICAgICB2YXIgZW5kID0gbnVsbDsKKyAgICAgICAgdmFyIGtleSA9IG51bGw7CiAgICAgICAg
IGZvciAoa2V5IGluIGFuaW1hdGlvbikgewogICAgICAgICAgICAgaWYgKGtleSA9PT0gImVsZW1l
bnQiKQogICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBhbmltYXRpb25ba2V5XTsK
</data>
<flag name="review"
          id="17040"
          type_id="1"
          status="+"
          setter="sam"
    />
          </attachment>
      

    </bug>

</bugzilla>