<?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>184068</bug_id>
          
          <creation_ts>2018-03-27 19:34:25 -0700</creation_ts>
          <short_desc>WebSocket::didReceiveMessage() may construct a SecurityOrigin object on a non-main thread</short_desc>
          <delta_ts>2018-04-05 10:32:33 -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>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <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>
          
          <blocked>184059</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>ap</cc>
    
    <cc>dbates</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1409758</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-27 19:34:25 -0700</bug_when>
    <thetext>WebSocket::didReceiveMessage() may construct a SecurityOrigin object on a non-main thread, which is not safe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1409759</commentid>
    <comment_count>1</comment_count>
      <attachid>336637</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-27 19:35:36 -0700</bug_when>
    <thetext>Created attachment 336637
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1409773</commentid>
    <comment_count>2</comment_count>
      <attachid>336641</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-27 20:34:53 -0700</bug_when>
    <thetext>Created attachment 336641
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410007</commentid>
    <comment_count>3</comment_count>
      <attachid>336641</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-03-28 13:09:45 -0700</bug_when>
    <thetext>Comment on attachment 336641
Patch

Maybe we could assert in SecurityOriginData::toString that URL is http/https/ws/wss.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410013</commentid>
    <comment_count>4</comment_count>
      <attachid>336641</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-28 13:17:09 -0700</bug_when>
    <thetext>Comment on attachment 336641
Patch

Clearing flags on attachment: 336641

Committed r230042: &lt;https://trac.webkit.org/changeset/230042&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410014</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-28 13:17:10 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410016</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-03-28 13:18:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/38969197&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410150</commentid>
    <comment_count>7</comment_count>
      <attachid>336641</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-03-28 18:41:44 -0700</bug_when>
    <thetext>Comment on attachment 336641
Patch

This patch is not right. SecurityOriginData::toString() is not equivalent to SecurityOrigin::toString(). We need to stop and think before transitioning any  any more WebCore code to SecurityOriginData. It is not safe to do so.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410152</commentid>
    <comment_count>8</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-03-28 18:59:14 -0700</bug_when>
    <thetext>(In reply to Daniel Bates from comment #7)
&gt; Comment on attachment 336641 [details]
&gt; Patch
&gt; 
&gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.

In that particular case, the URL is ws or wss, so I think this patch is correct as per https://url.spec.whatwg.org/#concept-url-origin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410166</commentid>
    <comment_count>9</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-03-28 20:13:22 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #8)
&gt; (In reply to Daniel Bates from comment #7)
&gt; &gt; Comment on attachment 336641 [details]
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; &gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; &gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.
&gt; 
&gt; In that particular case, the URL is ws or wss, so I think this patch is
&gt; correct as per https://url.spec.whatwg.org/#concept-url-origin.

This is not the correct section of the spec. to reference.

Take m_url to be the parsed URL corresponding to ws://example.com. Let D be the result of SecurityOriginData::fromURL(m_url) and S be the result of SecurityOrigin::create(m_url). Then D.toString() = &quot;ws://example.com:0&quot; != &quot;ws://example.com&quot; = S.toString().

Disregarding the aforementioned correctness issue, this patch is self-contradictory because it only &quot;fixes&quot; the usage of SecurityOrigin in WebSocket::didReceiveMessage(). It does not fix other uses of SecurityOrigin::create(m_url) in WebSocket::didReceiveBinaryData(). Regardless, I disagree with the approach of transitioning code from SecurityOrigin to SecurityOriginData in WebCore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410168</commentid>
    <comment_count>10</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-28 20:18:53 -0700</bug_when>
    <thetext>(In reply to Daniel Bates from comment #9)
&gt; (In reply to youenn fablet from comment #8)
&gt; &gt; (In reply to Daniel Bates from comment #7)
&gt; &gt; &gt; Comment on attachment 336641 [details]
&gt; &gt; &gt; Patch
&gt; &gt; &gt; 
&gt; &gt; &gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; &gt; &gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; &gt; &gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.
&gt; &gt; 
&gt; &gt; In that particular case, the URL is ws or wss, so I think this patch is
&gt; &gt; correct as per https://url.spec.whatwg.org/#concept-url-origin.
&gt; 
&gt; This is not the correct section of the spec. to reference.
&gt; 
&gt; Take m_url to be the parsed URL corresponding to ws://example.com. Let D be
&gt; the result of SecurityOriginData::fromURL(m_url) and S be the result of
&gt; SecurityOrigin::create(m_url). Then D.toString() = &quot;ws://example.com:0&quot; !=
&gt; &quot;ws://example.com&quot; = S.toString().

Where is &quot;ws://example.com:0&quot; coming from? D.toString() would return &quot;ws://example.com&quot; (as of last week end).

&gt; 
&gt; Disregarding the aforementioned correctness issue, this patch is
&gt; self-contradictory because it only &quot;fixes&quot; the usage of SecurityOrigin in
&gt; WebSocket::didReceiveMessage(). It does not fix other uses of
&gt; SecurityOrigin::create(m_url) in WebSocket::didReceiveBinaryData().
I am still going though the assertion failures and fixing them as I find them.

&gt; Regardless, I disagree with the approach of transitioning code from
&gt; SecurityOrigin to SecurityOriginData in WebCore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410173</commentid>
    <comment_count>11</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-03-28 20:30:04 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #10)
&gt; (In reply to Daniel Bates from comment #9)
&gt; &gt; (In reply to youenn fablet from comment #8)
&gt; &gt; &gt; (In reply to Daniel Bates from comment #7)
&gt; &gt; &gt; &gt; Comment on attachment 336641 [details]
&gt; &gt; &gt; &gt; Patch
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; &gt; &gt; &gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; &gt; &gt; &gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.
&gt; &gt; &gt; 
&gt; &gt; &gt; In that particular case, the URL is ws or wss, so I think this patch is
&gt; &gt; &gt; correct as per https://url.spec.whatwg.org/#concept-url-origin.
&gt; &gt; 
&gt; &gt; This is not the correct section of the spec. to reference.
&gt; &gt; 
&gt; &gt; Take m_url to be the parsed URL corresponding to ws://example.com. Let D be
&gt; &gt; the result of SecurityOriginData::fromURL(m_url) and S be the result of
&gt; &gt; SecurityOrigin::create(m_url). Then D.toString() = &quot;ws://example.com:0&quot; !=
&gt; &gt; &quot;ws://example.com&quot; = S.toString().
&gt; 
&gt; Where is &quot;ws://example.com:0&quot; coming from? D.toString() would return
&gt; &quot;ws://example.com&quot; (as of last week end).
&gt; 

Oops, I was looking at an old revision. I see that &lt;https://trac.webkit.org/changeset/229954/&gt; fixed up SecurityOriginData::toString(). Regardless, I do not like the direction of where we are going with SecurityOriginData. Both SecurityOrigin::toString() and SecurityOriginData::toString() are implementing some subset of the origin serialization algorithm.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410174</commentid>
    <comment_count>12</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-28 20:33:53 -0700</bug_when>
    <thetext>(In reply to Daniel Bates from comment #11)
&gt; (In reply to Chris Dumez from comment #10)
&gt; &gt; (In reply to Daniel Bates from comment #9)
&gt; &gt; &gt; (In reply to youenn fablet from comment #8)
&gt; &gt; &gt; &gt; (In reply to Daniel Bates from comment #7)
&gt; &gt; &gt; &gt; &gt; Comment on attachment 336641 [details]
&gt; &gt; &gt; &gt; &gt; Patch
&gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; &gt; &gt; &gt; &gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; &gt; &gt; &gt; &gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; In that particular case, the URL is ws or wss, so I think this patch is
&gt; &gt; &gt; &gt; correct as per https://url.spec.whatwg.org/#concept-url-origin.
&gt; &gt; &gt; 
&gt; &gt; &gt; This is not the correct section of the spec. to reference.
&gt; &gt; &gt; 
&gt; &gt; &gt; Take m_url to be the parsed URL corresponding to ws://example.com. Let D be
&gt; &gt; &gt; the result of SecurityOriginData::fromURL(m_url) and S be the result of
&gt; &gt; &gt; SecurityOrigin::create(m_url). Then D.toString() = &quot;ws://example.com:0&quot; !=
&gt; &gt; &gt; &quot;ws://example.com&quot; = S.toString().
&gt; &gt; 
&gt; &gt; Where is &quot;ws://example.com:0&quot; coming from? D.toString() would return
&gt; &gt; &quot;ws://example.com&quot; (as of last week end).
&gt; &gt; 
&gt; 
&gt; Oops, I was looking at an old revision. I see that
&gt; &lt;https://trac.webkit.org/changeset/229954/&gt; fixed up
&gt; SecurityOriginData::toString(). Regardless, I do not like the direction of
&gt; where we are going with SecurityOriginData. Both SecurityOrigin::toString()
&gt; and SecurityOriginData::toString() are implementing some subset of the
&gt; origin serialization algorithm.

What is your alternative proposal here?

Note that there are more usage of SecurityOrigin::create() on non-main threads than we originally thought. Maybe we should just give up and make SecurityOrigin::create() safe to call from a background thread? What do you guys think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410177</commentid>
    <comment_count>13</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-03-28 20:46:32 -0700</bug_when>
    <thetext>It seems to me that what we need is a thread safe way to serialize an origin directly from an URL. Maybe this is simpler to implement than a fully thread safe SecurityOrigin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410178</commentid>
    <comment_count>14</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-28 20:51:18 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #13)
&gt; It seems to me that what we need is a thread safe way to serialize an origin
&gt; directly from an URL. Maybe this is simpler to implement than a fully thread
&gt; safe SecurityOrigin.

We are saying the same thing, I never said anything about making SecurityOrigin (fully) thread safe. I just want to make it OK to call SecurityOrigin::create(url) from a background thread.

Similar to String. It is safe to construct a String on any thread. It is not safe to pass a string to another thread unless you isolatecopy.
We could do the same for SecurityOrigin.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410181</commentid>
    <comment_count>15</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-03-28 21:00:52 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #10)
&gt; &gt; 
&gt; &gt; Disregarding the aforementioned correctness issue, this patch is
&gt; &gt; self-contradictory because it only &quot;fixes&quot; the usage of SecurityOrigin in
&gt; &gt; WebSocket::didReceiveMessage(). It does not fix other uses of
&gt; &gt; SecurityOrigin::create(m_url) in WebSocket::didReceiveBinaryData().
&gt; I am still going though the assertion failures and fixing them as I find
&gt; them.
&gt; 

This is playing whack-a-mole with our security and thread safety. This does not seem like a good strategy that will lead to high confidence of correctness and quality software. This strategy assumes that we have perfect test coverage both covering all WebCore lines of code AND covering all possible test cases because we only hit an assertion failure if execution passes over the asserted code. I would hope we have test coverage to cover WebSocket::didReceiveBinaryData() being called from a background thread. I do not have the list of tests that cause assertion failures that you are working through (please file bugs instead of keeping them in your head or waiting for others to hit the assertion failures). According to &lt;https://bugs.webkit.org/buglist.cgi?bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;bug_status=RESOLVED&amp;chfield=%5BBug%20creation%5D&amp;chfieldfrom=2018-03-27&amp;chfieldto=2018-03-28&amp;email1=cdumez%40apple.com&amp;emailreporter1=1&amp;emailtype1=substring&amp;list_id=3588091&amp;query_format=advanced&gt; I see only two bugs about assertion failures filed between yesterday and today:

(This bug) WebSocket::didReceiveMessage() may construct a SecurityOrigin object on a non-main thread
&lt;https://bugs.webkit.org/show_bug.cgi?id=184068&gt;

And

Thread safety issue in IDBFactory&apos; shouldThrowSecurityException()
&lt;https://bugs.webkit.org/show_bug.cgi?id=184064&gt;

Instead I suggest we use the assertion failures are a guide, together with a strategy of grep&apos;ing for all SecurityOrigin usage around the assert that failed (would have caught the issue in WebSocket::didReceiveBinaryData()), as well as grep&apos;ing all of WebCore and auditing threaded code.

Filed bug #184125 to fix up WebSocket::didReceiveBinaryData().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410185</commentid>
    <comment_count>16</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-28 21:30:17 -0700</bug_when>
    <thetext>(In reply to Daniel Bates from comment #15)
&gt; (In reply to Chris Dumez from comment #10)
&gt; &gt; &gt; 
&gt; &gt; &gt; Disregarding the aforementioned correctness issue, this patch is
&gt; &gt; &gt; self-contradictory because it only &quot;fixes&quot; the usage of SecurityOrigin in
&gt; &gt; &gt; WebSocket::didReceiveMessage(). It does not fix other uses of
&gt; &gt; &gt; SecurityOrigin::create(m_url) in WebSocket::didReceiveBinaryData().
&gt; &gt; I am still going though the assertion failures and fixing them as I find
&gt; &gt; them.
&gt; &gt; 
&gt; 
&gt; This is playing whack-a-mole with our security and thread safety. This does
&gt; not seem like a good strategy that will lead to high confidence of
&gt; correctness and quality software. This strategy assumes that we have perfect
&gt; test coverage both covering all WebCore lines of code AND covering all
&gt; possible test cases because we only hit an assertion failure if execution
&gt; passes over the asserted code. I would hope we have test coverage to cover
&gt; WebSocket::didReceiveBinaryData() being called from a background thread. I
&gt; do not have the list of tests that cause assertion failures that you are
&gt; working through (please file bugs instead of keeping them in your head or
&gt; waiting for others to hit the assertion failures). According to
&gt; &lt;https://bugs.webkit.org/buglist.
&gt; cgi?bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOP
&gt; ENED&amp;bug_status=RESOLVED&amp;chfield=%5BBug%20creation%5D&amp;chfieldfrom=2018-03-
&gt; 27&amp;chfieldto=2018-03-28&amp;email1=cdumez%40apple.
&gt; com&amp;emailreporter1=1&amp;emailtype1=substring&amp;list_id=3588091&amp;query_format=advanc
&gt; ed&gt; I see only two bugs about assertion failures filed between yesterday and
&gt; today:
&gt; 
&gt; (This bug) WebSocket::didReceiveMessage() may construct a SecurityOrigin
&gt; object on a non-main thread
&gt; &lt;https://bugs.webkit.org/show_bug.cgi?id=184068&gt;
&gt; 
&gt; And
&gt; 
&gt; Thread safety issue in IDBFactory&apos; shouldThrowSecurityException()
&gt; &lt;https://bugs.webkit.org/show_bug.cgi?id=184064&gt;
&gt; 
&gt; Instead I suggest we use the assertion failures are a guide, together with a
&gt; strategy of grep&apos;ing for all SecurityOrigin usage around the assert that
&gt; failed (would have caught the issue in WebSocket::didReceiveBinaryData()),
&gt; as well as grep&apos;ing all of WebCore and auditing threaded code.
&gt; 
&gt; Filed bug #184125 to fix up WebSocket::didReceiveBinaryData().

I have landed at least 5 patches already and still not done. SecurityOrigin is already almost safe to construct from a background thread and making it fully safe would likely be less work and avoid annoying refactorings (especially if you do not want to use SecurityOriginData in WebCore).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410187</commentid>
    <comment_count>17</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-03-28 22:16:34 -0700</bug_when>
    <thetext>Some thoughts.

From what I see, for serializing an origin from an URL, calling shouldTreatAsPotentiallyTrustworthy is not needed.
The serialization just needs to know a SecurityOriginData and a isUnique boolean.

We could have something like:
- A &quot;String serializeURLOrigin(const URL&amp;)&quot; utility function.
- serializeURLOrigin and SecurityOrigin would use an underlying function taking a SecurityOriginData and a isUnique boolean.

As of the computation of the isUnique value from background threads, we could make shouldTreatAsUniqueOrigin thread safe.
It seems that http/https/ws/wss/ftp/data/blob could be special cased for efficiency.

Not sure about blobs though.
Maybe callOnMainThreadAndWait to create a temporary SecurityOrigin is good enough.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410261</commentid>
    <comment_count>18</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-29 08:10:44 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #17)
&gt; Some thoughts.
&gt; 
&gt; From what I see, for serializing an origin from an URL, calling
&gt; shouldTreatAsPotentiallyTrustworthy is not needed.
&gt; The serialization just needs to know a SecurityOriginData and a isUnique
&gt; boolean.
&gt; 
&gt; We could have something like:
&gt; - A &quot;String serializeURLOrigin(const URL&amp;)&quot; utility function.
&gt; - serializeURLOrigin and SecurityOrigin would use an underlying function
&gt; taking a SecurityOriginData and a isUnique boolean.
&gt; 
&gt; As of the computation of the isUnique value from background threads, we
&gt; could make shouldTreatAsUniqueOrigin thread safe.
&gt; It seems that http/https/ws/wss/ftp/data/blob could be special cased for
&gt; efficiency.
&gt; 
&gt; Not sure about blobs though.
&gt; Maybe callOnMainThreadAndWait to create a temporary SecurityOrigin is good
&gt; enough.

this is not just about serialization. What if we need to know if an URL is cross origin synchronously from a background thread? Then we’d need canAccess() too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410287</commentid>
    <comment_count>19</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-03-29 09:33:00 -0700</bug_when>
    <thetext>&gt; this is not just about serialization. What if we need to know if an URL is
&gt; cross origin synchronously from a background thread? Then we’d need
&gt; canAccess() too.

Yeah... then it seems that making SecurityOrigin fully thread-safe seems like the safest approach.

FWIW, looking at CSP implementation, we might need to sync some SchemeRegistries to NetworkProcess. It seems natural then to try syncing all of them and make SecurityOrigin usable in NetworkProcess.

That would extend the scope of usage of SecurityOrigin, which would increase the risk for unnoticed usage of SecurityOrigin in background threads.
I think that for now it will be main thread only.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410305</commentid>
    <comment_count>20</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2018-03-29 10:35:39 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #12)
&gt; (In reply to Daniel Bates from comment #11)
&gt; &gt; (In reply to Chris Dumez from comment #10)
&gt; &gt; &gt; (In reply to Daniel Bates from comment #9)
&gt; &gt; &gt; &gt; (In reply to youenn fablet from comment #8)
&gt; &gt; &gt; &gt; &gt; (In reply to Daniel Bates from comment #7)
&gt; &gt; &gt; &gt; &gt; &gt; Comment on attachment 336641 [details]
&gt; &gt; &gt; &gt; &gt; &gt; Patch
&gt; &gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; &gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; &gt; &gt; &gt; &gt; &gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; &gt; &gt; &gt; &gt; &gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.
&gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; In that particular case, the URL is ws or wss, so I think this patch is
&gt; &gt; &gt; &gt; &gt; correct as per https://url.spec.whatwg.org/#concept-url-origin.
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; This is not the correct section of the spec. to reference.
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; Take m_url to be the parsed URL corresponding to ws://example.com. Let D be
&gt; &gt; &gt; &gt; the result of SecurityOriginData::fromURL(m_url) and S be the result of
&gt; &gt; &gt; &gt; SecurityOrigin::create(m_url). Then D.toString() = &quot;ws://example.com:0&quot; !=
&gt; &gt; &gt; &gt; &quot;ws://example.com&quot; = S.toString().
&gt; &gt; &gt; 
&gt; &gt; &gt; Where is &quot;ws://example.com:0&quot; coming from? D.toString() would return
&gt; &gt; &gt; &quot;ws://example.com&quot; (as of last week end).
&gt; &gt; &gt; 
&gt; &gt; 
&gt; &gt; Oops, I was looking at an old revision. I see that
&gt; &gt; &lt;https://trac.webkit.org/changeset/229954/&gt; fixed up
&gt; &gt; SecurityOriginData::toString(). Regardless, I do not like the direction of
&gt; &gt; where we are going with SecurityOriginData. Both SecurityOrigin::toString()
&gt; &gt; and SecurityOriginData::toString() are implementing some subset of the
&gt; &gt; origin serialization algorithm.
&gt; 
&gt; What is your alternative proposal here?
&gt; 
&gt; Note that there are more usage of SecurityOrigin::create() on non-main
&gt; threads than we originally thought. Maybe we should just give up and make
&gt; SecurityOrigin::create() safe to call from a background thread? What do you
&gt; guys think?

Make SecurityOrigin thread-safe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410310</commentid>
    <comment_count>21</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-03-29 10:41:40 -0700</bug_when>
    <thetext>(In reply to Daniel Bates from comment #20)
&gt; (In reply to Chris Dumez from comment #12)
&gt; &gt; (In reply to Daniel Bates from comment #11)
&gt; &gt; &gt; (In reply to Chris Dumez from comment #10)
&gt; &gt; &gt; &gt; (In reply to Daniel Bates from comment #9)
&gt; &gt; &gt; &gt; &gt; (In reply to youenn fablet from comment #8)
&gt; &gt; &gt; &gt; &gt; &gt; (In reply to Daniel Bates from comment #7)
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Comment on attachment 336641 [details]
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Patch
&gt; &gt; &gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; &gt; &gt; This patch is not right. SecurityOriginData::toString() is not equivalent to
&gt; &gt; &gt; &gt; &gt; &gt; &gt; SecurityOrigin::toString(). We need to stop and think before transitioning
&gt; &gt; &gt; &gt; &gt; &gt; &gt; any  any more WebCore code to SecurityOriginData. It is not safe to do so.
&gt; &gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; &gt; In that particular case, the URL is ws or wss, so I think this patch is
&gt; &gt; &gt; &gt; &gt; &gt; correct as per https://url.spec.whatwg.org/#concept-url-origin.
&gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; This is not the correct section of the spec. to reference.
&gt; &gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; &gt; Take m_url to be the parsed URL corresponding to ws://example.com. Let D be
&gt; &gt; &gt; &gt; &gt; the result of SecurityOriginData::fromURL(m_url) and S be the result of
&gt; &gt; &gt; &gt; &gt; SecurityOrigin::create(m_url). Then D.toString() = &quot;ws://example.com:0&quot; !=
&gt; &gt; &gt; &gt; &gt; &quot;ws://example.com&quot; = S.toString().
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; Where is &quot;ws://example.com:0&quot; coming from? D.toString() would return
&gt; &gt; &gt; &gt; &quot;ws://example.com&quot; (as of last week end).
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; 
&gt; &gt; &gt; Oops, I was looking at an old revision. I see that
&gt; &gt; &gt; &lt;https://trac.webkit.org/changeset/229954/&gt; fixed up
&gt; &gt; &gt; SecurityOriginData::toString(). Regardless, I do not like the direction of
&gt; &gt; &gt; where we are going with SecurityOriginData. Both SecurityOrigin::toString()
&gt; &gt; &gt; and SecurityOriginData::toString() are implementing some subset of the
&gt; &gt; &gt; origin serialization algorithm.
&gt; &gt; 
&gt; &gt; What is your alternative proposal here?
&gt; &gt; 
&gt; &gt; Note that there are more usage of SecurityOrigin::create() on non-main
&gt; &gt; threads than we originally thought. Maybe we should just give up and make
&gt; &gt; SecurityOrigin::create() safe to call from a background thread? What do you
&gt; &gt; guys think?
&gt; 
&gt; Make SecurityOrigin thread-safe.

Ok, then I think we are now all in agreement. Let&apos;s do this. It will be easier and less error-prone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1412088</commentid>
    <comment_count>22</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-04-05 10:32:15 -0700</bug_when>
    <thetext>Reverted r230042 for reason:

It is no longer needed now that it is safe to construct a SecurityOrigin from an on-main thread

Committed r230305: &lt;https://trac.webkit.org/changeset/230305&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1412089</commentid>
    <comment_count>23</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-04-05 10:32:33 -0700</bug_when>
    <thetext>No longer needed.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>336637</attachid>
            <date>2018-03-27 19:35:36 -0700</date>
            <delta_ts>2018-03-27 20:34:52 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-184068-20180327193535.patch</filename>
            <type>text/plain</type>
            <size>1764</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMwMDE4CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggMDMxNTNlY2E5NGEyNjQz
OGNlYzA2NTE5OTBjMmU1Y2Q0MWVmNjJjOS4uMTA5NjAwZDU3MWI3NTdkNzU1Yjc3MDc3YjhjN2Uw
M2UxMzgyOGZlYiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE3IEBACisyMDE4LTAzLTI3ICBDaHJp
cyBEdW1leiAgPGNkdW1lekBhcHBsZS5jb20+CisKKyAgICAgICAgV2ViU29ja2V0OjpkaWRSZWNl
aXZlTWVzc2FnZSgpIG1heSBjb25zdHJ1Y3QgYSBTZWN1cml0eU9yaWdpbiBvYmplY3Qgb24gYSBu
b24tbWFpbiB0aHJlYWQKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcu
Y2dpP2lkPTE4NDA2OAorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisg
ICAgICAgIFdlYlNvY2tldDo6ZGlkUmVjZWl2ZU1lc3NhZ2UoKSBtYXkgY29uc3RydWN0IGEgU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BAIC01NzIsNyArNTcyLDcg
QEAgdm9pZCBXZWJTb2NrZXQ6OmRpZFJlY2VpdmVNZXNzYWdlKGNvbnN0IFN0cmluZyYgbXNnKQog
ICAgIGlmIChtX3N0YXRlICE9IE9QRU4pCiAgICAgICAgIHJldHVybjsKICAgICBBU1NFUlQoc2Ny
aXB0RXhlY3V0aW9uQ29udGV4dCgpKTsKLSAgICBkaXNwYXRjaEV2ZW50KE1lc3NhZ2VFdmVudDo6
Y3JlYXRlKG1zZywgU2VjdXJpdHlPcmlnaW46OmNyZWF0ZShtX3VybCktPnRvU3RyaW5nKCkpKTsK
KyAgICBkaXNwYXRjaEV2ZW50KE1lc3NhZ2VFdmVudDo6Y3JlYXRlKG1zZywgU2VjdXJpdHlPcmln
aW5EYXRhOjpmcm9tVVJMKG1fdXJsKS0+dG9TdHJpbmcoKSkpOwogfQogCiB2b2lkIFdlYlNvY2tl
dDo6ZGlkUmVjZWl2ZUJpbmFyeURhdGEoVmVjdG9yPHVpbnQ4X3Q+JiYgYmluYXJ5RGF0YSkK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>336641</attachid>
            <date>2018-03-27 20:34:53 -0700</date>
            <delta_ts>2018-03-28 13:17:09 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-184068-20180327203453.patch</filename>
            <type>text/plain</type>
            <size>1763</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMwMDE4CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggMDMxNTNlY2E5NGEyNjQz
OGNlYzA2NTE5OTBjMmU1Y2Q0MWVmNjJjOS4uMTA5NjAwZDU3MWI3NTdkNzU1Yjc3MDc3YjhjN2Uw
M2UxMzgyOGZlYiAxMDA2NDQKLS0tIGEvU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