Skip to content

Commit

Permalink
IndexedDB.IndexedDBPersistence is flakily failing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274099
rdar://128014218

Reviewed by Alex Christensen.

The second message might arrive on the first wait, so instead of starting a second wait, the test should check whether
first message has arrived after first wait. This is what getNextMessage() does, and the test doesn't need to do explicit
wait.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBPersistence.mm:
(TEST(IndexedDB, IndexedDBPersistence)):
(IndexedDBThirdPartyDataRemoval)):
(MigrateThirdPartyDataToGeneralStorageDirectory)):
((IndexedDB, IndexedDBGetDatabases)):

Canonical link: https://commits.webkit.org/278769@main
  • Loading branch information
szewai committed May 14, 2024
1 parent 10a4e90 commit 52a9c96
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBPersistence.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ - (void)userContentController:(WKUserContentController *)userContentController d
NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"IndexedDBPersistence-1" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
[webView loadRequest:request];

TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
RetainPtr<NSString> string1 = (NSString *)[getNextMessage() body];

TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
RetainPtr<NSString> string2 = (NSString *)[getNextMessage() body];

// Ditch this web view (ditching its web process)
Expand All @@ -86,9 +81,6 @@ - (void)userContentController:(WKUserContentController *)userContentController d

request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"IndexedDBPersistence-2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
[webView loadRequest:request];

TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
RetainPtr<NSString> string3 = (NSString *)[getNextMessage() body];

EXPECT_WK_STREQ(@"UpgradeNeeded", string1.get());
Expand Down Expand Up @@ -234,8 +226,6 @@ function postResult(result) {
static void loadThirdPartyPageInWebView(WKWebView *webView, NSString *expectedResult)
{
[webView loadHTMLString:mainFrameStringPersistence baseURL:[NSURL URLWithString:@"http://webkit.org"]];
TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
EXPECT_WK_STREQ(expectedResult, (NSString *)[getNextMessage() body]);
}

Expand Down Expand Up @@ -296,8 +286,6 @@ static void loadThirdPartyPageInWebView(WKWebView *webView, NSString *expectedRe

auto secondWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
[secondWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"iframe://"]]];
TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
EXPECT_WK_STREQ( @"database is created - put item success", (NSString *)[getNextMessage() body]);

readyToContinue = false;
Expand Down Expand Up @@ -423,8 +411,6 @@ static void loadThirdPartyPageInWebView(WKWebView *webView, NSString *expectedRe
}; \
</script>";
[webView loadHTMLString:firstPartyHTMLString baseURL:[NSURL URLWithString:@"http://webkit.org"]];
TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
EXPECT_WK_STREQ(@"database is created", (NSString *)[getNextMessage() body]);
EXPECT_TRUE([fileManager fileExistsAtPath:webkitOriginFile.path]);
EXPECT_FALSE([fileManager fileExistsAtPath:wrongWebkitIframeDatabaseDirectory.path]);
Expand Down Expand Up @@ -567,19 +553,13 @@ function postDatabases(databases) {

RetainPtr webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
[webView loadHTMLString:getDatabasesString baseURL:[NSURL URLWithString:@"http://apple.com"]];
TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
EXPECT_WK_STREQ(@"databases: [{\"name\":\"IndexedDBGetDatabases\",\"version\":1}]", [getNextMessage() body]);

[webView evaluateJavaScript:@"loadFrame()" completionHandler:nil];
TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
EXPECT_WK_STREQ(@"child frame databases: []", [getNextMessage() body]);

RetainPtr secondWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
[secondWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"webkit://"]]];
TestWebKitAPI::Util::run(&receivedScriptMessage);
receivedScriptMessage = false;
EXPECT_WK_STREQ(@"main frame databases: []", [getNextMessage() body]);

// Getting databases should not create files on disk.
Expand Down

0 comments on commit 52a9c96

Please sign in to comment.