Title: [288478] trunk
Revision
288478
Author
[email protected]
Date
2022-01-24 16:07:17 -0800 (Mon, 24 Jan 2022)

Log Message

Regression (r286936): SessionStorage data is not cleared when deleting website data by modification time
https://bugs.webkit.org/show_bug.cgi?id=235542

Reviewed by Chris Dumez.

Source/WebKit:

The old behavior before r286936 is to delete SessionStorage data regardless of the modifiedSince parameter.
r286936 made it check modifiedSince and perform deleteion when modifiedSince time is -Walltime::infinity. This
patch corrects it by deleting SessionStorage data when modifiedSince time is in the past.

API test: SessionStorage.ClearByModificationTime

* NetworkProcess/storage/OriginStorageManager.cpp:
(WebKit::OriginStorageManager::StorageBucket::deleteData):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (288477 => 288478)


--- trunk/Source/WebKit/ChangeLog	2022-01-24 23:47:36 UTC (rev 288477)
+++ trunk/Source/WebKit/ChangeLog	2022-01-25 00:07:17 UTC (rev 288478)
@@ -1,3 +1,19 @@
+2022-01-24  Sihui Liu  <[email protected]>
+
+        Regression (r286936): SessionStorage data is not cleared when deleting website data by modification time
+        https://bugs.webkit.org/show_bug.cgi?id=235542
+
+        Reviewed by Chris Dumez.
+
+        The old behavior before r286936 is to delete SessionStorage data regardless of the modifiedSince parameter.
+        r286936 made it check modifiedSince and perform deleteion when modifiedSince time is -Walltime::infinity. This 
+        patch corrects it by deleting SessionStorage data when modifiedSince time is in the past.
+
+        API test: SessionStorage.ClearByModificationTime
+
+        * NetworkProcess/storage/OriginStorageManager.cpp:
+        (WebKit::OriginStorageManager::StorageBucket::deleteData):
+
 2022-01-24  Ada Chan  <[email protected]>
 
         Soft link ARKit in a separate ARKitSoftLink file

Modified: trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp (288477 => 288478)


--- trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp	2022-01-24 23:47:36 UTC (rev 288477)
+++ trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp	2022-01-25 00:07:17 UTC (rev 288478)
@@ -174,7 +174,7 @@
         if (types.contains(WebsiteDataType::LocalStorage))
             deleteLocalStorageData(modifiedSinceTime);
 
-        if (types.contains(WebsiteDataType::SessionStorage) && modifiedSinceTime == -WallTime::infinity())
+        if (types.contains(WebsiteDataType::SessionStorage) && modifiedSinceTime < WallTime::now())
             deleteSessionStorageData();
     }
 

Modified: trunk/Tools/ChangeLog (288477 => 288478)


--- trunk/Tools/ChangeLog	2022-01-24 23:47:36 UTC (rev 288477)
+++ trunk/Tools/ChangeLog	2022-01-25 00:07:17 UTC (rev 288478)
@@ -1,3 +1,13 @@
+2022-01-24  Sihui Liu  <[email protected]>
+
+        Regression (r286936): SessionStorage data is not cleared when deleting website data by modification time
+        https://bugs.webkit.org/show_bug.cgi?id=235542
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm:
+        (TEST):
+
 2022-01-24  Wenson Hsieh  <[email protected]>
 
         [macOS] Update Pasteboard::read to prioritize native representations over TIFF

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm (288477 => 288478)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm	2022-01-24 23:47:36 UTC (rev 288477)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SessionStorage.mm	2022-01-25 00:07:17 UTC (rev 288478)
@@ -117,3 +117,32 @@
 {
     runSessionStorageInNewWindowTest(@"a = document.createElement('a'); a.href = "" a.target = 'newWindow'; a.rel='noopener'; a.click()", ShouldSessionBeCloned::No);
 }
+
+TEST(SessionStorage, ClearByModificationTime)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    [webView synchronouslyLoadHTMLString:@"<script>sessionStorage.setItem('key', 'value')</script>" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+
+    auto websiteDataTypes = adoptNS([[NSSet alloc] initWithArray:@[WKWebsiteDataTypeSessionStorage]]);
+    readyToContinue = false;
+    [[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:websiteDataTypes.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
+        EXPECT_EQ(1u, dataRecords.count);
+        EXPECT_WK_STREQ("webkit.org", [[dataRecords firstObject] displayName]);
+        readyToContinue = true;
+    }];
+    TestWebKitAPI::Util::run(&readyToContinue);
+
+    readyToContinue = false;
+    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes.get() modifiedSince:[NSDate distantPast] completionHandler:^() {
+        readyToContinue = true;
+    }];
+    TestWebKitAPI::Util::run(&readyToContinue);
+
+    readyToContinue = false;
+    [[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:websiteDataTypes.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) {
+        EXPECT_EQ(0u, dataRecords.count);
+        readyToContinue = true;
+    }];
+    TestWebKitAPI::Util::run(&readyToContinue);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to