<?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>188783</bug_id>
          
          <creation_ts>2018-08-21 04:36:25 -0700</creation_ts>
          <short_desc>Cookies not available when requestStorageAccess successfully resolves after &quot;allow&quot; in ITP prompt</short_desc>
          <delta_ts>2018-08-21 23:45:51 -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>New Bugs</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.13</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=188830</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ulf Liedberg">ulf</reporter>
          <assigned_to name="John Wilander">wilander</assigned_to>
          <cc>achristensen</cc>
    
    <cc>commit-queue</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wilander</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1452028</commentid>
    <comment_count>0</comment_count>
    <who name="Ulf Liedberg">ulf</who>
    <bug_when>2018-08-21 04:36:25 -0700</bug_when>
    <thetext>John Wilander asked me to file a bug here after a bit of discussion on twitter. Not sure if I&apos;m misunderstanding/misusing the Storage Access API but here&apos;s my case. 

When the user answers &quot;allow&quot; on the ITP prompt the cookies are not available in the 3rd party context directly. Not in the requestStorageAccess success callback and not afterwards. If the iframe is __reloaded__ and requestStorageAccess called it&apos;s, as expected, automatically successfully resolved and I have access to cookies.

Reproduction repo: https://github.com/uliedberg/itp2-test/tree/master/basic-basic-browser-set-cookies-only . I&apos;ve also put up the main &amp; third party parts on different domains for easier reproduction.

The third party iframe page will call hasStorageAccess() on load.

* &gt; defaults write com.apple.SafariTechnologyPreview ResourceLoadStatisticsManualPrevalentResource liedberg.org
* in Safari Technology Preview 63, clear history and then open: 
	- https://www.alfhild.io/itp2/main/?thirdparty-url=https%3A%2F%2Fwww.liedberg.org%2Fitp2%2Fthirdparty%2F
1. Click &quot;open popup&quot; link (third party in main page)
2. Click &quot;write cookie&quot; link (popup page)
3. Click &quot;close&quot; link (popup page)
4. Click &quot;request access&quot; link (third party in main page)
5. Select &quot;allow&quot; in ITP prompt (main page)
	- at this point the third party iframe tries to read the cookie but no value
6. Click &quot;read cookie&quot; link (third party in main page)
	- no value still
7. Click &quot;reload iframe&quot; link (third party in main page)
8. Click &quot;request access&quot; link (third party in main page)
	- __now__ the cookies are available</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452075</commentid>
    <comment_count>1</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2018-08-21 06:36:44 -0700</bug_when>
    <thetext>Thanks, Ulf!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452076</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-08-21 06:37:22 -0700</bug_when>
    <thetext>&lt;rdar://problem/43559215&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452321</commentid>
    <comment_count>3</comment_count>
      <attachid>347705</attachid>
    <who name="John Wilander">wilander</who>
    <bug_when>2018-08-21 14:56:48 -0700</bug_when>
    <thetext>Created attachment 347705
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452323</commentid>
    <comment_count>4</comment_count>
    <who name="John Wilander">wilander</who>
    <bug_when>2018-08-21 15:01:33 -0700</bug_when>
    <thetext>I found the bug, and it&apos;s related to the other bug you reported about the prompt showing the full host names instead of eTLD+1s.

The specific code path for the prompt sends the host names instead of the eTLD+1s which means storage access is granted for the host and not the eTLD+1. Then, when cookie resolution happens, there is no storage access entry for the eTLD+1 and thus no cookies.

The second code path, i.e. without a prompt, correctly stores and entry for the eTLD+1 and resolution works.

Again, thanks for the bug report, Ulf!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452344</commentid>
    <comment_count>5</comment_count>
      <attachid>347705</attachid>
    <who name="John Wilander">wilander</who>
    <bug_when>2018-08-21 15:25:45 -0700</bug_when>
    <thetext>Comment on attachment 347705
Patch

Thanks, Alex!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452390</commentid>
    <comment_count>6</comment_count>
      <attachid>347705</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-08-21 16:32:39 -0700</bug_when>
    <thetext>Comment on attachment 347705
Patch

Clearing flags on attachment: 347705

Committed r235145: &lt;https://trac.webkit.org/changeset/235145&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452391</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-08-21 16:32:41 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452547</commentid>
    <comment_count>8</comment_count>
    <who name="Ulf Liedberg">ulf</who>
    <bug_when>2018-08-21 23:45:51 -0700</bug_when>
    <thetext>Happy to help!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>347705</attachid>
            <date>2018-08-21 14:56:48 -0700</date>
            <delta_ts>2018-08-21 16:32:39 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-188783-20180821145647.patch</filename>
            <type>text/plain</type>
            <size>2119</size>
            <attacher name="John Wilander">wilander</attacher>
            
              <data encoding="base64">U3VidmVyc2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