<?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>27444</bug_id>
          
          <creation_ts>2009-07-20 06:35:23 -0700</creation_ts>
          <short_desc>Wrong FrameLoader::activeDocumentLoader when loading an invalid URL.</short_desc>
          <delta_ts>2009-07-25 08:29:57 -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>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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>25867</blocked>
          <everconfirmed>0</everconfirmed>
          <reporter name="Antonio Gomes">tonikitoo</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>andersca</cc>
    
    <cc>beidson</cc>
    
    <cc>hausmann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>133122</commentid>
    <comment_count>0</comment_count>
      <attachid>33081</attachid>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-20 06:35:23 -0700</bug_when>
    <thetext>Created attachment 33081
set the provisional documentLoader as the activeDocument in case of load failures (v0.1)

Steps to reproduce:

1) load a valid url (e.g. http://google.com). Calling:

FrameLoader::activeDocumentLoader::originalURL() -&gt; http://google.com
FrameLoader::activeDocumentLoader::url() -&gt; http://www.google.com (resolved/redirected)

--&gt; FROM GDB we see that the proper DocumentLoader is set to the FrameLoader after the load succeeds (see below):

gdb_$ b FrameLoader.cpp:setDocumentLoader
gdb_$ bt
FrameLoader::finishedLoading:3092
DocumentLoader::finishedLoading:353
main frame - willCloseFrame
FrameLoader::stopLoading:566
FrameLoader::transitionToCommitted:2869
*******FrameLoader::setDocumentLoader:2691 &apos;loader=0x886bdb0&apos;

2) after that, load an invalid url (e.g. http://abcdef.abcdef). 

--&gt; Since it fails to load, FrameLoader::setDocumentLoader is *never* called, and so calling Frameloader::activeDocumentLoader() returns a reference to &quot;0x886bdb0&quot; (documentLoader of the previous loaded URL - see above). It results in wrong originalURL values:

FrameLoader::activeDocumentLoader::originalURL() -&gt; http://google.com      &lt;---- WRONG
FrameLoader::activeDocumentLoader::url() -&gt; http://abcdef.abcdef</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133192</commentid>
    <comment_count>1</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-20 12:11:52 -0700</bug_when>
    <thetext>btw, no side effects on the layout tests (tested w/ qt webkit on linux 32bits)

actually w/ patch in, one test stopped to timeout for me, but it is probably not related.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133212</commentid>
    <comment_count>2</comment_count>
      <attachid>33081</attachid>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2009-07-20 13:37:50 -0700</bug_when>
    <thetext>Comment on attachment 33081
set the provisional documentLoader as the activeDocument in case of load failures (v0.1)

Thanks for your interest and thanks for you patch, but I think you&apos;re chasing down a non-issue.

Most importantly, a Frame shouldn&apos;t ever consider a failed, non-committed load as it&apos;s current DocumentLoader.  Making this change would be a change in behavior that many WebKit applications do not expect. Most notably, Safari would break with this change.

Can you explain an example of an application you&apos;re working on where this change is desirable?  And why?

Also, if a layout test times out with your patch in but runs correctly without your patch, that *is* indicative of a regression with your patch.  I bet the test is catching exactly the WebKit API breakage that I alluded to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133218</commentid>
    <comment_count>3</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-20 13:54:58 -0700</bug_when>
    <thetext>&gt; Thanks for your interest and thanks for you patch, but I think you&apos;re chasing
&gt; down a non-issue.

thanks for the comments.

&gt; Most importantly, a Frame shouldn&apos;t ever consider a failed, non-committed load
&gt; as it&apos;s current DocumentLoader.  Making this change would be a change in
&gt; behavior that many WebKit applications do not expect. Most notably, Safari
&gt; would break with this change.

is there any regression test for it ?

&gt; Can you explain an example of an application you&apos;re working on where this
&gt; change is desirable?  And why?

I should had mentioned it before, yes. I am working on https://bugs.webkit.org/show_bug.cgi?id=25867 (see patch 0.4) , which provides the url originally loaded by the frame.

in case of load failures, frameLoader-&gt;activeDocumentLoader points to a documentLoader instance of a (successful) previous load (see bug description). In this case, if i 

1) load google.com
2) load a known unexistent url
3) call originalUrl()
4) it calls FrameLoader::originalRequest() , which calls activeDocumentLoader()-&gt;originalRequest.url() =&gt; http://google.com

since activeDocumentLoader is not referring to the latest load but to the latest successful one.

so how do access the documentLoader that actually refers to the latest load (being in successful or not) ?

&gt; Also, if a layout test times out with your patch in but runs correctly without
&gt; your patch, that *is* indicative of a regression with your patch.  I bet the
&gt; test is catching exactly the WebKit API breakage that I alluded to.

i mis-explained maybe, but there is one less failing test w/ the patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133229</commentid>
    <comment_count>4</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2009-07-20 14:22:38 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; &gt; Also, if a layout test times out with your patch in but runs correctly without
&gt; &gt; your patch, that *is* indicative of a regression with your patch.  I bet the
&gt; &gt; test is catching exactly the WebKit API breakage that I alluded to.
&gt; 
&gt; i mis-explained maybe, but there is one less failing test w/ the patch.

Ah, yes I understood you to mean that your patch introduced a failure.  Since the Mac bots are all running green right now, I assume you mean there&apos;s a Qt failure that this cleans up.  But have you tried running the Mac tests with your patch in?

&gt; &gt; Most importantly, a Frame shouldn&apos;t ever consider a failed, non-committed load
&gt; &gt; as it&apos;s current DocumentLoader.  Making this change would be a change in
&gt; &gt; behavior that many WebKit applications do not expect. Most notably, Safari
&gt; &gt; would break with this change.
&gt; 
&gt; is there any regression test for it ?

I don&apos;t know - Do you have a Mac machine to try with your patch? 

It&apos;s quite possible there isn&apos;t, as one thing I know this patch breaks - which is the WebKit API [WebDataSource unreachableURL] - has historically been difficult to test automatically.

If your patch *doesn&apos;t* break any Mac layout tests, then we need to take the time to add one.

&gt; &gt; Can you explain an example of an application you&apos;re working on where this
&gt; &gt; change is desirable?  And why?
&gt; 
&gt; I should had mentioned it before, yes. I am working on
&gt; https://bugs.webkit.org/show_bug.cgi?id=25867 (see patch 0.4) , which provides
&gt; the url originally loaded by the frame.
&gt; 
&gt; in case of load failures, frameLoader-&gt;activeDocumentLoader points to a
&gt; documentLoader instance of a (successful) previous load (see bug description).
&gt; In this case, if i 
&gt; 
&gt; 1) load google.com
&gt; 2) load a known unexistent url
&gt; 3) call originalUrl()
&gt; 4) it calls FrameLoader::originalRequest() , which calls
&gt; activeDocumentLoader()-&gt;originalRequest.url() =&gt; http://google.com
&gt; 
&gt; since activeDocumentLoader is not referring to the latest load but to the
&gt; latest successful one.
&gt; 
&gt; so how do access the documentLoader that actually refers to the latest load
&gt; (being in successful or not) ?

I followed your description here and looked at the other bug.  Amusingly, the main thing this patch would break is what happens in the error case, which covered by DocumentLoader::unreachableURL().

When you say &quot;latest load&quot;, you are overloading some highly overloaded terminology.  In FrameLoader/DocumentLoader-land, the &quot;current load&quot; is the most recent main resource load to have been committed.  When a load fails because the url wasn&apos;t even valid, it was never committed, so the current activeDocumentLoader() remains unchanged.

Alas, information about this attempted-load-not-even-getting-started is tacked on the DocumentLoader.  Based on reading the other bug, you are happy with url() and originalURL(), but just want to know about failure cases.  What happens if you try using activeDocumentLoader()-&gt;mainDocumentError()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133230</commentid>
    <comment_count>5</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2009-07-20 14:24:25 -0700</bug_when>
    <thetext>Rereading even closer, it seems like you *WANT* &quot;originalURL()&quot; to return &quot;askjskdhf.asfjhsdjfhsd&quot; in the error case, right?

If so, what I suggested won&apos;t work.  Hmmm....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133327</commentid>
    <comment_count>6</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-20 19:03:15 -0700</bug_when>
    <thetext>thanks again for the comments , brady.

&gt; the Mac bots are all running green right now, I assume you mean there&apos;s a Qt
&gt; failure that this cleans up.  But have you tried running the Mac tests with
&gt; your patch in?

I will try it at work tomorrow and report the results.

&gt; I don&apos;t know - Do you have a Mac machine to try with your patch? 
&gt; It&apos;s quite possible there isn&apos;t, as one thing I know this patch breaks - which
&gt; is the WebKit API [WebDataSource unreachableURL] - has historically been
&gt; difficult to test automatically.
&gt; 
&gt; If your patch *doesn&apos;t* break any Mac layout tests, then we need to take the
&gt; time to add one.

that specific test would be definitively a great and needed add. So if no failure are catch on Mac when i re-run the tests, should I file a bug on adding that test ?

&gt; &gt; so how do access the documentLoader that actually refers to the latest load
&gt; &gt; (being in successful or not) ?
&gt; 
&gt; I followed your description here and looked at the other bug.  Amusingly, the
&gt; main thing this patch would break is what happens in the error case, which
&gt; covered by DocumentLoader::unreachableURL().

iirc, m_unreachebleURL will get set at object construction time. However I can not rely on it from qtwebkit api code, I am afraid.

&gt; When you say &quot;latest load&quot;, you are overloading some highly overloaded
&gt; terminology.  In FrameLoader/DocumentLoader-land, the &quot;current load&quot; is the
&gt; most recent main resource load to have been committed.  When a load fails
&gt; because the url wasn&apos;t even valid, it was never committed, so the current
&gt; activeDocumentLoader() remains unchanged.

sorry for mis-using the term ... i see and agree w/ what you pointed out, although i still think having access to the unsuccessful resource loader could be helpful. What do you think ?

&gt; Alas, information about this attempted-load-not-even-getting-started is tacked
&gt; on the DocumentLoader.  Based on reading the other bug, you are happy with
&gt; url() and originalURL(), but just want to know about failure cases.  

exactly that.

&gt; What happens if you try using activeDocumentLoader()-&gt;mainDocumentError()?

as you said, I could use that *if* activeDocumentLoader() returns the resource loader corresponding to the failing loader. I will check ...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133341</commentid>
    <comment_count>7</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2009-07-20 19:44:55 -0700</bug_when>
    <thetext>
&gt; &gt; What happens if you try using activeDocumentLoader()-&gt;mainDocumentError()?
&gt; 
&gt; as you said, I could use that *if* activeDocumentLoader() returns the resource
&gt; loader corresponding to the failing loader. I will check ...

I don&apos;t have time to run the experiment right now, but I think mainResourceError might be set on the current document loader, even in this case, along with unreachableURL.  

I might be wrong, though.  Let us know what you find.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133471</commentid>
    <comment_count>8</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-21 08:39:42 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; &gt; &gt; What happens if you try using activeDocumentLoader()-&gt;mainDocumentError()?
&gt; &gt; 
&gt; &gt; as you said, I could use that *if* activeDocumentLoader() returns the resource
&gt; &gt; loader corresponding to the failing loader. I will check ...
&gt; 
&gt; I don&apos;t have time to run the experiment right now, but I think
&gt; mainResourceError might be set on the current document loader, even in this
&gt; case, along with unreachableURL.  

hum, DocumentLoader::setMainResourceError() gets called in the right (failing) loader, ok. It calls FrameLoader::setMainDocumentError(error), which on its turn calls FrameLoaderClientXXX()::setMainDocumentError ...

that can be possibly a bridge. I could try emit a signal from it to be catch in QWebFrame, where I need to know if the load was successful or not.

if it is not successful (case where I am stuck on) I can get the originalUrl from calling FrameLoader::outgoingReferrer()

simon, what do you think ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>134742</commentid>
    <comment_count>9</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-25 08:29:57 -0700</bug_when>
    <thetext>&gt; &gt; I don&apos;t know - Do you have a Mac machine to try with your patch? 
&gt; &gt; It&apos;s quite possible there isn&apos;t, as one thing I know this patch breaks - which
&gt; &gt; is the WebKit API [WebDataSource unreachableURL] - has historically been
&gt; &gt; difficult to test automatically.
&gt; &gt; 
&gt; &gt; If your patch *doesn&apos;t* break any Mac layout tests, then we need to take the
&gt; &gt; time to add one.

i will try it on a MAC when i have a change. and file a bug is no test catches the possibly problem introduced by my patch.

for now, closing this one as INVALID.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>33081</attachid>
            <date>2009-07-20 06:35:23 -0700</date>
            <delta_ts>2009-07-20 13:37:49 -0700</delta_ts>
            <desc>set the provisional documentLoader as the activeDocument in case of load failures (v0.1)</desc>
            <filename>BUG_XXX.diff</filename>
            <type>text/plain</type>
            <size>705</size>
            <attacher name="Antonio Gomes">tonikitoo</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvbG9hZGVyL0ZyYW1lTG9hZGVyLmNwcCBiL1dlYkNvcmUvbG9h
ZGVyL0ZyYW1lTG9hZGVyLmNwcAppbmRleCBhZjU5Mjk5Li4zNThiMmQ5IDEwMDY0NAotLS0gYS9X
ZWJDb3JlL2xvYWRlci9GcmFtZUxvYWRlci5jcHAKKysrIGIvV2ViQ29yZS9sb2FkZXIvRnJhbWVM
b2FkZXIuY3BwCkBAIC00ODcyLDYgKzQ4NzIsMTAgQEAgdm9pZCBGcmFtZUxvYWRlcjo6bWFpblJl
Y2VpdmVkQ29tcGxldGVFcnJvcihEb2N1bWVudExvYWRlciogbG9hZGVyLCBjb25zdCBSZXNvdXIK
IHsKICAgICBsb2FkZXItPnNldFByaW1hcnlMb2FkQ29tcGxldGUodHJ1ZSk7CiAgICAgbV9jbGll
bnQtPmRpc3BhdGNoRGlkTG9hZE1haW5SZXNvdXJjZShhY3RpdmVEb2N1bWVudExvYWRlcigpKTsK
KyAgICAvLyBzZXR0aW5nIHRoZSBwcm92aXNpb25hbERvY3VtZW50TG9hZGVyIGFzIGFjdGl2ZURv
Y3VtZW50TG9hZGVyIHNvCisgICAgLy8gd2UgaGF2ZSBhIHJlZmVyZW5jZSBmb3IgdGhlIGFjdGl2
ZSBsb2FkZXIgYWZ0ZXIgdGhlIGxvYWRpbmcKKyAgICAvLyBmYWlsdXJlIGhhcHBlbmRlZC4KKyAg
ICBzZXREb2N1bWVudExvYWRlcihtX3Byb3Zpc2lvbmFsRG9jdW1lbnRMb2FkZXIuZ2V0KCkpOwog
ICAgIGNoZWNrQ29tcGxldGVkKCk7CiAgICAgaWYgKG1fZnJhbWUtPnBhZ2UoKSkKICAgICAgICAg
Y2hlY2tMb2FkQ29tcGxldGUoKTsK
</data>
<flag name="review"
          id="17411"
          type_id="1"
          status="-"
          setter="beidson"
    />
          </attachment>
      

    </bug>

</bugzilla>