<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206162] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206162">206162</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2016-09-20 11:46:26 -0700 (Tue, 20 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Align URLParser with web platform tests when parsing non-special relative URLs ending in AuthorityOrHost state
https://bugs.webkit.org/show_bug.cgi?id=162251

Reviewed by Tim Horton.

Source/WebCore:

Covered by new and updated API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):
Fix parsing of non-special URLs that end after scheme:// with no authority.
We used to assume that parsing non-special schemes would never end with just scheme:// but a string can indeed end right there.
When a non-special relative URL contains just scheme:// we need the resulting URL to be valid to conform with the web platform tests.
(WebCore::URLParser::parseHostAndPort):
Renamed to reflect what the function actually does.
(WebCore::URLParser::internalValuesConsistent):
Add utility function for testing.
(WebCore::URLParser::parseHost): Deleted.
* platform/URLParser.h:

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
(TestWebKitAPI::checkRelativeURL):
(TestWebKitAPI::checkURLDifferences):
(TestWebKitAPI::checkRelativeURLDifferences):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformURLParsercpp">trunk/Source/WebCore/platform/URLParser.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformURLParserh">trunk/Source/WebCore/platform/URLParser.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreURLParsercpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206161 => 206162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-20 18:41:43 UTC (rev 206161)
+++ trunk/Source/WebCore/ChangeLog        2016-09-20 18:46:26 UTC (rev 206162)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-09-20  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Align URLParser with web platform tests when parsing non-special relative URLs ending in AuthorityOrHost state
+        https://bugs.webkit.org/show_bug.cgi?id=162251
+
+        Reviewed by Tim Horton.
+
+        Covered by new and updated API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        Fix parsing of non-special URLs that end after scheme:// with no authority.
+        We used to assume that parsing non-special schemes would never end with just scheme:// but a string can indeed end right there.
+        When a non-special relative URL contains just scheme:// we need the resulting URL to be valid to conform with the web platform tests.
+        (WebCore::URLParser::parseHostAndPort):
+        Renamed to reflect what the function actually does.
+        (WebCore::URLParser::internalValuesConsistent):
+        Add utility function for testing.
+        (WebCore::URLParser::parseHost): Deleted.
+        * platform/URLParser.h:
+
</ins><span class="cx"> 2016-09-20  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [css-grid] The 'grid' shorthand has a new syntax.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.cpp (206161 => 206162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.cpp        2016-09-20 18:41:43 UTC (rev 206161)
+++ trunk/Source/WebCore/platform/URLParser.cpp        2016-09-20 18:46:26 UTC (rev 206162)
</span><span class="lines">@@ -999,20 +999,20 @@
</span><span class="cx">                     else
</span><span class="cx">                         state = State::SpecialAuthoritySlashes;
</span><span class="cx">                 } else {
</span><del>-                    m_url.m_userStart = m_asciiBuffer.size();
-                    m_url.m_userEnd = m_url.m_userStart;
-                    m_url.m_passwordEnd = m_url.m_userStart;
-                    m_url.m_hostEnd = m_url.m_userStart;
-                    m_url.m_portEnd = m_url.m_userStart;
</del><span class="cx">                     auto maybeSlash = c;
</span><span class="cx">                     incrementIteratorSkippingTabAndNewLine&lt;serialized&gt;(maybeSlash);
</span><span class="cx">                     if (!maybeSlash.atEnd() &amp;&amp; *maybeSlash == '/') {
</span><span class="cx">                         m_asciiBuffer.append('/');
</span><del>-                        m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
</del><ins>+                        m_url.m_userStart = m_asciiBuffer.size();
</ins><span class="cx">                         state = State::PathOrAuthority;
</span><span class="cx">                         c = maybeSlash;
</span><span class="cx">                         ASSERT(*c == '/');
</span><span class="cx">                     } else {
</span><ins>+                        m_url.m_userStart = m_asciiBuffer.size();
+                        m_url.m_userEnd = m_url.m_userStart;
+                        m_url.m_passwordEnd = m_url.m_userStart;
+                        m_url.m_hostEnd = m_url.m_userStart;
+                        m_url.m_portEnd = m_url.m_userStart;
</ins><span class="cx">                         m_url.m_pathAfterLastSlash = m_url.m_userStart;
</span><span class="cx">                         m_url.m_cannotBeABaseURL = true;
</span><span class="cx">                         state = State::CannotBeABaseURLPath;
</span><span class="lines">@@ -1076,8 +1076,16 @@
</span><span class="cx">                 state = State::AuthorityOrHost;
</span><span class="cx">                 ++c;
</span><span class="cx">                 authorityOrHostBegin = c;
</span><del>-            } else
</del><ins>+            } else {
+                ASSERT(m_asciiBuffer.last() == '/');
+                m_url.m_userStart = m_asciiBuffer.size() - 1;
+                m_url.m_userEnd = m_url.m_userStart;
+                m_url.m_passwordEnd = m_url.m_userStart;
+                m_url.m_hostEnd = m_url.m_userStart;
+                m_url.m_portEnd = m_url.m_userStart;
+                m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
</ins><span class="cx">                 state = State::Path;
</span><ins>+            }
</ins><span class="cx">             break;
</span><span class="cx">         case State::Relative:
</span><span class="cx">             LOG_STATE(&quot;Relative&quot;);
</span><span class="lines">@@ -1162,7 +1170,7 @@
</span><span class="cx">                 if (isSlash || *c == '?' || *c == '#') {
</span><span class="cx">                     m_url.m_userEnd = m_asciiBuffer.size();
</span><span class="cx">                     m_url.m_passwordEnd = m_url.m_userEnd;
</span><del>-                    if (!parseHost&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</del><ins>+                    if (!parseHostAndPort&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</ins><span class="cx">                         return failure(input, length);
</span><span class="cx">                     if (!isSlash) {
</span><span class="cx">                         m_asciiBuffer.append('/');
</span><span class="lines">@@ -1179,7 +1187,7 @@
</span><span class="cx">         case State::Host:
</span><span class="cx">             LOG_STATE(&quot;Host&quot;);
</span><span class="cx">             if (*c == '/' || *c == '?' || *c == '#') {
</span><del>-                if (!parseHost&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</del><ins>+                if (!parseHostAndPort&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</ins><span class="cx">                     return failure(input, length);
</span><span class="cx">                 state = State::Path;
</span><span class="cx">                 break;
</span><span class="lines">@@ -1309,7 +1317,7 @@
</span><span class="cx">                     state = State::Path;
</span><span class="cx">                     break;
</span><span class="cx">                 }
</span><del>-                if (!parseHost&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</del><ins>+                if (!parseHostAndPort&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</ins><span class="cx">                     return failure(input, length);
</span><span class="cx">                 
</span><span class="cx">                 if (StringView(m_asciiBuffer.data() + m_url.m_passwordEnd, m_asciiBuffer.size() - m_url.m_passwordEnd) == &quot;localhost&quot;)  {
</span><span class="lines">@@ -1433,6 +1441,11 @@
</span><span class="cx">         break;
</span><span class="cx">     case State::PathOrAuthority:
</span><span class="cx">         LOG_FINAL_STATE(&quot;PathOrAuthority&quot;);
</span><ins>+        m_url.m_userEnd = m_asciiBuffer.size();
+        m_url.m_passwordEnd = m_url.m_userEnd;
+        m_url.m_hostEnd = m_url.m_userEnd;
+        m_url.m_portEnd = m_url.m_userEnd;
+        m_url.m_pathAfterLastSlash = m_url.m_userEnd;
</ins><span class="cx">         m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
</span><span class="cx">         m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
</span><span class="cx">         m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash;
</span><span class="lines">@@ -1470,11 +1483,20 @@
</span><span class="cx">         LOG_FINAL_STATE(&quot;AuthorityOrHost&quot;);
</span><span class="cx">         m_url.m_userEnd = m_asciiBuffer.size();
</span><span class="cx">         m_url.m_passwordEnd = m_url.m_userEnd;
</span><del>-        FALLTHROUGH;
</del><ins>+        if (authorityOrHostBegin.atEnd()) {
+            m_url.m_hostEnd = m_url.m_userEnd;
+            m_url.m_portEnd = m_url.m_userEnd;
+        } else if (!parseHostAndPort&lt;serialized&gt;(authorityOrHostBegin))
+            return failure(input, length);
+        m_asciiBuffer.append('/');
+        m_url.m_pathEnd = m_url.m_portEnd + 1;
+        m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
+        m_url.m_queryEnd = m_url.m_pathEnd;
+        m_url.m_fragmentEnd = m_url.m_pathEnd;
+        break;
</ins><span class="cx">     case State::Host:
</span><del>-        if (state == State::Host)
-            LOG_FINAL_STATE(&quot;Host&quot;);
-        if (!parseHost&lt;serialized&gt;(authorityOrHostBegin))
</del><ins>+        LOG_FINAL_STATE(&quot;Host&quot;);
+        if (!parseHostAndPort&lt;serialized&gt;(authorityOrHostBegin))
</ins><span class="cx">             return failure(input, length);
</span><span class="cx">         m_asciiBuffer.append('/');
</span><span class="cx">         m_url.m_pathEnd = m_url.m_portEnd + 1;
</span><span class="lines">@@ -1528,7 +1550,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!parseHost&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</del><ins>+        if (!parseHostAndPort&lt;serialized&gt;(CodePointIterator&lt;CharacterType&gt;(authorityOrHostBegin, c)))
</ins><span class="cx">             return failure(input, length);
</span><span class="cx"> 
</span><span class="cx">         if (StringView(m_asciiBuffer.data() + m_url.m_passwordEnd, m_asciiBuffer.size() - m_url.m_passwordEnd) == &quot;localhost&quot;)  {
</span><span class="lines">@@ -1583,6 +1605,7 @@
</span><span class="cx">     }
</span><span class="cx">     m_url.m_isValid = true;
</span><span class="cx">     LOG(URLParser, &quot;Parsed URL &lt;%s&gt;&quot;, m_url.m_string.utf8().data());
</span><ins>+    ASSERT(internalValuesConsistent(m_url));
</ins><span class="cx">     return m_url;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2006,7 +2029,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;bool serialized, typename CharacterType&gt;
</span><del>-bool URLParser::parseHost(CodePointIterator&lt;CharacterType&gt; iterator)
</del><ins>+bool URLParser::parseHostAndPort(CodePointIterator&lt;CharacterType&gt; iterator)
</ins><span class="cx"> {
</span><span class="cx">     if (iterator.atEnd())
</span><span class="cx">         return false;
</span><span class="lines">@@ -2224,6 +2247,22 @@
</span><span class="cx">         &amp;&amp; a.m_fragmentEnd == b.m_fragmentEnd;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool URLParser::internalValuesConsistent(const URL&amp; url)
+{    
+    return url.m_schemeEnd &lt;= url.m_userStart
+        &amp;&amp; url.m_userStart &lt;= url.m_userEnd
+        &amp;&amp; url.m_userEnd &lt;= url.m_passwordEnd
+        &amp;&amp; url.m_passwordEnd &lt;= url.m_hostEnd
+        &amp;&amp; url.m_hostEnd &lt;= url.m_hostEnd
+        &amp;&amp; url.m_portEnd &lt;= url.m_pathAfterLastSlash
+        &amp;&amp; url.m_pathAfterLastSlash &lt;= url.m_pathEnd
+        &amp;&amp; url.m_pathEnd &lt;= url.m_queryEnd
+        &amp;&amp; url.m_queryEnd &lt;= url.m_fragmentEnd
+        &amp;&amp; (url.m_isValid ? url.m_fragmentEnd == url.m_string.length() : !url.m_fragmentEnd);
+    // FIXME: Why do we even store m_fragmentEnd?
+    // It should be able to be deduced from m_isValid and m_string.length() to save memory.
+}
+
</ins><span class="cx"> static bool urlParserEnabled = false;
</span><span class="cx"> 
</span><span class="cx"> void URLParser::setEnabled(bool enabled)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.h (206161 => 206162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.h        2016-09-20 18:41:43 UTC (rev 206161)
+++ trunk/Source/WebCore/platform/URLParser.h        2016-09-20 18:46:26 UTC (rev 206162)
</span><span class="lines">@@ -38,7 +38,9 @@
</span><span class="cx"> public:
</span><span class="cx">     WEBCORE_EXPORT URL parse(const String&amp;, const URL&amp; = { }, const TextEncoding&amp; = UTF8Encoding());
</span><span class="cx">     WEBCORE_EXPORT URL parseSerializedURL(const String&amp;);
</span><ins>+
</ins><span class="cx">     WEBCORE_EXPORT static bool allValuesEqual(const URL&amp;, const URL&amp;);
</span><ins>+    WEBCORE_EXPORT static bool internalValuesConsistent(const URL&amp;);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static bool enabled();
</span><span class="cx">     WEBCORE_EXPORT static void setEnabled(bool);
</span><span class="lines">@@ -56,7 +58,7 @@
</span><span class="cx"> 
</span><span class="cx">     template&lt;bool serialized, typename CharacterType&gt; URL parse(const CharacterType*, const unsigned length, const URL&amp;, const TextEncoding&amp;);
</span><span class="cx">     template&lt;bool serialized, typename CharacterType&gt; void parseAuthority(CodePointIterator&lt;CharacterType&gt;);
</span><del>-    template&lt;bool serialized, typename CharacterType&gt; bool parseHost(CodePointIterator&lt;CharacterType&gt;);
</del><ins>+    template&lt;bool serialized, typename CharacterType&gt; bool parseHostAndPort(CodePointIterator&lt;CharacterType&gt;);
</ins><span class="cx">     template&lt;bool serialized, typename CharacterType&gt; bool parsePort(CodePointIterator&lt;CharacterType&gt;&amp;);
</span><span class="cx">     template&lt;typename CharacterType&gt; URL failure(const CharacterType*, unsigned length);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (206161 => 206162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-09-20 18:41:43 UTC (rev 206161)
+++ trunk/Tools/ChangeLog        2016-09-20 18:46:26 UTC (rev 206162)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2016-09-20  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Align URLParser with web platform tests when parsing non-special relative URLs ending in AuthorityOrHost state
+        https://bugs.webkit.org/show_bug.cgi?id=162251
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::checkURL):
+        (TestWebKitAPI::TEST_F):
+        (TestWebKitAPI::checkRelativeURL):
+        (TestWebKitAPI::checkURLDifferences):
+        (TestWebKitAPI::checkRelativeURLDifferences):
+
+2016-09-20  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
</ins><span class="cx">         URLParser should allow '@' in user
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=162272
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206161 => 206162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2016-09-20 18:41:43 UTC (rev 206161)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2016-09-20 18:46:26 UTC (rev 206162)
</span><span class="lines">@@ -82,6 +82,8 @@
</span><span class="cx">     EXPECT_TRUE(eq(parts.string, oldURL.string()));
</span><span class="cx">     
</span><span class="cx">     EXPECT_TRUE(URLParser::allValuesEqual(url, oldURL));
</span><ins>+    EXPECT_TRUE(URLParser::internalValuesConsistent(url));
+    EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;size_t length&gt;
</span><span class="lines">@@ -201,9 +203,9 @@
</span><span class="cx">     checkURL(&quot;sc:/pa/pa&quot;, {&quot;sc&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/pa/pa&quot;, &quot;&quot;, &quot;&quot;, &quot;sc:/pa/pa&quot;});
</span><span class="cx">     checkURL(&quot;sc:/pa&quot;, {&quot;sc&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/pa&quot;, &quot;&quot;, &quot;&quot;, &quot;sc:/pa&quot;});
</span><span class="cx">     checkURL(&quot;sc:/pa/&quot;, {&quot;sc&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/pa/&quot;, &quot;&quot;, &quot;&quot;, &quot;sc:/pa/&quot;});
</span><ins>+    checkURL(&quot;notspecial:/notuser:notpassword@nothost&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/notuser:notpassword@nothost&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/notuser:notpassword@nothost&quot;});
</ins><span class="cx">     checkURL(&quot;sc://pa/&quot;, {&quot;sc&quot;, &quot;&quot;, &quot;&quot;, &quot;pa&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;sc://pa/&quot;});
</span><span class="cx">     checkURL(&quot;http://host   \a   &quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://host/&quot;});
</span><del>-    checkURL(&quot;notspecial:/&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;});
</del><span class="cx">     checkURL(&quot;notspecial:/a&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/a&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/a&quot;});
</span><span class="cx">     checkURL(&quot;notspecial:&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:&quot;});
</span><span class="cx">     checkURL(&quot;http:/a&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;a&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://a/&quot;});
</span><span class="lines">@@ -210,6 +212,8 @@
</span><span class="cx">     checkURL(&quot;http://256/&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;256&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://256/&quot;});
</span><span class="cx">     checkURL(&quot;http://256./&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;256.&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://256./&quot;});
</span><span class="cx">     checkURL(&quot;http://123.256/&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;123.256&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://123.256/&quot;});
</span><ins>+    checkURL(&quot;notspecial:/a&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/a&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/a&quot;});
+    checkURL(&quot;notspecial:&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:&quot;});
</ins><span class="cx">     // FIXME: Fix and add a test with an invalid surrogate pair at the end with a space as the second code unit.
</span><span class="cx"> 
</span><span class="cx">     // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse,
</span><span class="lines">@@ -246,6 +250,8 @@
</span><span class="cx">     EXPECT_TRUE(eq(parts.string, oldURL.string()));
</span><span class="cx"> 
</span><span class="cx">     EXPECT_TRUE(URLParser::allValuesEqual(url, oldURL));
</span><ins>+    EXPECT_TRUE(URLParser::internalValuesConsistent(url));
+    EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST_F(URLParserTest, ParseRelative)
</span><span class="lines">@@ -287,9 +293,7 @@
</span><span class="cx">     checkRelativeURL(&quot;  foo.com  &quot;, &quot;http://example.org/foo/bar&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;example.org&quot;, 0, &quot;/foo/foo.com&quot;, &quot;&quot;, &quot;&quot;, &quot;http://example.org/foo/foo.com&quot;});
</span><span class="cx">     checkRelativeURL(&quot; \a baz&quot;, &quot;http://example.org/foo/bar&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;example.org&quot;, 0, &quot;/foo/baz&quot;, &quot;&quot;, &quot;&quot;, &quot;http://example.org/foo/baz&quot;});
</span><span class="cx">     checkRelativeURL(&quot;~&quot;, &quot;http://example.org&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;example.org&quot;, 0, &quot;/~&quot;, &quot;&quot;, &quot;&quot;, &quot;http://example.org/~&quot;});
</span><del>-    checkRelativeURL(&quot;notspecial:/&quot;, &quot;about:blank&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;});
</del><span class="cx">     checkRelativeURL(&quot;notspecial:&quot;, &quot;about:blank&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:&quot;});
</span><del>-    checkRelativeURL(&quot;notspecial:/&quot;, &quot;http://host&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;});
</del><span class="cx">     checkRelativeURL(&quot;notspecial:&quot;, &quot;http://host&quot;, {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:&quot;});
</span><span class="cx">     checkRelativeURL(&quot;http:&quot;, &quot;http://host&quot;, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://host/&quot;});
</span><span class="cx">     
</span><span class="lines">@@ -324,6 +328,8 @@
</span><span class="cx">     EXPECT_TRUE(eq(partsOld.string, oldURL.string()));
</span><span class="cx">     
</span><span class="cx">     EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
</span><ins>+    EXPECT_TRUE(URLParser::internalValuesConsistent(url));
+    EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void checkRelativeURLDifferences(const String&amp; urlString, const String&amp; baseURLString, const ExpectedParts&amp; partsNew, const ExpectedParts&amp; partsOld)
</span><span class="lines">@@ -355,6 +361,8 @@
</span><span class="cx">     EXPECT_TRUE(eq(partsOld.string, oldURL.string()));
</span><span class="cx">     
</span><span class="cx">     EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
</span><ins>+    EXPECT_TRUE(URLParser::internalValuesConsistent(url));
+    EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // These are differences between the new URLParser and the old URL::parse which make URLParser more standards compliant.
</span><span class="lines">@@ -547,6 +555,20 @@
</span><span class="cx">     checkRelativeURLDifferences(&quot;https://@test@test@example:800/&quot;, &quot;http://doesnotmatter/&quot;,
</span><span class="cx">         {&quot;https&quot;, &quot;@test@test&quot;, &quot;&quot;, &quot;example&quot;, 800, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;https://%40test%40test@example:800/&quot;},
</span><span class="cx">         {&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;https://@test@test@example:800/&quot;});
</span><ins>+    checkRelativeURLDifferences(&quot;foo://&quot;, &quot;http://example.org/foo/bar&quot;,
+        {&quot;foo&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;foo:///&quot;},
+        {&quot;foo&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;//&quot;, &quot;&quot;, &quot;&quot;, &quot;foo://&quot;});
+
+    // This matches the spec and web platform tests, but not Chrome, Firefox, or URL::parse.
+    checkRelativeURLDifferences(&quot;notspecial:/&quot;, &quot;about:blank&quot;,
+        {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;},
+        {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;});
+    checkRelativeURLDifferences(&quot;notspecial:/&quot;, &quot;http://host&quot;,
+        {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;},
+        {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;});
+    checkURLDifferences(&quot;notspecial:/&quot;,
+        {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;},
+        {&quot;notspecial&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;notspecial:/&quot;});
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST_F(URLParserTest, DefaultPort)
</span></span></pre>
</div>
</div>

</body>
</html>