<?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>101725</bug_id>
          
          <creation_ts>2012-11-09 01:33:46 -0800</creation_ts>
          <short_desc>[V8] Inspector does not callback IDB methods in context</short_desc>
          <delta_ts>2012-12-18 00:50:27 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>
          
          <blocked>101573</blocked>
          <everconfirmed>0</everconfirmed>
          <reporter name="Dan Carney">dcarney</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alecflett</cc>
    
    <cc>pfeldman</cc>
    
    <cc>vsevik</cc>
    
    <cc>webkit.review.bot</cc>
    
    <cc>yurys</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>762702</commentid>
    <comment_count>0</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-09 01:33:46 -0800</bug_when>
    <thetext>[V8] Inspector does not callback IDB methods in context</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>762703</commentid>
    <comment_count>1</comment_count>
      <attachid>173236</attachid>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-09 01:35:29 -0800</bug_when>
    <thetext>Created attachment 173236
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>762706</commentid>
    <comment_count>2</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-09 01:40:08 -0800</bug_when>
    <thetext>This is a hack in the style of the previous idb hack. It should be done properly, but I&apos;m not sure how to do that here. All three points I injected the context have stack traces similar to:

WebCore::IDBOpenDBRequest::create(WebCore::ScriptExecutionContext*, WTF::PassRefPtr&lt;WebCore::IDBAny&gt;, WTF::PassRefPtr&lt;WebCore::IDBDatabaseCallbacksImpl&gt;, long) at IDBOpenDBRequest.cpp:42
WebCore::IDBFactory::openInternal(WebCore::ScriptExecutionContext*, WTF::String const&amp;, long, int&amp;) at IDBFactory.cpp:130
WebCore::IDBFactory::open(WebCore::ScriptExecutionContext*, WTF::String const&amp;, int&amp;) at IDBFactory.cpp:138
start at InspectorIndexedDBAgent.cpp:210
WebCore::InspectorIndexedDBAgent::requestDatabase(WTF::String*, WTF::String const&amp;, WTF::String const&amp;, WTF::PassRefPtr&lt;WebCore::InspectorBackendDispatcher::IndexedDBCommandHandler::RequestDatabaseCallback&gt;) at InspectorIndexedDBAgent.cpp:669
WebCore::InspectorBackendDispatcherImpl::IndexedDB_requestDatabase(long, WebCore::InspectorObject*) at InspectorBackendDispatcher.cpp:2147
WebCore::InspectorBackendDispatcherImpl::dispatch(WTF::String const&amp;) at InspectorBackendDispatcher.cpp:5660
WebCore::InspectorController::dispatchMessageFromFrontend(WTF::String const&amp;) at InspectorController.cpp:343
WebKit::WebDevToolsAgentImpl::dispatchOnInspectorBackend(WebKit::WebString const&amp;) at WebDevToolsAgentImpl.cpp:565

I see no better place to to the context injection.

Finally, I used the main world here but I have no idea if that it the correct thing to do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>763187</commentid>
    <comment_count>3</comment_count>
      <attachid>173236</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-11-09 11:23:16 -0800</bug_when>
    <thetext>Comment on attachment 173236
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173236&amp;action=review

&gt; Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:650
&gt; +    v8::Handle&lt;v8::Context&gt; context = document-&gt;frame()-&gt;script()-&gt;mainWorldContext();

Why the main world?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>763195</commentid>
    <comment_count>4</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-09 11:34:25 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 173236 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=173236&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:650
&gt; &gt; +    v8::Handle&lt;v8::Context&gt; context = document-&gt;frame()-&gt;script()-&gt;mainWorldContext();
&gt; 
&gt; Why the main world?

I had to choose one.  This patch is only meant to fix the crashes and inject the contexts where they more or less need to be. Also, I figured there might be an off chance that the inspector only pays attention to main world IDBs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>770775</commentid>
    <comment_count>5</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-19 08:32:27 -0800</bug_when>
    <thetext>I&apos;ve hit another issue that bug 101573 would have triggered an assertion on. I&apos;d like to move forward with this patch if no one has a better solution. I will, however, change it slightly to only enter a context if it&apos;s not currently in one. That will replicate the existing (wrong) behaviour.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>770835</commentid>
    <comment_count>6</comment_count>
    <who name="Alec Flett">alecflett</who>
    <bug_when>2012-11-19 10:13:32 -0800</bug_when>
    <thetext>dcarney: there&apos;s a new abstraction, DOMRequest, that should cover this - we&apos;re using it in IDBRequest. Can you use that? (that way it will work with JSC too)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>770862</commentid>
    <comment_count>7</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-19 10:55:51 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; dcarney: there&apos;s a new abstraction, DOMRequest, that should cover this - we&apos;re using it in IDBRequest. Can you use that? (that way it will work with JSC too)

Thanks for the update. I&apos;ll check it out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>770873</commentid>
    <comment_count>8</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-19 11:11:49 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; dcarney: there&apos;s a new abstraction, DOMRequest, that should cover this - we&apos;re using it in IDBRequest. Can you use that? (that way it will work with JSC too)

That won&apos;t work. The problem is not the hackiness of the patch versus having a clean abstraction. No v8 context has been entered higher up the stack.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>771009</commentid>
    <comment_count>9</comment_count>
    <who name="Alec Flett">alecflett</who>
    <bug_when>2012-11-19 14:03:19 -0800</bug_when>
    <thetext>ah, I see what you mean, nevermind</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>772661</commentid>
    <comment_count>10</comment_count>
      <attachid>173236</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-11-21 02:09:30 -0800</bug_when>
    <thetext>Comment on attachment 173236
Patch

Ok.  Let&apos;s land this so that we can add the ASSERT to world context handle.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>772675</commentid>
    <comment_count>11</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-21 02:20:17 -0800</bug_when>
    <thetext>(In reply to comment #10)
&gt; (From update of attachment 173236 [details])
&gt; Ok.  Let&apos;s land this so that we can add the ASSERT to world context handle.

Ok. This is pretty heinous, though, and could lead to more of the same crashes. We could just disable the failing tests and let it crash in WorldContextHandle</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>772676</commentid>
    <comment_count>12</comment_count>
      <attachid>173236</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-11-21 02:20:24 -0800</bug_when>
    <thetext>Comment on attachment 173236
Patch

Clearing flags on attachment: 173236

Committed r135367: &lt;http://trac.webkit.org/changeset/135367&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>772677</commentid>
    <comment_count>13</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-11-21 02:20:27 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>774273</commentid>
    <comment_count>14</comment_count>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-23 00:33:30 -0800</bug_when>
    <thetext>added yurys and pfeldman:

if one of you two knows who could fix this properly, that would be great. The submitted patch is completely wrong, but removing this code will cause test failures in  4 IDB inspector test. It&apos;s possible that this incorrect behaviour is causing this crash: http://code.google.com/p/chromium/issues/detail?id=150737. Ping me directly if you need more information about the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>775234</commentid>
    <comment_count>15</comment_count>
      <attachid>173236</attachid>
    <who name="Yury Semikhatsky">yurys</who>
    <bug_when>2012-11-26 01:12:59 -0800</bug_when>
    <thetext>Comment on attachment 173236
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173236&amp;action=review

&gt; Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:675
&gt;      RefPtr&lt;DatabaseLoader&gt; databaseLoader = DatabaseLoader::create(document, requestCallback);

Why do we have to enter V8 context while calling a native function which by the way accepts ScriptExecutionContext and can enter the context if it need one? It seems completely wrong to me. Looks like we should make DatabaseLoader::create instead not to make assumptions about the v8 context stack, is there any problem with that approach?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>775246</commentid>
    <comment_count>16</comment_count>
      <attachid>173236</attachid>
    <who name="Dan Carney">dcarney</who>
    <bug_when>2012-11-26 01:35:05 -0800</bug_when>
    <thetext>Comment on attachment 173236
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173236&amp;action=review

&gt;&gt; Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:675
&gt;&gt;      RefPtr&lt;DatabaseLoader&gt; databaseLoader = DatabaseLoader::create(document, requestCallback);
&gt; 
&gt; Why do we have to enter V8 context while calling a native function which by the way accepts ScriptExecutionContext and can enter the context if it need one? It seems completely wrong to me. Looks like we should make DatabaseLoader::create instead not to make assumptions about the v8 context stack, is there any problem with that approach?

if ScriptExecutionContext were enough to determine context, I would be using it.  Unfortunately, for isolated worlds, ScriptExecutionContext is simply not enough. It could be that the context needs to be stored somewhere earlier and reused at the points I changed, but since I know nothing about the way inspector works, I can&apos;t say what the correct solution here is at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>793434</commentid>
    <comment_count>17</comment_count>
    <who name="Yury Semikhatsky">yurys</who>
    <bug_when>2012-12-18 00:50:27 -0800</bug_when>
    <thetext>(In reply to comment #16)
&gt; (From update of attachment 173236 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=173236&amp;action=review
&gt; 
&gt; &gt;&gt; Source/WebCore/inspector/InspectorIndexedDBAgent.cpp:675
&gt; &gt;&gt;      RefPtr&lt;DatabaseLoader&gt; databaseLoader = DatabaseLoader::create(document, requestCallback);
&gt; &gt; 
&gt; &gt; Why do we have to enter V8 context while calling a native function which by the way accepts ScriptExecutionContext and can enter the context if it need one? It seems completely wrong to me. Looks like we should make DatabaseLoader::create instead not to make assumptions about the v8 context stack, is there any problem with that approach?
&gt; 
&gt; if ScriptExecutionContext were enough to determine context, I would be using it.  Unfortunately, for isolated worlds, ScriptExecutionContext is simply not enough. It could be that the context needs to be stored somewhere earlier and reused at the points I changed, but since I know nothing about the way inspector works, I can&apos;t say what the correct solution here is at all.

Regardless of inspector code why DatabaseLoader::create depends on the JS context that calls it? Can we implement the check in the JS bindings where control flows from JS to native code?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>173236</attachid>
            <date>2012-11-09 01:35:29 -0800</date>
            <delta_ts>2012-11-26 01:35:05 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-101725-20121109103337.patch</filename>
            <type>text/plain</type>
            <size>3105</size>
            <attacher name="Dan Carney">dcarney</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTM0MDI1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggODQwNGNhNjI0OWJiOWNj
OGRmODg5YTRkYTFjYzU2NDIwYjNkOTBkZi4uZGU3NzYyZmFkYTgxOTY4YTVmMmIwYjg0NDYwMDU3
MDhlZmVlY2QzZCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE5IEBACisyMDEyLTExLTA5ICBEYW4g
Q2FybmV5ICA8ZGNhcm5leUBnb29nbGUuY29tPgorCisgICAgICAgIFtWOF0gSW5zcGVjdG9yIGRv
ZXMgbm90IGNhbGxiYWNrIElEQiBtZXRob2RzIGluIGNvbnRleHQKKyAgICAgICAgaHR0cHM6Ly9i
dWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTEwMTcyNQorCisgICAgICAgIFJldmlld2Vk
IGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEluc2VydGVkIHY4IGNvbnRleHQgYmVmb3Jl
IGNhbGxpbmcgb3V0IHRvIElEQi4KKworICAgICAgICBObyBuZXcgdGVzdHMuCisKKyAgICAgICAg
KiBpbnNwZWN0b3IvSW5zcGVjdG9ySW5kZXhlZERCQWdlbnQuY3BwOgorICAgICAgICAoV2ViQ29y
ZTo6SW5zcGVjdG9ySW5kZXhlZERCQWdlbnQ6OnJlcXVlc3REYXRhYmFzZU5hbWVzRm9yRnJhbWUp
OgorICAgICAgICAoV2ViQ29yZTo6SW5zcGVjdG9ySW5kZXhlZERCQWdlbnQ6OnJlcXVlc3REYXRh
YmFzZSk6CisgICAgICAgIChXZWJDb3JlOjpJbnNwZWN0b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