Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (287222 => 287223)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2021-12-18 15:11:29 UTC (rev 287222)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2021-12-18 17:18:25 UTC (rev 287223)
@@ -29,7 +29,6 @@
#import "HTTPServer.h"
#import "PlatformUtilities.h"
#import "ServiceWorkerPageProtocol.h"
-#import "ServiceWorkerTCPServer.h"
#import "Test.h"
#import "TestNavigationDelegate.h"
#import "TestUIDelegate.h"
@@ -438,9 +437,9 @@
static void runBasicSWTest(ShouldRunServiceWorkersOnMainThread shouldRunServiceWorkersOnMainThread)
{
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes},
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
[WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
@@ -561,13 +560,10 @@
auto messageHandler = adoptNS([[SWUserAgentMessageHandler alloc] initWithExpectedMessage:@"Message from worker: Foo Custom UserAgent"]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", userAgentSWBytes },
- }, {
- { "text/html", mainBytes },
- { "application/_javascript_", userAgentSWBytes },
- }, 2, { "Foo Custom UserAgent"_s, "Bar Custom UserAgent"_s });
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, userAgentSWBytes } },
+ });
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -599,7 +595,6 @@
TestWebKitAPI::Util::run(&done);
done = false;
- EXPECT_EQ(server.userAgentsChecked(), 3ull);
}
TEST(ServiceWorkers, RestoreFromDisk)
@@ -618,17 +613,15 @@
RetainPtr<SWMessageHandlerForRestoreFromDiskTest> messageHandler = adoptNS([[SWMessageHandlerForRestoreFromDiskTest alloc] initWithExpectedMessage:@"PASS: Registration was successful and service worker was activated"]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainRegisteringWorkerBytes },
- { "application/_javascript_", scriptBytes },
- }, {
- { "text/html", mainRegisteringAlreadyExistingWorkerBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { mainRegisteringWorkerBytes } },
+ { "/second.html", { mainRegisteringAlreadyExistingWorkerBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
@@ -644,7 +637,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -756,17 +749,15 @@
RetainPtr<SWMessageHandlerWithExpectedMessage> messageHandler = adoptNS([[SWMessageHandlerWithExpectedMessage alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainForFirstLoadInterceptTestBytes },
- { "application/_javascript_", scriptInterceptingFirstLoadBytes },
- }, {
- { "application/_javascript_", scriptInterceptingFirstLoadBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/main.html", { mainForFirstLoadInterceptTestBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptInterceptingFirstLoadBytes } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
expectedMessage = "Service Worker activated";
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&done);
@@ -783,7 +774,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
expectedMessage = "Intercepted by worker";
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -807,17 +798,15 @@
auto messageHandler = adoptNS([[SWMessageHandlerWithExpectedMessage alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainForFirstLoadInterceptTestBytes },
- { "application/_javascript_", scriptInterceptingFirstLoadBytes },
- }, {
- { "application/_javascript_", scriptInterceptingFirstLoadBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/main.html", { mainForFirstLoadInterceptTestBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptInterceptingFirstLoadBytes } },
});
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
expectedMessage = "Service Worker activated";
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&done);
@@ -835,7 +824,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
expectedMessage = "Intercepted by worker";
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -857,11 +846,9 @@
RetainPtr<SWMessageHandlerWithExpectedMessage> messageHandler = adoptNS([[SWMessageHandlerWithExpectedMessage alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainForFirstLoadInterceptTestBytes },
- { "application/_javascript_", scriptInterceptingFirstLoadBytes },
- }, {
- { "application/_javascript_", scriptInterceptingFirstLoadBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/main.html", { mainForFirstLoadInterceptTestBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptInterceptingFirstLoadBytes } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -868,7 +855,7 @@
// Register a service worker and activate it.
expectedMessage = "Service Worker activated";
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&done);
@@ -886,7 +873,7 @@
// Verify service worker is intercepting load.
expectedMessage = "Intercepted by worker";
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -901,7 +888,7 @@
navigationComplete = false;
// Verify service worker load goes well when policy delegate is ok.
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&navigationComplete);
EXPECT_FALSE(navigationFailed);
@@ -915,7 +902,7 @@
navigationComplete = false;
// Verify service worker load fails well when policy delegate is not ok.
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/main.html")];
TestWebKitAPI::Util::run(&navigationComplete);
EXPECT_TRUE(navigationFailed);
@@ -974,12 +961,12 @@
RetainPtr<RegularPageMessageHandler> regularPageMessageHandler = adoptNS([[RegularPageMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
- ServiceWorkerTCPServer server({
- { "text/html", regularPageWithConnectionBytes },
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
- { "text/html", regularPageWithConnectionBytes },
- { "text/html", regularPageWithConnectionBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { regularPageWithConnectionBytes } },
+ { "/second.html", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
+ { "/third.html", { regularPageWithConnectionBytes } },
+ { "/fourth.html", { regularPageWithConnectionBytes } },
});
RetainPtr<WKWebView> regularPageWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -987,23 +974,23 @@
RetainPtr<WKWebView> newRegularPageWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
// Test that a regular page does not trigger a service worker connection to network process if there is no registered service worker.
- [regularPageWebView loadRequest:server.request()];
+ [regularPageWebView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
// Test that a sw scheme page can register a service worker.
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
webView = nullptr;
// Now that a service worker is registered, the regular page should have a service worker connection.
- [regularPageWebView loadRequest:server.request()];
+ [regularPageWebView loadRequest:server.request("/third.html")];
TestWebKitAPI::Util::run(&done);
done = false;
regularPageWebView = nullptr;
- [newRegularPageWebView loadRequest:server.request()];
+ [newRegularPageWebView loadRequest:server.request("/fourth.html")];
TestWebKitAPI::Util::run(&done);
done = false;
newRegularPageWebView = nullptr;
@@ -1078,19 +1065,17 @@
RetainPtr<RegularPageMessageHandler> regularPageMessageHandler = adoptNS([[RegularPageMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytesWithScope },
- { "application/_javascript_", scriptBytes },
- }, {
- { "text/html", regularPageWithConnectionBytes },
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { mainBytesWithScope } },
+ { "/second.html", { regularPageWithConnectionBytes } },
+ { "/third.html", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
// Load a page that registers a service worker.
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
webView = nullptr;
@@ -1105,7 +1090,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
EXPECT_EQ(1u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -1114,7 +1099,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/third.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -1181,20 +1166,20 @@
auto messageHandler = adoptNS([[SWMessageHandlerForCacheStorage alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", writeCacheBytes },
- { "text/html", readCacheBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { writeCacheBytes } },
+ { "/second.html", { readCacheBytes } },
});
configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
}
@@ -1253,9 +1238,9 @@
auto defaultPreferences = [configuration preferences];
[defaultPreferences _setSecureContextChecksEnabled:NO];
- ServiceWorkerTCPServer server({
- { "text/html", serviceWorkerCacheAccessEphemeralSessionMainBytes },
- { "application/_javascript_", serviceWorkerCacheAccessEphemeralSessionSWBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { serviceWorkerCacheAccessEphemeralSessionMainBytes } },
+ { "/serviceworker-private-browsing-worker.js", { { { "Content-Type", "application/_javascript_" } }, serviceWorkerCacheAccessEphemeralSessionSWBytes } },
});
auto defaultWebView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -1334,21 +1319,20 @@
auto messageHandler = adoptNS([[SWMessageHandlerForCacheStorage alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", differentSessionsUseDifferentRegistrationsMainBytes },
- { "application/_javascript_", "" },
- { "text/html", defaultPageMainBytes }
- }, {
- { "text/html", privatePageMainBytes }
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { differentSessionsUseDifferentRegistrationsMainBytes } },
+ { "/empty-worker.js", { { { "Content-Type", "application/_javascript_" } }, "" } },
+ { "/second.html", { defaultPageMainBytes } },
+ { "/third.html", { privatePageMainBytes } },
});
auto defaultWebView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [defaultWebView synchronouslyLoadRequest:server.request()];
+ [defaultWebView synchronouslyLoadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
- [defaultWebView synchronouslyLoadRequest:server.request()];
+ [defaultWebView synchronouslyLoadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -1355,7 +1339,7 @@
configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
auto ephemeralWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [ephemeralWebView synchronouslyLoadRequest:server.request()];
+ [ephemeralWebView synchronouslyLoadRequest:server.request("/third.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -1393,15 +1377,15 @@
RetainPtr<DirectoryPageMessageHandler> directoryPageMessageHandler = adoptNS([[DirectoryPageMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:directoryPageMessageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
- { "text/html", regularPageGrabbingCacheStorageDirectory },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
+ { "/second.html", { regularPageGrabbingCacheStorageDirectory } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
while (![[configuration websiteDataStore] _hasRegisteredServiceWorker])
@@ -1409,7 +1393,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
EXPECT_TRUE(retrievedString.contains("/Caches/com.apple.WebKit.TestWebKitAPI/WebKit/CacheStorage"));
@@ -1436,15 +1420,15 @@
RetainPtr<DirectoryPageMessageHandler> directoryPageMessageHandler = adoptNS([[DirectoryPageMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:directoryPageMessageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
- { "text/html", regularPageGrabbingCacheStorageDirectory },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
+ { "/second.html", { regularPageGrabbingCacheStorageDirectory } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
while (![websiteDataStore _hasRegisteredServiceWorker])
@@ -1452,7 +1436,7 @@
webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
EXPECT_TRUE(retrievedString.contains("\"path\": \"/var/tmp\""));
@@ -1487,9 +1471,9 @@
RetainPtr<SWMessageHandlerWithExpectedMessage> messageHandler = adoptNS([[SWMessageHandlerWithExpectedMessage alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytesForSessionIDTest },
- { "application/_javascript_", scriptBytesForSessionIDTest },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytesForSessionIDTest } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytesForSessionIDTest } },
});
expectedMessage = "PASS: activation successful";
@@ -1551,15 +1535,13 @@
RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server1({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
- { "text/html", mainBytes },
- { "text/html", mainBytes },
+ TestWebKitAPI::HTTPServer server1({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
- ServiceWorkerTCPServer server2({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server2({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
WKProcessPool *processPool = configuration.get().processPool;
@@ -1629,13 +1611,13 @@
auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server1({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server1({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
- ServiceWorkerTCPServer server2({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server2({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
auto *processPool = configuration.get().processPool;
@@ -1743,9 +1725,9 @@
auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
auto *processPool = configuration.get().processPool;
@@ -1884,9 +1866,9 @@
RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -1924,12 +1906,10 @@
RetainPtr<WKProcessPool> protectedProcessPool;
RetainPtr<WKWebsiteDataStore> protectedWebsiteDataStore;
- ServiceWorkerTCPServer server({
- { "text/html", mainRegisteringWorkerBytes },
- { "application/_javascript_", scriptBytes },
- }, {
- { "text/html", mainRegisteringAlreadyExistingWorkerBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { mainRegisteringWorkerBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
+ { "/second.html", { mainRegisteringAlreadyExistingWorkerBytes } },
});
@autoreleasepool {
@@ -1947,7 +1927,7 @@
protectedProcessPool = webView.get().configuration.processPool;
protectedWebsiteDataStore = webView.get().configuration.websiteDataStore;
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -1970,7 +1950,7 @@
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -1993,10 +1973,10 @@
RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
- { "text/html", mainBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/first.html", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
+ { "/second.html", { mainBytes } },
});
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -2008,7 +1988,7 @@
done = false;
// Normal load to get SW registered.
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/first.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -2031,7 +2011,7 @@
[webView.get().configuration.websiteDataStore _sendNetworkProcessDidResume];
- [webView loadRequest:server.request()];
+ [webView loadRequest:server.request("/second.html")];
TestWebKitAPI::Util::run(&done);
done = false;
@@ -2081,9 +2061,9 @@
auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server1({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server1({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
WKProcessPool *processPool = configuration.get().processPool;
@@ -2097,9 +2077,9 @@
configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
- ServiceWorkerTCPServer server2({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server2({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -2384,9 +2364,9 @@
auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -2439,9 +2419,9 @@
auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { { { "Content-Type", "application/_javascript_" } }, scriptBytes } },
});
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);