Title: [243814] trunk/Tools
- Revision
- 243814
- Author
- [email protected]
- Date
- 2019-04-03 10:54:44 -0700 (Wed, 03 Apr 2019)
Log Message
Add a test for DOMCache on multiple browsing in case of private browsing
https://bugs.webkit.org/show_bug.cgi?id=196524
Reviewed by Alex Christensen.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
(-[SWMessageHandlerForCacheStorage userContentController:didReceiveScriptMessage:]):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (243813 => 243814)
--- trunk/Tools/ChangeLog 2019-04-03 17:48:31 UTC (rev 243813)
+++ trunk/Tools/ChangeLog 2019-04-03 17:54:44 UTC (rev 243814)
@@ -1,3 +1,13 @@
+2019-04-03 Youenn Fablet <[email protected]>
+
+ Add a test for DOMCache on multiple browsing in case of private browsing
+ https://bugs.webkit.org/show_bug.cgi?id=196524
+
+ Reviewed by Alex Christensen.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+ (-[SWMessageHandlerForCacheStorage userContentController:didReceiveScriptMessage:]):
+
2019-04-03 Jonathan Bedard <[email protected]>
[ews] Clean out ~/Library/Logs/CoreSimulator/ on reboot
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (243813 => 243814)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2019-04-03 17:48:31 UTC (rev 243813)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2019-04-03 17:54:44 UTC (rev 243814)
@@ -1272,6 +1272,81 @@
done = false;
}
+static const char* readCacheBytes = R"SWRESOURCE(
+<script>
+
+function log(msg)
+{
+ window.webkit.messageHandlers.sw.postMessage(msg);
+}
+
+window.caches.keys().then(keys => {
+ log(keys.length && keys[0] === "test" ? "PASS" : "FAIL");
+}, () => {
+ log("FAIL");
+});
+
+</script>
+)SWRESOURCE";
+
+static const char* writeCacheBytes = R"SWRESOURCE(
+<script>
+
+function log(msg)
+{
+ window.webkit.messageHandlers.sw.postMessage(msg);
+}
+
+window.caches.open("test").then(() => {
+ log("PASS");
+}, () => {
+ log("FAIL");
+});
+
+</script>
+)SWRESOURCE";
+
+@interface SWMessageHandlerForCacheStorage : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation SWMessageHandlerForCacheStorage
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ EXPECT_WK_STREQ(@"PASS", [message body]);
+ done = true;
+}
+@end
+
+TEST(ServiceWorkers, CacheStorageInPrivateBrowsingMode)
+{
+ [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+ auto messageHandler = adoptNS([[SWMessageHandlerForCacheStorage alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
+
+ auto handler = adoptNS([[SWSchemes alloc] init]);
+ handler->resources.set("sw://host/readCache.html", ResourceInfo { @"text/html", readCacheBytes });
+ handler->resources.set("sw://host/writeCache.html", ResourceInfo { @"text/html", writeCacheBytes });
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"];
+
+ configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
+ [configuration.get().processPool _registerURLSchemeServiceWorkersCanHandle:@"sw"];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ auto *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/writeCache.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/readCache.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
static const char* regularPageGrabbingCacheStorageDirectory = R"SWRESOURCE(
<script>
async function getResult()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes