WebKit Bugzilla
Attachment 340672 Details for
Bug 185715
: Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185715-20180517184738.patch (text/plain), 13.03 KB, created by
Sihui Liu
on 2018-05-17 18:47:39 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2018-05-17 18:47:39 PDT
Size:
13.03 KB
patch
obsolete
>Subversion Revision: 231849 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1adef6425cb6f8bf058ae5f9b2d00a707cd1ca8a..9818691f15b421787465a3c7acdbc1cdf3eb0fab 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2018-05-17 Sihui Liu <sihui_liu@apple.com> >+ >+ Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null >+ https://bugs.webkit.org/show_bug.cgi?id=185715 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fixed the issue of null port when coverting between SecurityOriginData and DatabaseIdentifier. >+ >+ Test: WKWebView.LocalStorageFetchDataRecords. >+ >+ * page/SecurityOriginData.cpp: >+ (WebCore::SecurityOriginData::fromDatabaseIdentifier): >+ > 2018-05-16 Chris Nardi <cnardi@chromium.org> > > Remove Document#selectedStylesheetSet/preferredStylesheetSet >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 116d592fbf5b3d3e3e5d4fecbf63d90d847e4b65..1bca4117b9cc87b925565f38e180361e5b67a2fa 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,17 @@ >+2018-05-17 Sihui Liu <sihui_liu@apple.com> >+ >+ Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null >+ https://bugs.webkit.org/show_bug.cgi?id=185715 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add getter for origins in WKWebsiteDataRecord for testing. >+ >+ * UIProcess/API/Cocoa/WKWebsiteDataRecord.mm: >+ (-[WKWebsiteDataRecord _originsString]): >+ * UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h: >+ >+ > 2018-05-16 Chris Nardi <cnardi@chromium.org> > > Remove Document#selectedStylesheetSet/preferredStylesheetSet >diff --git a/Source/WebCore/page/SecurityOriginData.cpp b/Source/WebCore/page/SecurityOriginData.cpp >index 2aac8ee8d3bdb0b5add8631505450264c1c27592..632a2233781eba8653da2d6eae0f29f877caa4f4 100644 >--- a/Source/WebCore/page/SecurityOriginData.cpp >+++ b/Source/WebCore/page/SecurityOriginData.cpp >@@ -114,6 +114,9 @@ std::optional<SecurityOriginData> SecurityOriginData::fromDatabaseIdentifier(con > if (port < 0 || port > std::numeric_limits<uint16_t>::max()) > return std::nullopt; > >+ if (!port) >+ return SecurityOriginData {databaseIdentifier.substring(0, separator1), databaseIdentifier.substring(separator1 + 1, separator2 - separator1 - 1), std::nullopt}; >+ > return SecurityOriginData {databaseIdentifier.substring(0, separator1), databaseIdentifier.substring(separator1 + 1, separator2 - separator1 - 1), static_cast<uint16_t>(port)}; > } > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm >index f7a6bfba63f32e7670c4ba10f46246c43a2cfcda..5219051320d231dc13fb1d7162db168c28082a79 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm >@@ -29,6 +29,8 @@ > #if WK_API_ENABLED > > #import "_WKWebsiteDataSizeInternal.h" >+#import <WebCore/SecurityOriginData.h> >+#import <wtf/HashSet.h> > > NSString * const WKWebsiteDataTypeFetchCache = @"WKWebsiteDataTypeFetchCache"; > NSString * const WKWebsiteDataTypeDiskCache = @"WKWebsiteDataTypeDiskCache"; >@@ -146,6 +148,14 @@ - (_WKWebsiteDataSize *)_dataSize > return [[[_WKWebsiteDataSize alloc] initWithSize:*size] autorelease]; > } > >+- (NSArray<NSString *> *)_originsString >+{ >+ auto array = [[NSMutableArray alloc] init]; >+ for (auto& origin : _websiteDataRecord->websiteDataRecord().origins) >+ [array addObject:[[NSString alloc] initWithCString:origin.toString().utf8().data() encoding:NSUTF8StringEncoding]]; >+ return array; >+} >+ > @end > > #endif >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h >index 536cbcd4c98dcabc13fee59f42d5f171ab0bae34..d1906373b1710044e93d9eb2a7cf4bead9128d5d 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h >@@ -46,6 +46,8 @@ WK_EXTERN NSString * const _WKWebsiteDataTypePlugInData WK_API_AVAILABLE(macosx( > > @property (nullable, nonatomic, readonly) _WKWebsiteDataSize *_dataSize; > >+- (NSArray<NSString *> *)_originsString WK_API_AVAILABLE(macosx(10.13.4), ios(11.3)); >+ > @end > > NS_ASSUME_NONNULL_END >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 7a66842554aa358f8439be7639d2ce6ca478fd2c..4ea8840cf08b7215330e208891202fa411b70ca9 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2018-05-17 Sihui Liu <sihui_liu@apple.com> >+ >+ Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null >+ https://bugs.webkit.org/show_bug.cgi?id=185715 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add API test coverage. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/LocalStorageDatabaseTracker.mm: Added. >+ (-[LocalStorageUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): >+ (TEST): >+ > 2018-05-16 Valerie R Young <valerie@bocoup.com> > > test262/Runner.pm: save to supplied expectation file if supplied >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index b20baacb181d0e71876c13e0e86d34cb76ed920b..66fa498440a660f8fa2ab50edaef19cb3255036b 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -697,6 +697,7 @@ > C9C60E651E53A9DC006DA181 /* autoplay-check-frame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */; }; > C9C60E661E53A9DC006DA181 /* autoplay-check-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */; }; > C9E6DD351EA97D0800DD78AA /* FirstResponderSuppression.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E6DD311EA972D800DD78AA /* FirstResponderSuppression.mm */; }; >+ CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */; }; > CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */; }; > CD0BD0A81F79982D001AB2CF /* ContextMenuImgWithVideo.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */; }; > CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */; }; >@@ -1841,6 +1842,7 @@ > C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check-frame.html"; sourceTree = "<group>"; }; > C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check-in-iframe.html"; sourceTree = "<group>"; }; > C9E6DD311EA972D800DD78AA /* FirstResponderSuppression.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderSuppression.mm; sourceTree = "<group>"; }; >+ CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageDatabaseTracker.mm; sourceTree = "<group>"; }; > CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuImgWithVideo.mm; sourceTree = "<group>"; }; > CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = ContextMenuImgWithVideo.html; sourceTree = "<group>"; }; > CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; }; >@@ -2211,6 +2213,7 @@ > A125478D1DB18B9400358564 /* LoadDataWithNilMIMEType.mm */, > 57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */, > 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */, >+ CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */, > 46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */, > 8C10AF96206467770018FD90 /* LocalStoragePersistence.mm */, > 7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */, >@@ -3646,6 +3649,7 @@ > 7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */, > 574F55CF204D37C5002948C6 /* LocalAuthenticator.mm in Sources */, > 51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */, >+ CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */, > 46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */, > 8C10AF99206467A90018FD90 /* LocalStoragePersistence.mm in Sources */, > 7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStorageDatabaseTracker.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStorageDatabaseTracker.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..31a30c8091d1276b7004fe723262f7705cde9c58 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStorageDatabaseTracker.mm >@@ -0,0 +1,81 @@ >+/* >+ * Copyright (C) 2018 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/WKWebsiteDataRecordPrivate.h> >+#import <WebKit/WebKit.h> >+#import <wtf/text/WTFString.h> >+ >+#if WK_API_ENABLED >+ >+static bool readyToContinue; >+ >+@interface LocalStorageUIDelegate : NSObject <WKUIDelegate> >+@end >+ >+@implementation LocalStorageUIDelegate >+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler >+{ >+ EXPECT_STREQ("testValue", message.UTF8String); >+ readyToContinue = true; >+ completionHandler(); >+} >+@end >+ >+TEST(WKWebView, LocalStorageFetchDataRecords) >+{ >+ readyToContinue = false; >+ [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() { >+ readyToContinue = true; >+ }]; >+ TestWebKitAPI::Util::run(&readyToContinue); >+ >+ readyToContinue = false; >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ configuration.get().websiteDataStore = [WKWebsiteDataStore defaultDataStore]; >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ webView.get().UIDelegate = [[LocalStorageUIDelegate alloc] init]; >+ [webView loadHTMLString:@"<script>localStorage.setItem('testKey', 'testValue');alert(localStorage.getItem('testKey'));</script>" baseURL:[NSURL URLWithString:@"http://localhost"]]; >+ TestWebKitAPI::Util::run(&readyToContinue); >+ >+ // Local storage database update interval. >+ TestWebKitAPI::Util::sleep(1); >+ >+ readyToContinue = false; >+ [[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { >+ readyToContinue = true; >+ ASSERT_EQ(1u, dataRecords.count); >+ auto origins = [[dataRecords objectAtIndex:0] _originsString]; >+ ASSERT_EQ(1u, origins.count); >+ EXPECT_TRUE([[origins objectAtIndex:0] isEqual:@"http://localhost"]); >+ }]; >+ TestWebKitAPI::Util::run(&readyToContinue); >+} >+ >+#endif >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185715
:
340561
|
340672
|
340716