<?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>184987</bug_id>
          
          <creation_ts>2018-04-25 11:55:17 -0700</creation_ts>
          <short_desc>[Cocoa] ResourceRequest constructors should retain &apos;isTopSite&apos; (and other) state</short_desc>
          <delta_ts>2019-02-21 10:15:53 -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>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=194906</see_also>
          <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>1</everconfirmed>
          <reporter name="Brent Fulgham">bfulgham</reporter>
          <assigned_to name="Daniel Bates">dbates</assigned_to>
          <cc>achristensen</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>csaavedra</cc>
    
    <cc>dbates</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>japhet</cc>
    
    <cc>sam</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1417663</commentid>
    <comment_count>0</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2018-04-25 11:55:17 -0700</bug_when>
    <thetext>When we convert a ResourceRequest to a cocoa type (e.g., CFURLRequest/NSURLRequest) for Cocoa/CFNetwork API use, and then attempt to build new ResourceRequest objects (perhaps during redirect delegate calls from CFNetwork) using the constructors from CFURLRequest and NSURLRequest, we end up losing useful states (e.g., &apos;isTopSite()&apos;).

We should try to retain this state somewhere, perhaps by using properties on the CFNetwork objects (e.g., _propertyForKey:@&quot;_kCFHTTPCookiePolicyPropertyIsTopLevelNavigation&quot;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417778</commentid>
    <comment_count>1</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-04-25 14:32:32 -0700</bug_when>
    <thetext>(In reply to Brent Fulgham from comment #0)
&gt; When we convert a ResourceRequest to a cocoa type (e.g.,
&gt; CFURLRequest/NSURLRequest) for Cocoa/CFNetwork API use, and then attempt to
&gt; build new ResourceRequest objects (perhaps during redirect delegate calls
&gt; from CFNetwork) using the constructors from CFURLRequest and NSURLRequest,
&gt; we end up losing useful states (e.g., &apos;isTopSite()&apos;).
&gt; 

As it turns out, we only set ResourceRequest::isTopSite() if the ResourceRequest::isSameSiteUnspecified(). So, the result you are seeing of ResourceRequest::isTopSite() returning false in -[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:] is because we conditionally set ResourceRequest::isTopSite(). Instead we should uncondtionally set ResourceRequest::isTopSite() whenever we are loading a main resource.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417788</commentid>
    <comment_count>2</comment_count>
      <attachid>338798</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-04-25 14:46:05 -0700</bug_when>
    <thetext>Created attachment 338798
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417807</commentid>
    <comment_count>3</comment_count>
      <attachid>338798</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-04-25 15:15:10 -0700</bug_when>
    <thetext>Comment on attachment 338798
Patch

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

&gt; Source/WebCore/ChangeLog:12
&gt; +        commit.

I am not sure ResourceRequest is the right place for this kind of information.
Maybe this should be a loader option instead?

As an example, we create new requests in the case of redirections.
In that case, we would need to make sure isTopSite sticks to the new request, which I am not sure is guaranteed in all code paths.
Having this information as a loader option might be more robust.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417820</commentid>
    <comment_count>4</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-04-25 15:29:51 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #3)
&gt; Comment on attachment 338798 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=338798&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/ChangeLog:12
&gt; &gt; +        commit.
&gt; 
&gt; I am not sure ResourceRequest is the right place for this kind of
&gt; information.
&gt; Maybe this should be a loader option instead?

Do you feel it is necessary to address this in this patch?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417904</commentid>
    <comment_count>5</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2018-04-25 17:26:08 -0700</bug_when>
    <thetext>Is &quot;top site&quot; as a term relatively new to WebKit? I don&apos;t remember seeing it before. I find it a bit confusing. &quot;Site&quot; is a term we don&apos;t traditionally use (outside of the term of art &quot;site-specific quirks&quot;).

If what it is referring to is a main frame navigation, can we call it that, or match the CFNetwork terminology and it call it a &quot;top level navigation&quot;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1418036</commentid>
    <comment_count>6</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2018-04-26 07:56:49 -0700</bug_when>
    <thetext>For what it&apos;s worth, I was investigating whether I could use this for the libsoup network backend&apos;s implementation of HSTS (knowing whether the request is not for a toplevel frame would allow us to mitigate HSTS abuse) and came across this same bug, and the patch looks right to me.

I suspect that &quot;top site&quot; makes sense in the context of same-site cookies, but as described above there are more cases in which this information is useful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1418112</commentid>
    <comment_count>7</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2018-04-26 10:28:11 -0700</bug_when>
    <thetext>(In reply to Sam Weinig from comment #5)
&gt; Is &quot;top site&quot; as a term relatively new to WebKit? I don&apos;t remember seeing it
&gt; before. I find it a bit confusing. &quot;Site&quot; is a term we don&apos;t traditionally
&gt; use (outside of the term of art &quot;site-specific quirks&quot;).
&gt; 
&gt; If what it is referring to is a main frame navigation, can we call it that,
&gt; or match the CFNetwork terminology and it call it a &quot;top level navigation&quot;?

I agree.  When I see &quot;top site&quot; I think it must be a very popular website.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1418122</commentid>
    <comment_count>8</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-04-26 10:49:08 -0700</bug_when>
    <thetext>This parameter is very close to FetchOptions::Mode.
As it is immutable, I would consider moving it to a loader option, plus this would be platform-agnostic.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1423997</commentid>
    <comment_count>9</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2018-05-15 04:59:21 -0700</bug_when>
    <thetext>Regardless of the criticism that you might have for the method&apos;s name, the code is not working reliably and the discussion is stalled. Can we please fix it at at least so that it&apos;s not inconsistent?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1424124</commentid>
    <comment_count>10</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-05-15 14:20:59 -0700</bug_when>
    <thetext>In NetworkProcess side, there is NetworkResourceLoadParameters.options.destination and NetworkLoadParameters.isMainFrameNavigation.
That tells whether the load is for a document and whether this is for the main frame.
Claudio, would that be sufficient for your use case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1482380</commentid>
    <comment_count>11</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2018-11-28 00:34:54 -0800</bug_when>
    <thetext>(In reply to youenn fablet from comment #10)
&gt; In NetworkProcess side, there is
&gt; NetworkResourceLoadParameters.options.destination and
&gt; NetworkLoadParameters.isMainFrameNavigation.
&gt; That tells whether the load is for a document and whether this is for the
&gt; main frame.
&gt; Claudio, would that be sufficient for your use case?

It might, I have to check it. I will during these days, now that I&apos;ve retaken the HSTS work. However, this bug stands valid. You have internal API that is not working consistently. We either remove it or fix it. Having it broken because of a posteriori disagreement is not a good idea.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508562</commentid>
    <comment_count>12</comment_count>
      <attachid>338798</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-02-21 10:14:58 -0800</bug_when>
    <thetext>Comment on attachment 338798
Patch

Declaring bankruptcy on this bug. Fix is correct and Claudio Saavedra is the only person that could figure this out. I suspect the confusion arose because I thought I could kill two birds with one stone with this bug: 1) fix the correctness issue myself and Claudio noticed and 2) provide an enhancement for Brent to use (see the request in comment #0). It would later turn out that Brent would not need this enhancement as he forged his own equivalent, NetworkLoadParameters.isMainFrameNavigation (as pointed out in comment #10). Untangling this mess by reverting the name of the bug back to its original name and closing it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508563</commentid>
    <comment_count>13</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-02-21 10:15:25 -0800</bug_when>
    <thetext>I will fix the correctness issue in bug #194906.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>338798</attachid>
            <date>2018-04-25 14:46:05 -0700</date>
            <delta_ts>2019-02-21 10:14:58 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-184987-20180425144604.patch</filename>
            <type>text/plain</type>
            <size>3013</size>
            <attacher name="Daniel Bates">dbates</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMwOTc3CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOGQ3NTczNzczMTJkNzI3
MDE3ZWQwNDZmOD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