Skip to content

Commit

Permalink
TestWebKitAPI.PushAPI.firePushEventWithNoPages* tests are flakily tim…
Browse files Browse the repository at this point in the history
…ing out

https://bugs.webkit.org/show_bug.cgi?id=257341
rdar://109846867

Reviewed by Youenn Fablet.

Since 262941@main, ServiceWorkerRegistrations data is stored in origin directory instead of ServiceWorkerRegistrations
directory, so tests should not check inside ServiceWorkerRegistrations directory to decide whether registrations are
stored on disk. The tests can use SPI to flush registrations to disk.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm:

Canonical link: https://commits.webkit.org/264592@main
  • Loading branch information
szewai committed May 26, 2023
1 parent 14e948c commit 974deb3
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm
Expand Up @@ -506,24 +506,15 @@ - (void)dealloc

static void terminateNetworkProcessWhileRegistrationIsStored(WKWebViewConfiguration *configuration)
{
auto path = configuration.websiteDataStore._configuration._serviceWorkerRegistrationDirectory.path;
NSURL* directory = [NSURL fileURLWithPath:path isDirectory:YES];
auto filename = makeString("ServiceWorkerRegistrations-"_s, WebCore::SWRegistrationDatabase::schemaVersion, ".sqlite3");
NSURL *swDBPath = [directory URLByAppendingPathComponent:filename];
unsigned timeout = 0;
while (![[NSFileManager defaultManager] fileExistsAtPath:swDBPath.path] && ++timeout < 100)
TestWebKitAPI::Util::runFor(0.1_s);
// Let's close the SQL database.
[configuration.websiteDataStore _sendNetworkProcessWillSuspendImminently];
done = false;
[configuration.websiteDataStore _storeServiceWorkerRegistrations:^{
done = true;
}];
TestWebKitAPI::Util::run(&done);
[configuration.websiteDataStore _terminateNetworkProcess];
}

// FIXME when rdar://109725221 is resolved
#if PLATFORM(IOS)
TEST(PushAPI, DISABLED_firePushEventWithNoPagesSuccessful)
#else
TEST(PushAPI, firePushEventWithNoPagesSuccessful)
#endif
{
TestWebKitAPI::HTTPServer server({
{ "/"_s, { mainBytes } },
Expand Down Expand Up @@ -571,12 +562,7 @@ static void terminateNetworkProcessWhileRegistrationIsStored(WKWebViewConfigurat
clearWebsiteDataStore([configuration websiteDataStore]);
}

// FIXME when rdar://109725221 is resolved
#if PLATFORM(IOS)
TEST(PushAPI, DISABLED_firePushEventWithNoPagesFail)
#else
TEST(PushAPI, firePushEventWithNoPagesFail)
#endif
{
TestWebKitAPI::HTTPServer server({
{ "/"_s, { mainBytes } },
Expand Down Expand Up @@ -622,11 +608,8 @@ static void terminateNetworkProcessWhileRegistrationIsStored(WKWebViewConfigurat

clearWebsiteDataStore([configuration websiteDataStore]);
}
#if PLATFORM(IOS)
TEST(PushAPI, DISABLED_firePushEventWithNoPagesTimeout)
#else

TEST(PushAPI, firePushEventWithNoPagesTimeout)
#endif
{
TestWebKitAPI::HTTPServer server({
{ "/"_s, { mainBytes } },
Expand Down

0 comments on commit 974deb3

Please sign in to comment.