Title: [202984] trunk
Revision
202984
Author
[email protected]
Date
2016-07-08 10:03:12 -0700 (Fri, 08 Jul 2016)

Log Message

Clearing LocalStorage doesn't also delete -wal and -shm files.
<rdar://problem/27206772> and https://bugs.webkit.org/show_bug.cgi?id=159566

Reviewed by Brent Fulgham.
Also helpfully picked over by Andy "Never Forgets" Estes.

Source/WebCore:

Covered by new API test.

* WebCore.xcodeproj/project.pbxproj:

* platform/sql/SQLiteFileSystem.h:

Source/WebKit2:

* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
(WebKit::LocalStorageDatabaseTracker::removeDatabaseWithOriginIdentifier):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202983 => 202984)


--- trunk/Source/WebCore/ChangeLog	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Source/WebCore/ChangeLog	2016-07-08 17:03:12 UTC (rev 202984)
@@ -1,3 +1,17 @@
+2016-07-08  Brady Eidson  <[email protected]>
+
+        Clearing LocalStorage doesn't also delete -wal and -shm files.
+        <rdar://problem/27206772> and https://bugs.webkit.org/show_bug.cgi?id=159566
+
+        Reviewed by Brent Fulgham.
+        Also helpfully picked over by Andy "Never Forgets" Estes.
+
+        Covered by new API test.
+
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * platform/sql/SQLiteFileSystem.h:
+
 2016-07-08  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r202945.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202983 => 202984)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-08 17:03:12 UTC (rev 202984)
@@ -5415,7 +5415,7 @@
 		B59DD6A911902A71007E9684 /* JSSQLStatementErrorCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B59DD6A711902A71007E9684 /* JSSQLStatementErrorCallback.h */; };
 		B59DD6AA11902A71007E9684 /* JSSQLStatementErrorCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59DD6A811902A71007E9684 /* JSSQLStatementErrorCallback.cpp */; };
 		B59ED23B18272679006D564C /* RenderAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = B59ED23A18272679006D564C /* RenderAncestorIterator.h */; };
-		B5A684220FFABE9800D24689 /* SQLiteFileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A684210FFABE9800D24689 /* SQLiteFileSystem.h */; };
+		B5A684220FFABE9800D24689 /* SQLiteFileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A684210FFABE9800D24689 /* SQLiteFileSystem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B5A684240FFABEAA00D24689 /* SQLiteFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A684230FFABEAA00D24689 /* SQLiteFileSystem.cpp */; };
 		B5B65874186FDE4C009C26E8 /* RenderPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = ADE16736181050C300463A2E /* RenderPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B5B7A17017C10AA800E4AA0A /* ElementData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5B7A16F17C1080600E4AA0A /* ElementData.cpp */; };

Modified: trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h (202983 => 202984)


--- trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h	2016-07-08 17:03:12 UTC (rev 202984)
@@ -88,7 +88,7 @@
     // Deletes a database file.
     //
     // fileName - The file name.
-    static bool deleteDatabaseFile(const String& fileName);
+    WEBCORE_EXPORT static bool deleteDatabaseFile(const String& fileName);
 
 #if PLATFORM(IOS)
     // Truncates a database file. Used when MobileSafariSettings deletes a database file,

Modified: trunk/Source/WebKit2/ChangeLog (202983 => 202984)


--- trunk/Source/WebKit2/ChangeLog	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-08 17:03:12 UTC (rev 202984)
@@ -1,3 +1,14 @@
+2016-07-08  Brady Eidson  <[email protected]>
+
+        Clearing LocalStorage doesn't also delete -wal and -shm files.
+        <rdar://problem/27206772> and https://bugs.webkit.org/show_bug.cgi?id=159566
+
+        Reviewed by Brent Fulgham.
+        Also helpfully picked over by Andy "Never Forgets" Estes.
+
+        * UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
+        (WebKit::LocalStorageDatabaseTracker::removeDatabaseWithOriginIdentifier):
+
 2016-07-07  Andy Estes  <[email protected]>
 
         [Content Filtering] Load blocked pages more like other error pages are loaded

Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp (202983 => 202984)


--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp	2016-07-08 17:03:12 UTC (rev 202984)
@@ -27,6 +27,7 @@
 #include "LocalStorageDatabaseTracker.h"
 
 #include <WebCore/FileSystem.h>
+#include <WebCore/SQLiteFilesystem.h>
 #include <WebCore/SQLiteStatement.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/TextEncoding.h>
@@ -336,13 +337,13 @@
         return;
     }
 
-    deleteFile(path);
+    SQLiteFileSystem::deleteDatabaseFile(path);
 
     m_origins.remove(originIdentifier);
     if (m_origins.isEmpty()) {
         // There are no origins left; delete the tracker database.
         m_database.close();
-        deleteFile(trackerDatabasePath());
+        SQLiteFileSystem::deleteDatabaseFile(trackerDatabasePath());
         deleteEmptyDirectory(m_localStorageDirectory);
     }
 

Modified: trunk/Tools/ChangeLog (202983 => 202984)


--- trunk/Tools/ChangeLog	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Tools/ChangeLog	2016-07-08 17:03:12 UTC (rev 202984)
@@ -1,3 +1,15 @@
+2016-07-08  Brady Eidson  <[email protected]>
+
+        Clearing LocalStorage doesn't also delete -wal and -shm files.
+        <rdar://problem/27206772> and https://bugs.webkit.org/show_bug.cgi?id=159566
+
+        Reviewed by Brent Fulgham.
+        Also helpfully picked over by Andy "Never Forgets" Estes.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm: Added.
+
 2016-07-08  Konstantin Tokarev  <[email protected]>
 
         Removed Qt leftovers from Tools.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (202983 => 202984)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-07-08 16:42:20 UTC (rev 202983)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-07-08 17:03:12 UTC (rev 202984)
@@ -87,6 +87,8 @@
 		51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */; };
 		51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
 		51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780371919AFF8001829A2 /* simple3.html */; };
+		51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */; };
+		51E6A8961D2F1CA700C004B6 /* LocalStorageClear.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */; };
 		51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */; };
 		520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */; };
 		524BBC9E19DF72C0002F1AF1 /* file-with-video.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 524BBC9B19DF3714002F1AF1 /* file-with-video.html */; };
@@ -479,6 +481,7 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				51E6A8961D2F1CA700C004B6 /* LocalStorageClear.html in Copy Resources */,
 				51A587851D2739E3004BA9AF /* IndexedDBDatabaseProcessKill-1.html in Copy Resources */,
 				510477771D298E72009747EB /* IDBDeleteRecovery.html in Copy Resources */,
 				510477721D298DDD009747EB /* IDBDeleteRecovery.sqlite3 in Copy Resources */,
@@ -733,6 +736,8 @@
 		51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModalAlerts.mm; sourceTree = "<group>"; };
 		51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "modal-alerts-in-new-about-blank-window.html"; sourceTree = "<group>"; };
 		51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
+		51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageClear.mm; sourceTree = "<group>"; };
+		51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageClear.html; sourceTree = "<group>"; };
 		51E780361919AFF8001829A2 /* simple2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple2.html; sourceTree = "<group>"; };
 		51E780371919AFF8001829A2 /* simple3.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple3.html; sourceTree = "<group>"; };
 		51E93016156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageGetScaleFactorNotZero.cpp; sourceTree = "<group>"; };
@@ -1181,6 +1186,7 @@
 				51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */,
 				37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
 				57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
+				51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */,
 				51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
 				1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
 				CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
@@ -1293,6 +1299,7 @@
 				51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */,
 				51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */,
 				51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */,
+				51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */,
 				51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
 				51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
 				93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */,
@@ -2098,6 +2105,7 @@
 				51714EB81CF8CA17004723C4 /* WebProcessKillIDBCleanup.mm in Sources */,
 				7CCE7EFA1A411AE600447C4C /* HitTestResultNodeHandle.cpp in Sources */,
 				7CCE7EC11A411A7E00447C4C /* HTMLCollectionNamedItem.mm in Sources */,
+				51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */,
 				7CCE7EC21A411A7E00447C4C /* HTMLFormCollectionNamedItem.mm in Sources */,
 				7CCE7EFB1A411AE600447C4C /* InjectedBundleBasic.cpp in Sources */,
 				7CCE7EFC1A411AE600447C4C /* InjectedBundleFrameHitTest.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.html (0 => 202984)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.html	2016-07-08 17:03:12 UTC (rev 202984)
@@ -0,0 +1,6 @@
+<script>
+
+window.localStorage.foo = "bar";
+window.webkit.messageHandlers.testHandler.postMessage('Go ahead and clear it');
+
+</script>

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm (0 => 202984)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LocalStorageClear.mm	2016-07-08 17:03:12 UTC (rev 202984)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WKWebsiteDataStore.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WebKit.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED
+
+static bool readyToContinue;
+
+@interface LocalStorageClearMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation LocalStorageClearMessageHandler
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    readyToContinue = true;
+}
+
+@end
+
+TEST(WKWebView, LocalStorageClear)
+{
+    RetainPtr<LocalStorageClearMessageHandler> handler = adoptNS([[LocalStorageClearMessageHandler alloc] init]);
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
+
+    [configuration _setAllowUniversalAccessFromFileURLs:YES];
+
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"LocalStorageClear" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&readyToContinue);
+    readyToContinue = false;
+
+    webView = nil;
+
+    NSString *dbPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.localstorage" stringByExpandingTildeInPath];
+    NSString *dbSHMPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.localstorage-shm" stringByExpandingTildeInPath];
+    NSString *dbWALPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.localstorage-wal" stringByExpandingTildeInPath];
+    NSString *trackerPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/StorageTracker.db" stringByExpandingTildeInPath];
+    NSString *trackerSHMPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/StorageTracker.db-shm" stringByExpandingTildeInPath];
+    NSString *trackerWALPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/StorageTracker.db-wal" stringByExpandingTildeInPath];
+
+    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:dbPath]);
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:dbSHMPath]);
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:dbWALPath]);
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:trackerPath]);
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:trackerSHMPath]);
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:trackerWALPath]);
+        readyToContinue = true;
+    }];
+
+    TestWebKitAPI::Util::run(&readyToContinue);
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to