<?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>15574</bug_id>
          
          <creation_ts>2007-10-20 03:33:47 -0700</creation_ts>
          <short_desc>Web Inspector doesn&apos;t work with the new Database feature</short_desc>
          <delta_ts>2008-04-04 14:42:06 -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>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P4</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ralf D.">nsstring</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>beidson</cc>
    
    <cc>ian</cc>
    
    <cc>mrowe</cc>
    
    <cc>sam</cc>
    
    <cc>timothy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>58900</commentid>
    <comment_count>0</comment_count>
    <who name="Ralf D.">nsstring</who>
    <bug_when>2007-10-20 03:33:47 -0700</bug_when>
    <thetext>I get this Javascript error on the provided example site (http://webkit.org/misc/DatabaseExample.html)

-----------
Undefined Value
/Applications/WebKit.app/Contents/Resources/WebCore.framework/Versions/A/Resources/inspector/DatabasePanel.js 
line 429
-----------

See here:
http://img98.imageshack.us/img98/2283/errorpu7.png</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58910</commentid>
    <comment_count>1</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2007-10-20 09:35:52 -0700</bug_when>
    <thetext>Something bogus is happening in the callback from 
this.database.database.executeSql(query, [], function(result) { panel.browseQueryFinished(result) });

in _tableForResult, it&apos;s almost like there&apos;s no global (window) object.  window.document is null, and I tried to place a debugging alert() and it also failed due to undefined.

o_O</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58911</commentid>
    <comment_count>2</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2007-10-20 09:52:41 -0700</bug_when>
    <thetext>This isn&apos;t always happening, sometimes it works.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58912</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-10-20 09:57:47 -0700</bug_when>
    <thetext>It&apos;ll work against file:/// URLs.  By the looks of things, the callback Brady mentions is running in the security context of the page in the web browser but with the global object of the inspector.  This means it is unable to access any properties of the window object without triggering a yummy &quot;Unsafe JavaScript attempt to access frame&quot; error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58919</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-10-20 10:43:02 -0700</bug_when>
    <thetext>To clarify a little:

* this.database.database is the Database instance from within the frame at http://webkit.org/misc/DatabaseExample.html. 
* Calling executeSql on this object will result in the callback being executed within that frame&apos;s interpreter and thus that frame&apos;s security context. 
* The callback function was created within the inspector&apos;s interpreter, and thus has the inspector&apos;s window object in its scope chain.  
* When the callback function attempts to access the window object, this is a security violation (accessing an object in the inspector&apos;s security domain from within the websites interpreter).

I can&apos;t think of any simple solution to this.  Hopefully someone more clueful can!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58920</commentid>
    <comment_count>5</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2007-10-20 11:19:41 -0700</bug_when>
    <thetext>We can always open a new database instance that only the inspector owns.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58927</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-10-20 14:12:25 -0700</bug_when>
    <thetext>I landed a workaround for this issue in r26830 (http://trac.webkit.org/projects/webkit/changeset/26830).  The behaviour being worked around definitely feels incorrect in some respect, so I think this deserves further investigation to determine what the correct fix is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58965</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-10-20 19:57:16 -0700</bug_when>
    <thetext>Why is Mark&apos;s change considered a workaround, and not a fix?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58973</commentid>
    <comment_count>8</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2007-10-20 21:37:48 -0700</bug_when>
    <thetext>We think it is working around XSS security, similar to the hole Sam fixed for addEventListener &lt;rdar://problem/5426142&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58974</commentid>
    <comment_count>9</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2007-10-20 21:40:25 -0700</bug_when>
    <thetext>A real fix would be:

Index: WebCore/bindings/js/JSDatabaseCustom.cpp
===================================================================
--- WebCore/bindings/js/JSDatabaseCustom.cpp	(revision 26802)
+++ WebCore/bindings/js/JSDatabaseCustom.cpp	(working copy)
@@ -99,7 +99,7 @@
         return jsUndefined();
     }
 
-    if (Frame* frame = m_impl-&gt;document()-&gt;frame()) {
+    if (Frame* frame = Window::retrieveActive(exec)-&gt;impl()-&gt;frame()) {
         RefPtr&lt;VersionChangeCallback&gt; changeCallback(new JSCustomVersionChangeCallback(callback, frame));
         m_impl-&gt;changeVersion(oldVersion, newVersion, changeCallback.release());
     }

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59240</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2007-10-23 01:16:30 -0700</bug_when>
    <thetext>The callback should run with the security context of the script that created the callback, no?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68677</commentid>
    <comment_count>11</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2008-01-29 11:16:08 -0800</bug_when>
    <thetext>&lt;rdar://problem/5712937&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76340</commentid>
    <comment_count>12</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2008-04-04 14:42:06 -0700</bug_when>
    <thetext>I tried removing the workaround, and all seems to work.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>