Changeset 243814 in webkit
- Timestamp:
- Apr 3, 2019, 10:54:44 AM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r243803 r243814 1 2019-04-03 Youenn Fablet <youenn@apple.com> 2 3 Add a test for DOMCache on multiple browsing in case of private browsing 4 https://bugs.webkit.org/show_bug.cgi?id=196524 5 6 Reviewed by Alex Christensen. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: 9 (-[SWMessageHandlerForCacheStorage userContentController:didReceiveScriptMessage:]): 10 1 11 2019-04-03 Jonathan Bedard <jbedard@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
r242905 r243814 1273 1273 } 1274 1274 1275 static const char* readCacheBytes = R"SWRESOURCE( 1276 <script> 1277 1278 function log(msg) 1279 { 1280 window.webkit.messageHandlers.sw.postMessage(msg); 1281 } 1282 1283 window.caches.keys().then(keys => { 1284 log(keys.length && keys[0] === "test" ? "PASS" : "FAIL"); 1285 }, () => { 1286 log("FAIL"); 1287 }); 1288 1289 </script> 1290 )SWRESOURCE"; 1291 1292 static const char* writeCacheBytes = R"SWRESOURCE( 1293 <script> 1294 1295 function log(msg) 1296 { 1297 window.webkit.messageHandlers.sw.postMessage(msg); 1298 } 1299 1300 window.caches.open("test").then(() => { 1301 log("PASS"); 1302 }, () => { 1303 log("FAIL"); 1304 }); 1305 1306 </script> 1307 )SWRESOURCE"; 1308 1309 @interface SWMessageHandlerForCacheStorage : NSObject <WKScriptMessageHandler> 1310 @end 1311 1312 @implementation SWMessageHandlerForCacheStorage 1313 - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message 1314 { 1315 EXPECT_WK_STREQ(@"PASS", [message body]); 1316 done = true; 1317 } 1318 @end 1319 1320 TEST(ServiceWorkers, CacheStorageInPrivateBrowsingMode) 1321 { 1322 [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins]; 1323 1324 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 1325 1326 auto messageHandler = adoptNS([[SWMessageHandlerForCacheStorage alloc] init]); 1327 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"]; 1328 1329 auto handler = adoptNS([[SWSchemes alloc] init]); 1330 handler->resources.set("sw://host/readCache.html", ResourceInfo { @"text/html", readCacheBytes }); 1331 handler->resources.set("sw://host/writeCache.html", ResourceInfo { @"text/html", writeCacheBytes }); 1332 [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"]; 1333 1334 configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore]; 1335 [configuration.get().processPool _registerURLSchemeServiceWorkersCanHandle:@"sw"]; 1336 1337 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 1338 auto *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/writeCache.html"]]; 1339 [webView loadRequest:request]; 1340 TestWebKitAPI::Util::run(&done); 1341 done = false; 1342 1343 webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 1344 request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/readCache.html"]]; 1345 [webView loadRequest:request]; 1346 TestWebKitAPI::Util::run(&done); 1347 done = false; 1348 } 1349 1275 1350 static const char* regularPageGrabbingCacheStorageDirectory = R"SWRESOURCE( 1276 1351 <script>
Note:
See TracChangeset
for help on using the changeset viewer.