Diff
Modified: trunk/Source/WebCore/ChangeLog (222092 => 222093)
--- trunk/Source/WebCore/ChangeLog 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Source/WebCore/ChangeLog 2017-09-15 16:51:17 UTC (rev 222093)
@@ -1,3 +1,18 @@
+2017-09-15 Youenn Fablet <[email protected]>
+
+ Add an URL method to remove both query string and fragment identifier
+ https://bugs.webkit.org/show_bug.cgi?id=176911
+
+ Reviewed by Alex Christensen.
+
+ Covered by existing tests and new API tests.
+
+ * Modules/cache/DOMCache.cpp:
+ (WebCore::DOMCache::retrieveRecords): Using new helper method.
+ * platform/URL.cpp:
+ (WebCore::URL::removeQueryAndFragmentIdentifier):
+ * platform/URL.h:
+
2017-09-15 Andy Estes <[email protected]>
[Cocoa] Upstream MediaRemote and VideoToolbox WebKitSystemInterface functions
Modified: trunk/Source/WebCore/Modules/cache/DOMCache.cpp (222092 => 222093)
--- trunk/Source/WebCore/Modules/cache/DOMCache.cpp 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Source/WebCore/Modules/cache/DOMCache.cpp 2017-09-15 16:51:17 UTC (rev 222093)
@@ -423,9 +423,7 @@
setPendingActivity(this);
URL retrieveURL = url;
- if (retrieveURL.hasQuery())
- retrieveURL.setQuery({ });
- retrieveURL.removeFragmentIdentifier();
+ retrieveURL.removeQueryAndFragmentIdentifier();
m_connection->retrieveRecords(m_identifier, retrieveURL, [this, callback = WTFMove(callback)](RecordsOrError&& result) {
if (!m_isStopped) {
Modified: trunk/Source/WebCore/platform/URL.cpp (222092 => 222093)
--- trunk/Source/WebCore/platform/URL.cpp 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Source/WebCore/platform/URL.cpp 2017-09-15 16:51:17 UTC (rev 222093)
@@ -870,7 +870,16 @@
if (m_isValid && m_string.length() > m_queryEnd)
m_string = m_string.left(m_queryEnd);
}
-
+
+void URL::removeQueryAndFragmentIdentifier()
+{
+ if (!m_isValid)
+ return;
+
+ m_string = m_string.left(m_pathEnd);
+ m_queryEnd = m_pathEnd;
+}
+
void URL::setQuery(const String& query)
{
if (!m_isValid)
Modified: trunk/Source/WebCore/platform/URL.h (222092 => 222093)
--- trunk/Source/WebCore/platform/URL.h 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Source/WebCore/platform/URL.h 2017-09-15 16:51:17 UTC (rev 222093)
@@ -163,9 +163,11 @@
// URL (with nothing after it). To clear the query, pass a null string.
WEBCORE_EXPORT void setQuery(const String&);
- void setFragmentIdentifier(StringView);
+ WEBCORE_EXPORT void setFragmentIdentifier(StringView);
WEBCORE_EXPORT void removeFragmentIdentifier();
+ WEBCORE_EXPORT void removeQueryAndFragmentIdentifier();
+
WEBCORE_EXPORT friend bool equalIgnoringFragmentIdentifier(const URL&, const URL&);
WEBCORE_EXPORT friend bool protocolHostAndPortAreEqual(const URL&, const URL&);
Modified: trunk/Source/WebKit/ChangeLog (222092 => 222093)
--- trunk/Source/WebKit/ChangeLog 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Source/WebKit/ChangeLog 2017-09-15 16:51:17 UTC (rev 222093)
@@ -1,3 +1,13 @@
+2017-09-15 Youenn Fablet <[email protected]>
+
+ Add an URL method to remove both query string and fragment identifier
+ https://bugs.webkit.org/show_bug.cgi?id=176911
+
+ Reviewed by Alex Christensen.
+
+ * NetworkProcess/cache/CacheStorageEngineCache.cpp:
+ (WebKit::CacheStorage::computeKeyURL):
+
2017-09-15 Andy Estes <[email protected]>
[Cocoa] Upstream MediaRemote and VideoToolbox WebKitSystemInterface functions
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp (222092 => 222093)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp 2017-09-15 16:51:17 UTC (rev 222093)
@@ -56,11 +56,9 @@
static inline String computeKeyURL(const URL& url)
{
- URL keyURL = url;
- if (keyURL.hasQuery())
- keyURL.setQuery({ });
- keyURL.removeFragmentIdentifier();
- return keyURL;
+ URL keyURL { url };
+ keyURL.removeQueryAndFragmentIdentifier();
+ return keyURL.string();
}
static inline Vector<uint64_t> queryCache(const Vector<RecordInformation>* records, const ResourceRequest& request, const CacheQueryOptions& options)
Modified: trunk/Tools/ChangeLog (222092 => 222093)
--- trunk/Tools/ChangeLog 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Tools/ChangeLog 2017-09-15 16:51:17 UTC (rev 222093)
@@ -1,3 +1,16 @@
+2017-09-15 Youenn Fablet <[email protected]>
+
+ Add an URL method to remove both query string and fragment identifier
+ https://bugs.webkit.org/show_bug.cgi?id=176911
+
+ Reviewed by Alex Christensen.
+
+ Adding unit test for new URL method as well as modified setQuery and setFragmentIdentifier.
+
+ * TestWebKitAPI/Tests/WebCore/URL.cpp:
+ (TestWebKitAPI::createURL):
+ (TestWebKitAPI::TEST_F):
+
2017-09-14 Yousuke Kimoto <[email protected]>
[WinCairo] Add an option to build WebKitLegacy and WebKit
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp (222092 => 222093)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp 2017-09-15 16:34:27 UTC (rev 222092)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp 2017-09-15 16:51:17 UTC (rev 222093)
@@ -71,13 +71,14 @@
EXPECT_EQ(String("fragment"), kurl.fragmentIdentifier());
}
+static URL createURL(const char* urlAsString)
+{
+ URLParser parser(urlAsString);
+ return parser.result();
+};
+
TEST_F(URLTest, URLProtocolHostAndPort)
{
- auto createURL = [](const char* urlAsString) {
- URLParser parser(urlAsString);
- return parser.result();
- };
-
auto url = ""
EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
@@ -127,4 +128,89 @@
EXPECT_EQ(threeApples.impl(), url.string().impl());
}
+TEST_F(URLTest, URLSetQuery)
+{
+ URL url = ""
+ URL url1 = createURL("http://www.webkit.org/");
+ URL url2 = createURL("http://www.webkit.org/?");
+ URL url3 = createURL("http://www.webkit.org/?test");
+ URL url4 = createURL("http://www.webkit.org/?test1");
+
+ url1.setQuery("test");
+ url2.setQuery("test");
+ url3.setQuery("test");
+ url4.setQuery("test");
+
+ EXPECT_EQ(url.string(), url1.string());
+ EXPECT_EQ(url.string(), url2.string());
+ EXPECT_EQ(url.string(), url3.string());
+ EXPECT_EQ(url.string(), url4.string());
+
+ URL urlWithFragmentIdentifier = createURL("http://www.webkit.org/?test%C3%83%C2%A5#newFragment");
+ URL urlWithFragmentIdentifier1 = createURL("http://www.webkit.org/#newFragment");
+ URL urlWithFragmentIdentifier2 = createURL("http://www.webkit.org/?#newFragment");
+ URL urlWithFragmentIdentifier3 = createURL("http://www.webkit.org/?test1#newFragment");
+
+ urlWithFragmentIdentifier1.setQuery("test\xc3\xa5");
+ urlWithFragmentIdentifier2.setQuery("test\xc3\xa5");
+ urlWithFragmentIdentifier3.setQuery("test\xc3\xa5");
+
+ EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier1.string());
+ EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier2.string());
+ EXPECT_EQ(urlWithFragmentIdentifier.string(), urlWithFragmentIdentifier3.string());
+}
+
+TEST_F(URLTest, URLSetFragmentIdentifier)
+{
+ URL url = ""
+ URL url1 = createURL("http://www.webkit.org/");
+ URL url2 = createURL("http://www.webkit.org/#test2");
+ URL url3 = createURL("http://www.webkit.org/#");
+
+ url1.setFragmentIdentifier("newFragment\xc3\xa5");
+ url2.setFragmentIdentifier("newFragment\xc3\xa5");
+ url3.setFragmentIdentifier("newFragment\xc3\xa5");
+
+ EXPECT_EQ(url.string(), url1.string());
+ EXPECT_EQ(url.string(), url2.string());
+ EXPECT_EQ(url.string(), url3.string());
+
+ URL urlWithQuery = createURL("http://www.webkit.org/?test1#newFragment");
+ URL urlWithQuery1 = createURL("http://www.webkit.org/?test1");
+ URL urlWithQuery2 = createURL("http://www.webkit.org/?test1#");
+ URL urlWithQuery3 = createURL("http://www.webkit.org/?test1#test2");
+
+ urlWithQuery1.setFragmentIdentifier("newFragment");
+ urlWithQuery2.setFragmentIdentifier("newFragment");
+ urlWithQuery3.setFragmentIdentifier("newFragment");
+
+ EXPECT_EQ(urlWithQuery.string(), urlWithQuery1.string());
+ EXPECT_EQ(urlWithQuery.string(), urlWithQuery2.string());
+ EXPECT_EQ(urlWithQuery.string(), urlWithQuery3.string());
+}
+
+TEST_F(URLTest, URLRemoveQueryAndFragmentIdentifier)
+{
+ URL url = ""
+ URL url1 = createURL("http://www.webkit.org/?");
+ URL url2 = createURL("http://www.webkit.org/?test1");
+ URL url3 = createURL("http://www.webkit.org/?test1#test2");
+ URL url4 = createURL("http://www.webkit.org/#test2");
+ URL url5 = createURL("http://www.webkit.org/#");
+
+ url.removeQueryAndFragmentIdentifier();
+ url1.removeQueryAndFragmentIdentifier();
+ url2.removeQueryAndFragmentIdentifier();
+ url3.removeQueryAndFragmentIdentifier();
+ url4.removeQueryAndFragmentIdentifier();
+ url5.removeQueryAndFragmentIdentifier();
+
+ EXPECT_EQ(url.string(), url.string());
+ EXPECT_EQ(url.string(), url1.string());
+ EXPECT_EQ(url.string(), url2.string());
+ EXPECT_EQ(url.string(), url3.string());
+ EXPECT_EQ(url.string(), url4.string());
+ EXPECT_EQ(url.string(), url5.string());
+}
+
} // namespace TestWebKitAPI