Title: [284183] trunk
Revision
284183
Author
[email protected]
Date
2021-10-14 11:44:52 -0700 (Thu, 14 Oct 2021)

Log Message

[WKWebView _loadServiceWorkerURL] ends up lowercasing URL host
https://bugs.webkit.org/show_bug.cgi?id=231742

Reviewed by Timothy Hatcher.

Source/WebKit:

[WKWebView _loadServiceWorkerURL] ends up lowercasing URL host. While I don't think it is technically wrong
(hosts should not be case-sensitive), it can be confusing.

The reason this was happening is that I was using SecurityOriginData::fromURL(url).toString() to extract the
URL's scheme/host/port and SecurityOriginData::fromURL() lowercases the scheme and host. I am now using
URL::protocolHostAndPort() instead, which does not have this side effect and is actually more efficient.

No new tests, extended existing API test.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadServiceWorker):

Tools:

Extend test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (284182 => 284183)


--- trunk/Source/WebKit/ChangeLog	2021-10-14 18:37:42 UTC (rev 284182)
+++ trunk/Source/WebKit/ChangeLog	2021-10-14 18:44:52 UTC (rev 284183)
@@ -1,3 +1,22 @@
+2021-10-14  Chris Dumez  <[email protected]>
+
+        [WKWebView _loadServiceWorkerURL] ends up lowercasing URL host
+        https://bugs.webkit.org/show_bug.cgi?id=231742
+
+        Reviewed by Timothy Hatcher.
+
+        [WKWebView _loadServiceWorkerURL] ends up lowercasing URL host. While I don't think it is technically wrong
+        (hosts should not be case-sensitive), it can be confusing.
+
+        The reason this was happening is that I was using SecurityOriginData::fromURL(url).toString() to extract the
+        URL's scheme/host/port and SecurityOriginData::fromURL() lowercases the scheme and host. I am now using
+        URL::protocolHostAndPort() instead, which does not have this side effect and is actually more efficient.
+
+        No new tests, extended existing API test.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::loadServiceWorker):
+
 2021-10-14  Carlos Garcia Campos  <[email protected]>
 
         [GTK][WPE] Move getCurrentExecutablePath() and getCurrentExecutableName() to FileSystem

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (284182 => 284183)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-10-14 18:37:42 UTC (rev 284182)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-10-14 18:44:52 UTC (rev 284183)
@@ -10715,9 +10715,8 @@
     WEBPAGEPROXY_RELEASE_LOG(Loading, "loadServiceWorker:");
 
     m_isServiceWorkerPage = true;
-    auto securityOriginURL = SecurityOriginData::fromURL(url).toString();
     CString html = makeString("<script>navigator.serviceWorker.register('", url.string().utf8().data(), "');</script>").utf8();
-    loadData({ reinterpret_cast<const uint8_t*>(html.data()), html.length() }, "text/html"_s, "UTF-8"_s, securityOriginURL);
+    loadData({ reinterpret_cast<const uint8_t*>(html.data()), html.length() }, "text/html"_s, "UTF-8"_s, url.protocolHostAndPort());
 }
 
 #if !PLATFORM(IOS_FAMILY)

Modified: trunk/Tools/ChangeLog (284182 => 284183)


--- trunk/Tools/ChangeLog	2021-10-14 18:37:42 UTC (rev 284182)
+++ trunk/Tools/ChangeLog	2021-10-14 18:44:52 UTC (rev 284183)
@@ -1,5 +1,16 @@
 2021-10-14  Chris Dumez  <[email protected]>
 
+        [WKWebView _loadServiceWorkerURL] ends up lowercasing URL host
+        https://bugs.webkit.org/show_bug.cgi?id=231742
+
+        Reviewed by Timothy Hatcher.
+
+        Extend test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+
+2021-10-14  Chris Dumez  <[email protected]>
+
         [ iOS Release ] TestWebKitAPI.WebKit.TryUsingPrewarmedProcessThatJustCrashed is a flaky timeout
         https://bugs.webkit.org/show_bug.cgi?id=229260
         <rdar://problem/82100254>

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (284182 => 284183)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm	2021-10-14 18:37:42 UTC (rev 284182)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm	2021-10-14 18:44:52 UTC (rev 284183)
@@ -2697,6 +2697,8 @@
     EXPECT_EQ(webViewConfiguration.processPool._serviceWorkerProcessCount, 1U);
     EXPECT_EQ(webViewConfiguration.processPool._webProcessCountIgnoringPrewarmedAndCached, 1U);
 
+    EXPECT_WK_STREQ([webView URL].absoluteString, @"sw-ext://ABC");
+
     // The service worker should exit if we close/deallocate the view we used to launch it.
     [webView _close];
     webView = nil;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to