Changeset 264599 in webkit


Ignore:
Timestamp:
Jul 20, 2020, 6:51:14 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

LayoutTests/imported/w3c:
Setting URL.hash to '#' should preserve '#'
https://bugs.webkit.org/show_bug.cgi?id=214318

Patch by Rob Buis <rbuis@igalia.com> on 2020-07-20
Reviewed by Youenn Fablet.

Update improved test expectation.

  • web-platform-tests/url/url-setters-expected.txt:

Source/WebCore:
Setting URL.hash to '#' should set empty fragment
https://bugs.webkit.org/show_bug.cgi?id=214318

Patch by Rob Buis <rbuis@igalia.com> on 2020-07-20
Reviewed by Youenn Fablet.

Setting URL.hash to '#' should set empty fragment
identifier [1], unlike setting it to the empty string
which drops the fragment identifier.

Behavior matches Chrome and Firefox.

[1] https://html.spec.whatwg.org/#dom-hyperlink-hash

Test: imported/w3c/web-platform-tests/url/url-setters.html

  • html/URLDecomposition.cpp:

(WebCore::URLDecomposition::setHash):

LayoutTests:
Setting URL.hash to '#' should preserve '#'
https://bugs.webkit.org/show_bug.cgi?id=214318

Patch by Rob Buis <rbuis@igalia.com> on 2020-07-20
Reviewed by Youenn Fablet.

Update test expectations to new behavior.

  • fast/dom/DOMURL/set-href-attribute-hash-expected.txt:
  • fast/dom/DOMURL/set-href-attribute-hash.html:
  • fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt:
  • fast/dom/HTMLAnchorElement/set-href-attribute-hash.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r264596 r264599  
     12020-07-20  Rob Buis  <rbuis@igalia.com>
     2
     3        Setting URL.hash to '#' should preserve '#'
     4        https://bugs.webkit.org/show_bug.cgi?id=214318
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Update test expectations to new behavior.
     9
     10        * fast/dom/DOMURL/set-href-attribute-hash-expected.txt:
     11        * fast/dom/DOMURL/set-href-attribute-hash.html:
     12        * fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt:
     13        * fast/dom/HTMLAnchorElement/set-href-attribute-hash.html:
     14
    1152020-07-20  Philippe Normand  <pnormand@igalia.com>
    216
  • trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash-expected.txt

    r208096 r264599  
    2222PASS a.href is 'file:///some%20path#hash value'
    2323Set hash to '#'
    24 PASS a.href is 'http://mydomain.com/'
     24PASS a.href is 'http://mydomain.com/#'
    2525Add hash to non-standard protocol
    2626PASS a.href is 'foo:bar#hash'
  • trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash.html

    r208096 r264599  
    6363a.href = "http://mydomain.com#middle";
    6464a.hash = "#";
    65 shouldBe("a.href", "'http://mydomain.com/'");
     65shouldBe("a.href", "'http://mydomain.com/#'");
    6666
    6767// Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should.
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt

    r207162 r264599  
    2121PASS a.href is 'file:///some%20path#hash value'
    2222Set hash to '#'
    23 PASS a.href is 'http://mydomain.com/'
     23PASS a.href is 'http://mydomain.com/#'
    2424Add hash to non-standard protocol
    2525PASS a.href is 'foo:bar#hash'
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash.html

    r217390 r264599  
    6060a.href = "http://mydomain.com#middle";
    6161a.hash = "#";
    62 shouldBe("a.href", "'http://mydomain.com/'");
     62shouldBe("a.href", "'http://mydomain.com/#'");
    6363
    6464// Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should.
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r264573 r264599  
     12020-07-20  Rob Buis  <rbuis@igalia.com>
     2
     3        Setting URL.hash to '#' should preserve '#'
     4        https://bugs.webkit.org/show_bug.cgi?id=214318
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Update improved test expectation.
     9
     10        * web-platform-tests/url/url-setters-expected.txt:
     11
    1122020-07-18  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt

    r264516 r264599  
    583583PASS <a>: Setting <https://example.net?lang=en-US#nav>.hash = '#main'
    584584PASS <area>: Setting <https://example.net?lang=en-US#nav>.hash = '#main'
    585 FAIL URL: Setting <https://example.net?lang=en-US#nav>.hash = '#' assert_equals: expected "https://example.net/?lang=en-US#" but got "https://example.net/?lang=en-US"
    586 FAIL <a>: Setting <https://example.net?lang=en-US#nav>.hash = '#' assert_equals: expected "https://example.net/?lang=en-US#" but got "https://example.net/?lang=en-US"
    587 FAIL <area>: Setting <https://example.net?lang=en-US#nav>.hash = '#' assert_equals: expected "https://example.net/?lang=en-US#" but got "https://example.net/?lang=en-US"
     585PASS URL: Setting <https://example.net?lang=en-US#nav>.hash = '#'
     586PASS <a>: Setting <https://example.net?lang=en-US#nav>.hash = '#'
     587PASS <area>: Setting <https://example.net?lang=en-US#nav>.hash = '#'
    588588PASS URL: Setting <https://example.net?lang=en-US#nav>.hash = ''
    589589PASS <a>: Setting <https://example.net?lang=en-US#nav>.hash = ''
  • trunk/Source/WebCore/ChangeLog

    r264596 r264599  
     12020-07-20  Rob Buis  <rbuis@igalia.com>
     2
     3        Setting URL.hash to '#' should set empty fragment
     4        https://bugs.webkit.org/show_bug.cgi?id=214318
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Setting URL.hash to '#' should set empty fragment
     9        identifier [1], unlike setting it to the empty string
     10        which drops the fragment identifier.
     11
     12        Behavior matches Chrome and Firefox.
     13
     14        [1] https://html.spec.whatwg.org/#dom-hyperlink-hash
     15
     16        Test: imported/w3c/web-platform-tests/url/url-setters.html
     17
     18        * html/URLDecomposition.cpp:
     19        (WebCore::URLDecomposition::setHash):
     20
    1212020-07-20  Philippe Normand  <pnormand@igalia.com>
    222
  • trunk/Source/WebCore/html/URLDecomposition.cpp

    r264516 r264599  
    240240{
    241241    auto fullURL = this->fullURL();
    242     auto newFragment = value.startsWith('#') ? StringView(value).substring(1) : StringView(value);
    243     if (newFragment.isEmpty())
     242    if (value.isEmpty())
    244243        fullURL.removeFragmentIdentifier();
    245     else
     244    else {
     245        auto newFragment = value.startsWith('#') ? StringView(value).substring(1) : StringView(value);
    246246        fullURL.setFragmentIdentifier(newFragment);
    247     setFullURL(fullURL);
    248 }
    249 
    250 }
     247    }
     248    setFullURL(fullURL);
     249}
     250
     251}
Note: See TracChangeset for help on using the changeset viewer.