Changeset 268853 in webkit


Ignore:
Timestamp:
Oct 21, 2020, 10:24:47 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Update and pass new URL web platform tests
https://bugs.webkit.org/show_bug.cgi?id=218056

Reviewed by Tim Horton.

LayoutTests/imported/w3c:

  • web-platform-tests/url/a-element-expected.txt:
  • web-platform-tests/url/a-element-xhtml-expected.txt:
  • web-platform-tests/url/resources/setters_tests.json:
  • web-platform-tests/url/resources/urltestdata.json:
  • web-platform-tests/url/url-constructor-expected.txt:
  • web-platform-tests/url/url-searchparams.any.js:
  • web-platform-tests/url/url-setters-expected.txt:

Source/WebCore:

Don't add an extra forward slash at the beginning when setting the path of a file URL
that starts with a backslash, which we turn into a forward slash when parsing file URL paths.
This conveniently involves removing duplicate code.

This matches the behavior of Chrome and the URL spec.
Covered by newly passing web platform tests.

  • html/URLDecomposition.cpp:

(WebCore::URLDecomposition::setPathname):

Source/WTF:

  • wtf/URL.cpp:

(WTF::URL::setPath):

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r268843 r268853  
     12020-10-21  Alex Christensen  <achristensen@webkit.org>
     2
     3        Update and pass new URL web platform tests
     4        https://bugs.webkit.org/show_bug.cgi?id=218056
     5
     6        Reviewed by Tim Horton.
     7
     8        * web-platform-tests/url/a-element-expected.txt:
     9        * web-platform-tests/url/a-element-xhtml-expected.txt:
     10        * web-platform-tests/url/resources/setters_tests.json:
     11        * web-platform-tests/url/resources/urltestdata.json:
     12        * web-platform-tests/url/url-constructor-expected.txt:
     13        * web-platform-tests/url/url-searchparams.any.js:
     14        * web-platform-tests/url/url-setters-expected.txt:
     15
    1162020-10-21  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt

    r268479 r268853  
    489489PASS Parsing: <////one/two> against <file:///>
    490490PASS Parsing: <file:///.//> against <file:////>
     491PASS Parsing: <file:.//p> against <about:blank>
     492PASS Parsing: <file:/.//p> against <about:blank>
    491493PASS Parsing: <http://[1:0::]> against <http://example.net/>
    492494PASS Parsing: <http://[0:1:2:3:4:5:6:7:8]> against <http://example.net/>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt

    r268479 r268853  
    489489PASS Parsing: <////one/two> against <file:///>
    490490PASS Parsing: <file:///.//> against <file:////>
     491PASS Parsing: <file:.//p> against <about:blank>
     492PASS Parsing: <file:/.//p> against <about:blank>
    491493PASS Parsing: <http://[1:0::]> against <http://example.net/>
    492494PASS Parsing: <http://[0:1:2:3:4:5:6:7:8]> against <http://example.net/>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/setters_tests.json

    r266399 r268853  
    16731673            "new_value": "\\\\",
    16741674            "expected": {
    1675                 "href": "file://monkey/",
    1676                 "pathname": "/"
     1675                "href": "file://monkey//",
     1676                "pathname": "//"
    16771677            }
    16781678        },
     
    16821682            "new_value": "//\\/",
    16831683            "expected": {
    1684                 "href": "file:///",
    1685                 "pathname": "/"
     1684                "href": "file://////",
     1685                "pathname": "////"
    16861686            }
    16871687        },
     
    16911691            "new_value": "//monkey/..//",
    16921692            "expected": {
    1693                 "href": "file:///",
    1694                 "pathname": "/"
     1693                "href": "file://///",
     1694                "pathname": "///"
    16951695            }
    16961696        },
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json

    r267964 r268853  
    60926092    "failure": true
    60936093  },
    6094   "# Additional file URL tetsts for (https://github.com/whatwg/url/issues/405)",
     6094  "# Additional file URL tests for (https://github.com/whatwg/url/issues/405)",
    60956095  {
    60966096    "input": "file://localhost//a//../..//foo",
     
    62166216    "port": "",
    62176217    "pathname": "//",
     6218    "search": "",
     6219    "hash": ""
     6220  },
     6221  "File URL tests for https://github.com/whatwg/url/issues/549",
     6222  {
     6223    "input": "file:.//p",
     6224    "base": "about:blank",
     6225    "href": "file:////p",
     6226    "protocol": "file:",
     6227    "username": "",
     6228    "password": "",
     6229    "host": "",
     6230    "hostname": "",
     6231    "port": "",
     6232    "pathname": "//p",
     6233    "search": "",
     6234    "hash": ""
     6235  },
     6236  {
     6237    "input": "file:/.//p",
     6238    "base": "about:blank",
     6239    "href": "file:////p",
     6240    "protocol": "file:",
     6241    "username": "",
     6242    "password": "",
     6243    "host": "",
     6244    "hostname": "",
     6245    "port": "",
     6246    "pathname": "//p",
    62186247    "search": "",
    62196248    "hash": ""
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt

    r268479 r268853  
    488488PASS Parsing: <////one/two> against <file:///>
    489489PASS Parsing: <file:///.//> against <file:////>
     490PASS Parsing: <file:.//p> against <about:blank>
     491PASS Parsing: <file:/.//p> against <about:blank>
    490492PASS Parsing: <http://[1:0::]> against <http://example.net/>
    491493PASS Parsing: <http://[0:1:2:3:4:5:6:7:8]> against <http://example.net/>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-searchparams.any.js

    r264197 r268853  
    88    assert_true("searchParams" in url)
    99    var searchParams = url.searchParams
    10     assert_true(url.searchParams === searchParams, 'Object identity should hold.')
     10    assert_equals(url.searchParams, searchParams, 'Object identity should hold.')
    1111  }, 'URL.searchParams getter')
    1212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt

    r268479 r268853  
    508508PASS <a>: Setting <https://example.net#nav>.pathname = '../home'
    509509PASS <area>: Setting <https://example.net#nav>.pathname = '../home'
    510 FAIL URL: Setting <http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is a segment delimiter for 'special' URLs assert_equals: expected "http://example.net/a/c?lang=fr#nav" but got "http://example.net//a/c?lang=fr#nav"
    511 FAIL <a>: Setting <http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is a segment delimiter for 'special' URLs assert_equals: expected "http://example.net/a/c?lang=fr#nav" but got "http://example.net//a/c?lang=fr#nav"
    512 FAIL <area>: Setting <http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is a segment delimiter for 'special' URLs assert_equals: expected "http://example.net/a/c?lang=fr#nav" but got "http://example.net//a/c?lang=fr#nav"
     510PASS URL: Setting <http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is a segment delimiter for 'special' URLs
     511PASS <a>: Setting <http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is a segment delimiter for 'special' URLs
     512PASS <area>: Setting <http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is a segment delimiter for 'special' URLs
    513513PASS URL: Setting <view-source+http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is *not* a segment delimiter for non-'special' URLs
    514514PASS <a>: Setting <view-source+http://example.net/home?lang=fr#nav>.pathname = '\a\%2E\b\%2e.\c' \ is *not* a segment delimiter for non-'special' URLs
     
    535535PASS <a>: Setting <sc://example.net>.pathname = '#' # needs to be encoded, non-special scheme
    536536PASS <area>: Setting <sc://example.net>.pathname = '#' # needs to be encoded, non-special scheme
    537 FAIL URL: Setting <file://monkey/>.pathname = '\\' File URLs and (back)slashes assert_equals: expected "file://monkey/" but got "file://monkey///"
    538 FAIL <a>: Setting <file://monkey/>.pathname = '\\' File URLs and (back)slashes assert_equals: expected "file://monkey/" but got "file://monkey///"
    539 FAIL <area>: Setting <file://monkey/>.pathname = '\\' File URLs and (back)slashes assert_equals: expected "file://monkey/" but got "file://monkey///"
    540 FAIL URL: Setting <file:///unicorn>.pathname = '//\/' File URLs and (back)slashes assert_equals: expected "file:///" but got "file://////"
    541 FAIL <a>: Setting <file:///unicorn>.pathname = '//\/' File URLs and (back)slashes assert_equals: expected "file:///" but got "file://////"
    542 FAIL <area>: Setting <file:///unicorn>.pathname = '//\/' File URLs and (back)slashes assert_equals: expected "file:///" but got "file://////"
    543 FAIL URL: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes assert_equals: expected "file:///" but got "file://///"
    544 FAIL <a>: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes assert_equals: expected "file:///" but got "file://///"
    545 FAIL <area>: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes assert_equals: expected "file:///" but got "file://///"
     537PASS URL: Setting <file://monkey/>.pathname = '\\' File URLs and (back)slashes
     538PASS <a>: Setting <file://monkey/>.pathname = '\\' File URLs and (back)slashes
     539PASS <area>: Setting <file://monkey/>.pathname = '\\' File URLs and (back)slashes
     540PASS URL: Setting <file:///unicorn>.pathname = '//\/' File URLs and (back)slashes
     541PASS <a>: Setting <file:///unicorn>.pathname = '//\/' File URLs and (back)slashes
     542PASS <area>: Setting <file:///unicorn>.pathname = '//\/' File URLs and (back)slashes
     543PASS URL: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes
     544PASS <a>: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes
     545PASS <area>: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes
    546546PASS URL: Setting <non-spec:/>.pathname = '/.//p' Serialize /. in path
    547547PASS <a>: Setting <non-spec:/>.pathname = '/.//p' Serialize /. in path
  • trunk/Source/WTF/ChangeLog

    r268780 r268853  
     12020-10-21  Alex Christensen  <achristensen@webkit.org>
     2
     3        Update and pass new URL web platform tests
     4        https://bugs.webkit.org/show_bug.cgi?id=218056
     5
     6        Reviewed by Tim Horton.
     7
     8        * wtf/URL.cpp:
     9        (WTF::URL::setPath):
     10
    1112020-10-20  Sihui Liu  <sihui_liu@apple.com>
    212
  • trunk/Source/WTF/wtf/URL.cpp

    r268362 r268853  
    678678    parse(makeString(
    679679        StringView(m_string).left(pathStart()),
    680         path.startsWith('/') || (hasSpecialScheme() && path.startsWith('\\')) ? "" : "/",
     680        path.startsWith('/') || (path.startsWith('\\') && (hasSpecialScheme() || protocolIs("file"))) ? "" : "/",
    681681        escapePathWithoutCopying(path),
    682682        StringView(m_string).substring(m_pathEnd)
  • trunk/Source/WebCore/ChangeLog

    r268852 r268853  
     12020-10-21  Alex Christensen  <achristensen@webkit.org>
     2
     3        Update and pass new URL web platform tests
     4        https://bugs.webkit.org/show_bug.cgi?id=218056
     5
     6        Reviewed by Tim Horton.
     7
     8        Don't add an extra forward slash at the beginning when setting the path of a file URL
     9        that starts with a backslash, which we turn into a forward slash when parsing file URL paths.
     10        This conveniently involves removing duplicate code.
     11
     12        This matches the behavior of Chrome and the URL spec.
     13        Covered by newly passing web platform tests.
     14
     15        * html/URLDecomposition.cpp:
     16        (WebCore::URLDecomposition::setPathname):
     17
    1182020-10-21  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Source/WebCore/html/URLDecomposition.cpp

    r264611 r268853  
    203203    if (fullURL.cannotBeABaseURL() || !fullURL.canSetPathname())
    204204        return;
    205     if (value.startsWith('/'))
    206         fullURL.setPath(value);
    207     else
    208         fullURL.setPath(makeString('/', value));
     205    fullURL.setPath(value);
    209206    setFullURL(fullURL);
    210207}
Note: See TracChangeset for help on using the changeset viewer.