Changeset 279895 in webkit


Ignore:
Timestamp:
Jul 13, 2021 3:54:29 PM (3 years ago)
Author:
achristensen@apple.com
Message:

Update and fix URL WPT tests
https://bugs.webkit.org/show_bug.cgi?id=227820

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/url/failure-expected.txt:
  • web-platform-tests/url/resources/a-element-origin.js:

(runURLTests):

  • web-platform-tests/url/resources/a-element.js:

(runURLTests):

  • web-platform-tests/url/resources/setters_tests.json:
  • web-platform-tests/url/resources/urltestdata.json:
  • web-platform-tests/url/url-constructor.any-expected.txt:
  • web-platform-tests/url/url-constructor.any.js:

(bURL):

  • web-platform-tests/url/url-constructor.any.worker-expected.txt:
  • web-platform-tests/url/url-origin.any.js:

(bURL):

  • web-platform-tests/url/url-setters-a-area.window-expected.txt:
  • web-platform-tests/url/url-setters.any-expected.txt:
  • web-platform-tests/url/url-setters.any.worker-expected.txt:

Source/WTF:

There was an edge case where if we set a path to an empty string, it would add a slash. No more.

  • wtf/URL.cpp:

(WTF::URL::setPath):

Location:
trunk
Files:
1 deleted
15 edited

Legend:

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

    r279894 r279895  
     12021-07-13  Alex Christensen  <achristensen@webkit.org>
     2
     3        Update and fix URL WPT tests
     4        https://bugs.webkit.org/show_bug.cgi?id=227820
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/url/failure-expected.txt:
     9        * web-platform-tests/url/resources/a-element-origin.js:
     10        (runURLTests):
     11        * web-platform-tests/url/resources/a-element.js:
     12        (runURLTests):
     13        * web-platform-tests/url/resources/setters_tests.json:
     14        * web-platform-tests/url/resources/urltestdata.json:
     15        * web-platform-tests/url/url-constructor.any-expected.txt:
     16        * web-platform-tests/url/url-constructor.any.js:
     17        (bURL):
     18        * web-platform-tests/url/url-constructor.any.worker-expected.txt:
     19        * web-platform-tests/url/url-origin.any.js:
     20        (bURL):
     21        * web-platform-tests/url/url-setters-a-area.window-expected.txt:
     22        * web-platform-tests/url/url-setters.any-expected.txt:
     23        * web-platform-tests/url/url-setters.any.worker-expected.txt:
     24
    1252021-07-13  Chris Dumez  <cdumez@apple.com>
    226
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/failure-expected.txt

    r279646 r279895  
    1 Blocked access to external URL http://./Y:
    2 CONSOLE MESSAGE: Beacon API cannot load http://./Y: due to access control checks.
    3 Blocked access to external URL http://./y:
    4 CONSOLE MESSAGE: Beacon API cannot load http://./y: due to access control checks.
    51
    62PASS Loading data…
     
    7571PASS URL's constructor's base argument: http:@:www.example.com should throw
    7672PASS URL's href: http:@:www.example.com should throw
    77 FAIL XHR: http:@:www.example.com should throw assert_throws_dom: function "() => client.open("GET", test.input)" did not throw
    78 FAIL sendBeacon(): http:@:www.example.com should throw assert_throws_js: function "() => self.navigator.sendBeacon(test.input)" did not throw
    79 FAIL Location's href: http:@:www.example.com should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
    80 FAIL window.open(): http:@:www.example.com should throw assert_throws_dom: function "() => self.open(test.input).close()" did not throw
    8173PASS URL's constructor's base argument: http:/@:www.example.com should throw
    8274PASS URL's href: http:/@:www.example.com should throw
    83 FAIL XHR: http:/@:www.example.com should throw assert_throws_dom: function "() => client.open("GET", test.input)" did not throw
    84 FAIL sendBeacon(): http:/@:www.example.com should throw assert_throws_js: function "() => self.navigator.sendBeacon(test.input)" did not throw
    85 FAIL Location's href: http:/@:www.example.com should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
    86 FAIL window.open(): http:/@:www.example.com should throw assert_throws_dom: function "() => self.open(test.input).close()" did not throw
    8775PASS URL's constructor's base argument: http://@:www.example.com should throw
    8876PASS URL's href: http://@:www.example.com should throw
     
    405393PASS URL's constructor's base argument: \\\.\Y: should throw
    406394PASS URL's href: \\\.\Y: should throw
    407 FAIL XHR: \\\.\Y: should throw assert_throws_dom: function "() => client.open("GET", test.input)" did not throw
    408 FAIL sendBeacon(): \\\.\Y: should throw assert_throws_js: function "() => self.navigator.sendBeacon(test.input)" did not throw
    409 FAIL Location's href: \\\.\Y: should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
    410 FAIL window.open(): \\\.\Y: should throw assert_throws_dom: function "() => self.open(test.input).close()" did not throw
    411395PASS URL's constructor's base argument: \\\.\y: should throw
    412396PASS URL's href: \\\.\y: should throw
    413 FAIL XHR: \\\.\y: should throw assert_throws_dom: function "() => client.open("GET", test.input)" did not throw
    414 FAIL sendBeacon(): \\\.\y: should throw assert_throws_js: function "() => self.navigator.sendBeacon(test.input)" did not throw
    415 FAIL Location's href: \\\.\y: should throw assert_throws_js: function "() => self[0].location = test.input" did not throw
    416 FAIL window.open(): \\\.\y: should throw assert_throws_dom: function "() => self.open(test.input).close()" did not throw
    417397PASS URL's constructor's base argument: https://[0::0::0] should throw
    418398PASS URL's href: https://[0::0::0] should throw
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/a-element-origin.js

    r264197 r279895  
    1717    var expected = urltests[i]
    1818    if (typeof expected === "string" || !("origin" in expected)) continue
     19    // skip without base because you cannot unset the baseURL of a document
     20    if (expected.base === null) continue;
    1921
    2022    test(function() {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/a-element.js

    r264197 r279895  
    1717    var expected = urltests[i]
    1818    if (typeof expected === "string") continue // skip comments
     19    // skip without base because you cannot unset the baseURL of a document
     20    if (expected.base === null) continue;
    1921
    2022    test(function() {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/setters_tests.json

    r279211 r279895  
    16131613        },
    16141614        {
     1615            "comment": "Special URLs cannot have their paths erased",
     1616            "href": "file:///some/path",
     1617            "new_value": "",
     1618            "expected": {
     1619                "href": "file:///",
     1620                "pathname": "/"
     1621            }
     1622        },
     1623        {
     1624            "comment": "Non-special URLs can have their paths erased",
     1625            "href": "foo://somehost/some/path",
     1626            "new_value": "",
     1627            "expected": {
     1628                "href": "foo://somehost",
     1629                "pathname": ""
     1630            }
     1631        },
     1632        {
     1633            "comment": "Non-special URLs with an empty host can have their paths erased",
     1634            "href": "foo:///some/path",
     1635            "new_value": "",
     1636            "expected": {
     1637                "href": "foo://",
     1638                "pathname": ""
     1639            }
     1640        },
     1641        {
     1642            "comment": "Path-only URLs cannot have their paths erased",
     1643            "href": "foo:/some/path",
     1644            "new_value": "",
     1645            "expected": {
     1646                "href": "foo:/",
     1647                "pathname": "/"
     1648            }
     1649        },
     1650        {
     1651            "comment": "Path-only URLs always have an initial slash",
     1652            "href": "foo:/some/path",
     1653            "new_value": "test",
     1654            "expected": {
     1655                "href": "foo:/test",
     1656                "pathname": "/test"
     1657            }
     1658        },
     1659        {
    16151660            "href": "unix:/run/foo.socket?timeout=10",
    16161661            "new_value": "/var/log/../run/bar.socket",
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/resources/urltestdata.json

    r279211 r279895  
    33043304    "input": "http:@:www.example.com",
    33053305    "base": "about:blank",
    3306     "failure": true
     3306    "failure": true,
     3307    "inputCanBeRelative": true
    33073308  },
    33083309  {
    33093310    "input": "http:/@:www.example.com",
    33103311    "base": "about:blank",
    3311     "failure": true
     3312    "failure": true,
     3313    "inputCanBeRelative": true
    33123314  },
    33133315  {
     
    63746376    "input": "\\\\\\.\\Y:",
    63756377    "base": "about:blank",
    6376     "failure": true
     6378    "failure": true,
     6379    "inputCanBeRelative": true
    63776380  },
    63786381  "# file: drive letter cases from https://crbug.com/1078698 but lowercased",
     
    64366439    "input": "\\\\\\.\\y:",
    64376440    "base": "about:blank",
    6438     "failure": true
     6441    "failure": true,
     6442    "inputCanBeRelative": true
    64396443  },
    64406444  "# Additional file URL tests for (https://github.com/whatwg/url/issues/405)",
     
    80178021    "search": "",
    80188022    "username": ""
     8023  },
     8024  "Empty query and fragment with blank should throw an error",
     8025  {
     8026    "input": "#",
     8027    "base": null,
     8028    "failure": true
     8029  },
     8030  {
     8031    "input": "?",
     8032    "base": null,
     8033    "failure": true
    80198034  }
    80208035]
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any-expected.txt

    r279235 r279895  
    645645PASS Parsing: <abc:rootless> against <abc:path>
    646646PASS Parsing: <abc:/rooted> against <abc://host/path>
     647PASS Parsing: <#> against <null>
     648PASS Parsing: <?> against <null>
    647649
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.js

    r279211 r279895  
    22
    33function bURL(url, base) {
    4   return new URL(url, base || "about:blank")
     4  return base ? new URL(url, base) : new URL(url)
    55}
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor.any.worker-expected.txt

    r279235 r279895  
    645645PASS Parsing: <abc:rootless> against <abc:path>
    646646PASS Parsing: <abc:/rooted> against <abc://host/path>
     647PASS Parsing: <#> against <null>
     648PASS Parsing: <?> against <null>
    647649
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-origin.any.js

    r279211 r279895  
    22
    33function bURL(url, base) {
    4   return new URL(url, base || "about:blank")
     4  return base ? new URL(url, base) : new URL(url)
    55}
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt

    r279680 r279895  
    341341PASS <a>: Setting <mailto:me@example.net>.pathname = '/foo' Cannot-be-a-base don’t have a path
    342342PASS <area>: Setting <mailto:me@example.net>.pathname = '/foo' Cannot-be-a-base don’t have a path
     343PASS <a>: Setting <file:///some/path>.pathname = '' Special URLs cannot have their paths erased
     344PASS <area>: Setting <file:///some/path>.pathname = '' Special URLs cannot have their paths erased
     345PASS <a>: Setting <foo://somehost/some/path>.pathname = '' Non-special URLs can have their paths erased
     346PASS <area>: Setting <foo://somehost/some/path>.pathname = '' Non-special URLs can have their paths erased
     347PASS <a>: Setting <foo:///some/path>.pathname = '' Non-special URLs with an empty host can have their paths erased
     348PASS <area>: Setting <foo:///some/path>.pathname = '' Non-special URLs with an empty host can have their paths erased
     349PASS <a>: Setting <foo:/some/path>.pathname = '' Path-only URLs cannot have their paths erased
     350PASS <area>: Setting <foo:/some/path>.pathname = '' Path-only URLs cannot have their paths erased
     351PASS <a>: Setting <foo:/some/path>.pathname = 'test' Path-only URLs always have an initial slash
     352PASS <area>: Setting <foo:/some/path>.pathname = 'test' Path-only URLs always have an initial slash
    343353PASS <a>: Setting <unix:/run/foo.socket?timeout=10>.pathname = '/var/log/../run/bar.socket'
    344354PASS <area>: Setting <unix:/run/foo.socket?timeout=10>.pathname = '/var/log/../run/bar.socket'
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt

    r279680 r279895  
    171171PASS URL: Setting <javascript://x/>.port = '12'
    172172PASS URL: Setting <mailto:me@example.net>.pathname = '/foo' Cannot-be-a-base don’t have a path
     173PASS URL: Setting <file:///some/path>.pathname = '' Special URLs cannot have their paths erased
     174PASS URL: Setting <foo://somehost/some/path>.pathname = '' Non-special URLs can have their paths erased
     175PASS URL: Setting <foo:///some/path>.pathname = '' Non-special URLs with an empty host can have their paths erased
     176PASS URL: Setting <foo:/some/path>.pathname = '' Path-only URLs cannot have their paths erased
     177PASS URL: Setting <foo:/some/path>.pathname = 'test' Path-only URLs always have an initial slash
    173178PASS URL: Setting <unix:/run/foo.socket?timeout=10>.pathname = '/var/log/../run/bar.socket'
    174179PASS URL: Setting <https://example.net#nav>.pathname = 'home'
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt

    r279680 r279895  
    171171PASS URL: Setting <javascript://x/>.port = '12'
    172172PASS URL: Setting <mailto:me@example.net>.pathname = '/foo' Cannot-be-a-base don’t have a path
     173PASS URL: Setting <file:///some/path>.pathname = '' Special URLs cannot have their paths erased
     174PASS URL: Setting <foo://somehost/some/path>.pathname = '' Non-special URLs can have their paths erased
     175PASS URL: Setting <foo:///some/path>.pathname = '' Non-special URLs with an empty host can have their paths erased
     176PASS URL: Setting <foo:/some/path>.pathname = '' Path-only URLs cannot have their paths erased
     177PASS URL: Setting <foo:/some/path>.pathname = 'test' Path-only URLs always have an initial slash
    173178PASS URL: Setting <unix:/run/foo.socket?timeout=10>.pathname = '/var/log/../run/bar.socket'
    174179PASS URL: Setting <https://example.net#nav>.pathname = 'home'
  • trunk/Source/WTF/ChangeLog

    r279892 r279895  
     12021-07-13  Alex Christensen  <achristensen@webkit.org>
     2
     3        Update and fix URL WPT tests
     4        https://bugs.webkit.org/show_bug.cgi?id=227820
     5
     6        Reviewed by Chris Dumez.
     7
     8        There was an edge case where if we set a path to an empty string, it would add a slash.  No more.
     9
     10        * wtf/URL.cpp:
     11        (WTF::URL::setPath):
     12
    1132021-07-13  Michael Catanzaro  <mcatanzaro@gnome.org>
    214
  • trunk/Source/WTF/wtf/URL.cpp

    r279760 r279895  
    683683    parse(makeString(
    684684        StringView(m_string).left(pathStart()),
    685         path.startsWith('/') || (path.startsWith('\\') && (hasSpecialScheme() || protocolIs("file"))) ? "" : "/",
     685        path.startsWith('/') || (path.startsWith('\\') && (hasSpecialScheme() || protocolIs("file"))) || (!hasSpecialScheme() && path.isEmpty() && m_schemeEnd + 1 < pathStart()) ? "" : "/",
    686686        !hasSpecialScheme() && host().isEmpty() && path.startsWith("//") && path.length() > 2 ? "/." : "",
    687687        escapePathWithoutCopying(path),
Note: See TracChangeset for help on using the changeset viewer.