Changeset 206168 in webkit
- Timestamp:
- Sep 20, 2016 1:11:54 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r206165 r206168 1 2016-09-20 Alex Christensen <achristensen@webkit.org> 2 3 Make URLSearchParams spec-compliant 4 https://bugs.webkit.org/show_bug.cgi?id=162247 5 6 Reviewed by Chris Dumez and Sam Weinig. 7 8 * web-platform-tests/url/url-constructor-expected.txt: 9 1 10 2016-09-20 Alex Christensen <achristensen@webkit.org> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt
r206165 r206168 1 1 2 2 PASS URL.searchParams getter 3 FAIL URL.searchParams updating, clearing assert_equals: expected "" but got "a=b" 3 PASS URL.searchParams updating, clearing 4 4 PASS URL.searchParams setter, invalid values 5 FAIL URL.searchParams and URL.search setters, update propagation assert_equals: expected "e=f&g=h" but got "a=b&c=d" 5 PASS URL.searchParams and URL.search setters, update propagation 6 6 PASS Loading data… 7 7 PASS Parsing: <http://example . … … 351 351 g> against <about:blank> 352 352 PASS Parsing: <?a=b&c=d> against <http://example.org/foo/bar> 353 FAIL Parsing: <??a=b&c=d> against <http://example.org/foo/bar> assert_equals: searchParams expected "%3Fa=b&c=d" but got "a=b&c=d" 353 PASS Parsing: <??a=b&c=d> against <http://example.org/foo/bar> 354 354 PASS Parsing: <http:> against <http://example.org/foo/bar> 355 355 FAIL Parsing: <http:> against <https://example.org/foo/bar> assert_throws: function "function () { -
trunk/Source/WebCore/ChangeLog
r206167 r206168 1 2016-09-20 Alex Christensen <achristensen@webkit.org> 2 3 Make URLSearchParams spec-compliant 4 https://bugs.webkit.org/show_bug.cgi?id=162247 5 6 Reviewed by Chris Dumez and Sam Weinig. 7 8 Covered by newly-passing web platform tests. 9 10 * html/DOMURL.cpp: 11 (WebCore::DOMURL::~DOMURL): 12 (WebCore::DOMURL::setHref): 13 (WebCore::DOMURL::setQuery): 14 Update any associated URLSearchParams object when the query could change. 15 (WebCore::DOMURL::searchParams): 16 The lifetime of the URLSearchParams was wrong. We were creating a new URLSearchParams each time 17 URL.searchParams was called, and we should have been creating one the first time and returning the 18 same instance for subsequent calls. This means the DOMURL must own the URLSearchParams if it is associated, 19 but if it is not associated, then a URLSearchParams can live on its own. 20 * html/DOMURL.h: 21 * html/URLSearchParams.h: 22 (WebCore::URLSearchParams::URLDestroyed): 23 (WebCore::URLSearchParams::setContents): 24 1 25 2016-09-20 Antti Koivisto <antti@apple.com> 2 26 -
trunk/Source/WebCore/html/DOMURL.cpp
r205893 r206168 79 79 } 80 80 81 DOMURL::~DOMURL() 82 { 83 if (m_searchParams) 84 m_searchParams->associatedURLDestroyed(); 85 } 86 81 87 void DOMURL::setHref(const String& url) 82 88 { 83 89 m_url = URL(m_baseURL, url); 90 if (m_searchParams) 91 m_searchParams->updateFromAssociatedURL(); 84 92 } 85 93 … … 114 122 } 115 123 116 Ref<URLSearchParams>DOMURL::searchParams()124 URLSearchParams& DOMURL::searchParams() 117 125 { 118 return URLSearchParams::create(m_url.query(), this); 126 if (!m_searchParams) 127 m_searchParams = URLSearchParams::create(search(), this); 128 return *m_searchParams; 119 129 } 120 130 -
trunk/Source/WebCore/html/DOMURL.h
r205893 r206168 46 46 static Ref<DOMURL> create(const String& url, const DOMURL& base, ExceptionCode&); 47 47 static Ref<DOMURL> create(const String& url, ExceptionCode&); 48 ~DOMURL(); 48 49 49 50 URL href() const { return m_url; } … … 52 53 void setQuery(const String&); 53 54 54 Ref<URLSearchParams>searchParams();55 URLSearchParams& searchParams(); 55 56 56 57 static String createObjectURL(ScriptExecutionContext&, Blob*); … … 58 59 59 60 static String createPublicURL(ScriptExecutionContext&, URLRegistrable*); 60 61 61 private: 62 62 DOMURL(const String& url, const String& base, ExceptionCode&); … … 66 66 URL m_baseURL; 67 67 URL m_url; 68 RefPtr<URLSearchParams> m_searchParams; 68 69 }; 69 70 -
trunk/Source/WebCore/html/URLSearchParams.cpp
r205893 r206168 118 118 } 119 119 120 void URLSearchParams::updateFromAssociatedURL() 121 { 122 ASSERT(m_associatedURL); 123 String search = m_associatedURL->search(); 124 m_pairs = search.startsWith('?') ? URLParser::parseURLEncodedForm(StringView(search).substring(1)) : URLParser::parseURLEncodedForm(search); 120 125 } 126 127 } -
trunk/Source/WebCore/html/URLSearchParams.h
r205893 r206168 36 36 static Ref<URLSearchParams> create(const Vector<std::pair<String, String>>& pairs) { return adoptRef(*new URLSearchParams(pairs)); } 37 37 38 void associatedURLDestroyed() { m_associatedURL = nullptr; } 38 39 void append(const String& name, const String& value); 39 40 void remove(const String& name); … … 44 45 String toString(); 45 46 operator const Vector<std::pair<String, String>>&() { return m_pairs; } 47 void updateFromAssociatedURL(); 46 48 47 49 private: … … 50 52 void updateURL(); 51 53 52 RefPtr<DOMURL>m_associatedURL;54 DOMURL* m_associatedURL; 53 55 Vector<std::pair<String, String>> m_pairs; 54 56 };
Note: See TracChangeset
for help on using the changeset viewer.