Tools/ChangeLog

 12021-10-07 Youenn Fablet <youenn@apple.com>
 2
 3 REGRESSION (r283613): [ macOS ] TestWebKitAPI.ResourceLoadDelegate.LoadInfo is failing
 4 https://bugs.webkit.org/show_bug.cgi?id=231303
 5 <rdar://problem/83940067>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Make sure to clear all data store at the end of PushAPI test, as well as at the beginning of ResourceLoadDelegate test.
 10
 11 * TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm:
 12 * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
 13
1142021-10-06 Youenn Fablet <youenn@apple.com>
215
316 Implement https://w3c.github.io/push-api/#receiving-a-push-message

Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm

@@self.addEventListener("push", (event) => {
9494});
9595)SWRESOURCE";
9696
 97static void clearWebsiteDataStore(WKWebsiteDataStore *store)
 98{
 99 __block bool clearedStore = false;
 100 [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
 101 clearedStore = true;
 102 }];
 103 TestWebKitAPI::Util::run(&clearedStore);
 104}
 105
97106static bool pushMessageProcessed = false;
98107static bool pushMessageSuccessful = false;
99108TEST(PushAPI, firePushEvent)

@@TEST(PushAPI, firePushEvent)
110119 auto messageHandler = adoptNS([[PushAPIMessageHandlerWithExpectedMessage alloc] init]);
111120 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
112121
113  [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
114  done = true;
115  }];
116  TestWebKitAPI::Util::run(&done);
117  done = false;
 122 clearWebsiteDataStore([configuration websiteDataStore]);
118123
119124 expectedMessage = "Ready";
120125 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);

@@TEST(PushAPI, firePushEvent)
149154
150155 TestWebKitAPI::Util::run(&pushMessageProcessed);
151156 EXPECT_FALSE(pushMessageSuccessful);
 157
 158 clearWebsiteDataStore([configuration websiteDataStore]);
152159}

Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm

@@TEST(ResourceLoadDelegate, ResourceType)
248248
249249TEST(ResourceLoadDelegate, LoadInfo)
250250{
 251 __block bool clearedStore = false;
 252 [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
 253 clearedStore = true;
 254 }];
 255 TestWebKitAPI::Util::run(&clearedStore);
 256
251257 TestWebKitAPI::HTTPServer server({
252258 { "/", { "<iframe src='iframeSrc'></iframe>" } },
253259 { "/iframeSrc", { "<script>fetch('fetchTarget', { body: 'a=b&c=d', method: 'post'})</script>" } },