Bug 162247 - Make URLSearchParams spec-compliant
Summary: Make URLSearchParams spec-compliant
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-19 17:49 PDT by Alex Christensen
Modified: 2016-09-30 10:17 PDT (History)
6 users (show)

See Also:


Attachments
Patch (7.10 KB, patch)
2016-09-19 17:55 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (1.33 MB, application/zip)
2016-09-19 18:59 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews125 for ios-simulator-elcapitan-wk2 (7.55 MB, application/zip)
2016-09-19 19:06 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews117 for mac-yosemite (1.21 MB, application/zip)
2016-09-19 19:39 PDT, Build Bot
no flags Details
Patch (7.36 KB, patch)
2016-09-19 21:27 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (7.19 KB, patch)
2016-09-19 22:05 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews104 for mac-yosemite-wk2 (1.21 MB, application/zip)
2016-09-19 22:46 PDT, Build Bot
no flags Details
Patch (7.19 KB, patch)
2016-09-19 23:02 PDT, Alex Christensen
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2016-09-19 17:49:26 PDT
Make URLSearchParams spec-compliant
Comment 1 Alex Christensen 2016-09-19 17:55:39 PDT
Created attachment 289296 [details]
Patch
Comment 2 Chris Dumez 2016-09-19 18:38:02 PDT
Comment on attachment 289296 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=289296&action=review

> Source/WebCore/html/DOMURL.cpp:94
>  void DOMURL::setQuery(const String& query)

Who is calling this method? I quickly grep'd and did not find any obvious call site.

> Source/WebCore/html/DOMURL.cpp:98
> +        m_searchParams->setContents(URLSearchParams::create(query).get());

Shouldn't this get use search() so that we get the *parsed* query from m_url?

> Source/WebCore/html/DOMURL.cpp:129
> +        m_searchParams = URLSearchParams::create("?" + m_url.query(), this);

Can we just use search() instead of "?" + m_url.query(). Seems simpler.

> Source/WebCore/html/URLSearchParams.h:47
> +    void setContents(const Vector<std::pair<String, String>>& pairs) { m_pairs = pairs; }

Instead of doing can we have an updateFromAssocatedURL() method that does the right thing? I don't like that we have to construct a URLSearchParam every time the URL gets updated.
Comment 3 Build Bot 2016-09-19 18:59:50 PDT
Comment on attachment 289296 [details]
Patch

Attachment 289296 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2109124

New failing tests:
imported/w3c/web-platform-tests/url/urlsearchparams-constructor.html
Comment 4 Build Bot 2016-09-19 18:59:55 PDT
Created attachment 289299 [details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 5 Build Bot 2016-09-19 19:06:05 PDT
Comment on attachment 289296 [details]
Patch

Attachment 289296 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2109105

New failing tests:
imported/w3c/web-platform-tests/url/urlsearchparams-constructor.html
Comment 6 Build Bot 2016-09-19 19:06:09 PDT
Created attachment 289300 [details]
Archive of layout-test-results from ews125 for ios-simulator-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 7 Build Bot 2016-09-19 19:39:48 PDT
Comment on attachment 289296 [details]
Patch

Attachment 289296 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/2109268

New failing tests:
imported/w3c/web-platform-tests/url/urlsearchparams-constructor.html
Comment 8 Build Bot 2016-09-19 19:39:52 PDT
Created attachment 289302 [details]
Archive of layout-test-results from ews117 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 9 Alex Christensen 2016-09-19 20:45:09 PDT
(In reply to comment #2)
> Comment on attachment 289296 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=289296&action=review
> 
> > Source/WebCore/html/DOMURL.cpp:94
> >  void DOMURL::setQuery(const String& query)
> 
> Who is calling this method? I quickly grep'd and did not find any obvious
> call site.
URLSearchParams::updateURL
Comment 10 Chris Dumez 2016-09-19 21:05:17 PDT
Comment on attachment 289296 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=289296&action=review

>>> Source/WebCore/html/DOMURL.cpp:94
>>>  void DOMURL::setQuery(const String& query)
>> 
>> Who is calling this method? I quickly grep'd and did not find any obvious call site.
> 
> URLSearchParams::updateURL

Well then isn't it super weird for URLSearchParams to call DOMURL::setQuery() and for DOMURL to update its URLSearchParams object back again? :)
Comment 11 Alex Christensen 2016-09-19 21:06:06 PDT
And ideally without crashing...
Comment 12 Alex Christensen 2016-09-19 21:27:52 PDT
Created attachment 289309 [details]
Patch
Comment 13 Chris Dumez 2016-09-19 21:40:19 PDT
Comment on attachment 289309 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=289309&action=review

> Source/WebCore/html/DOMURL.cpp:97
> +    if (m_searchParams)

Why is this still updating search params if it is only called by search params

> Source/WebCore/html/URLSearchParams.cpp:120
> +void URLSearchParams::updateFromAssociatedURL(const DOMURL& url)

I don't think this should take a parameter?
Comment 14 Alex Christensen 2016-09-19 21:41:30 PDT
(In reply to comment #13)
> > Source/WebCore/html/URLSearchParams.cpp:120
> > +void URLSearchParams::updateFromAssociatedURL(const DOMURL& url)
> 
> I don't think this should take a parameter?
It's nice to not have a null check and to have an assertion.
Comment 15 Chris Dumez 2016-09-19 21:49:20 PDT
(In reply to comment #14)
> (In reply to comment #13)
> > > Source/WebCore/html/URLSearchParams.cpp:120
> > > +void URLSearchParams::updateFromAssociatedURL(const DOMURL& url)
> > 
> > I don't think this should take a parameter?
> It's nice to not have a null check and to have an assertion.

You do not need a null check, just an assertion.
Comment 16 Alex Christensen 2016-09-19 22:05:09 PDT
Created attachment 289316 [details]
Patch
Comment 17 Chris Dumez 2016-09-19 22:14:17 PDT
Comment on attachment 289316 [details]
Patch

R=me
Comment 18 Build Bot 2016-09-19 22:45:58 PDT
Comment on attachment 289316 [details]
Patch

Attachment 289316 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2110154

New failing tests:
imported/w3c/web-platform-tests/url/urlsearchparams-constructor.html
Comment 19 Build Bot 2016-09-19 22:46:02 PDT
Created attachment 289325 [details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 20 Alex Christensen 2016-09-19 23:02:01 PDT
Created attachment 289326 [details]
Patch
Comment 21 Sam Weinig 2016-09-20 03:39:30 PDT
Comment on attachment 289326 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=289326&action=review

> Source/WebCore/html/DOMURL.h:61
> +    ~DOMURL();

We usually put the destructor up toward the top, below the creates().

> Source/WebCore/html/URLSearchParams.h:38
> +    void URLDestroyed() { m_associatedURL = nullptr; }

initial capital letter makes me sad. associatedURLDestroyed()? WeakPtr<>?
Comment 22 Alex Christensen 2016-09-20 13:16:12 PDT
http://trac.webkit.org/changeset/206168
Comment 23 Alex Christensen 2016-09-20 15:21:41 PDT
http://trac.webkit.org/changeset/206179