Changeset 232079 in webkit


Ignore:
Timestamp:
May 22, 2018 2:13:59 PM (6 years ago)
Author:
sihui_liu@apple.com
Message:

Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
https://bugs.webkit.org/show_bug.cgi?id=185715

Reviewed by Geoffrey Garen.

Source/WebCore:

Fixed the issue of null port when converting between SecurityOriginData and DatabaseIdentifier.

Test: WKWebView.LocalStorageFetchDataRecords.

  • page/SecurityOriginData.cpp:

(WebCore::SecurityOriginData::fromDatabaseIdentifier):

Source/WebKit:

Add getter for origins in WKWebsiteDataRecord for testing.

  • UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:

(-[WKWebsiteDataRecord _originsString]):

  • UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h:

Tools:

Add API test coverage.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitCocoa/LocalStorageDatabaseTracker.mm: Added.

(-[LocalStorageUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(TEST):

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r232070 r232079  
     12018-05-22  Sihui Liu  <sihui_liu@apple.com>
     2
     3        Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
     4        https://bugs.webkit.org/show_bug.cgi?id=185715
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Fixed the issue of null port when converting between SecurityOriginData and DatabaseIdentifier.
     9
     10        Test: WKWebView.LocalStorageFetchDataRecords.
     11
     12        * page/SecurityOriginData.cpp:
     13        (WebCore::SecurityOriginData::fromDatabaseIdentifier):
     14
    1152018-05-22  Keith Miller  <keith_miller@apple.com>
    216
  • trunk/Source/WebCore/page/SecurityOriginData.cpp

    r229979 r232079  
    115115        return std::nullopt;
    116116   
    117     return SecurityOriginData {databaseIdentifier.substring(0, separator1), databaseIdentifier.substring(separator1 + 1, separator2 - separator1 - 1), static_cast<uint16_t>(port)};
     117    auto protocol = databaseIdentifier.substring(0, separator1);
     118    auto host = databaseIdentifier.substring(separator1 + 1, separator2 - separator1 - 1);
     119    if (!port)
     120        return SecurityOriginData { protocol, host, std::nullopt };
     121
     122    return SecurityOriginData { protocol, host, static_cast<uint16_t>(port) };
    118123}
    119124
  • trunk/Source/WebKit/ChangeLog

    r232078 r232079  
     12018-05-22  Sihui Liu  <sihui_liu@apple.com>
     2
     3        Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
     4        https://bugs.webkit.org/show_bug.cgi?id=185715
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add getter for origins in WKWebsiteDataRecord for testing.
     9
     10        * UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
     11        (-[WKWebsiteDataRecord _originsString]):
     12        * UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h:
     13
     14
    1152018-05-22  Brady Eidson  <beidson@apple.com>
    216
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm

    r223213 r232079  
    3030
    3131#import "_WKWebsiteDataSizeInternal.h"
     32#import <WebCore/SecurityOriginData.h>
     33#import <wtf/HashSet.h>
    3234
    3335NSString * const WKWebsiteDataTypeFetchCache = @"WKWebsiteDataTypeFetchCache";
     
    147149}
    148150
     151- (NSArray<NSString *> *)_originsStrings
     152{
     153    auto origins = _websiteDataRecord->websiteDataRecord().origins;
     154    NSMutableArray<NSString *> *array = [[NSMutableArray alloc] initWithCapacity:origins.size()];
     155    for (auto& origin : origins)
     156        [array addObject:(NSString *)origin.toString()];
     157    return [array autorelease];
     158}
     159
    149160@end
    150161
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h

    r221930 r232079  
    4747@property (nullable, nonatomic, readonly) _WKWebsiteDataSize *_dataSize;
    4848
     49- (NSArray<NSString *> *)_originsStrings WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     50
    4951@end
    5052
  • trunk/Tools/ChangeLog

    r232071 r232079  
     12018-05-22  Sihui Liu  <sihui_liu@apple.com>
     2
     3        Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
     4        https://bugs.webkit.org/show_bug.cgi?id=185715
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add API test coverage.
     9
     10        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     11        * TestWebKitAPI/Tests/WebKitCocoa/LocalStorageDatabaseTracker.mm: Added.
     12        (-[LocalStorageUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
     13        (TEST):
     14
    1152018-05-22  Sihui Liu  <sihui_liu@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r231979 r232079  
    699699                C9C60E661E53A9DC006DA181 /* autoplay-check-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */; };
    700700                C9E6DD351EA97D0800DD78AA /* FirstResponderSuppression.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E6DD311EA972D800DD78AA /* FirstResponderSuppression.mm */; };
     701                CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */; };
    701702                CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */; };
    702703                CD0BD0A81F79982D001AB2CF /* ContextMenuImgWithVideo.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */; };
     
    18441845                C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check-in-iframe.html"; sourceTree = "<group>"; };
    18451846                C9E6DD311EA972D800DD78AA /* FirstResponderSuppression.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderSuppression.mm; sourceTree = "<group>"; };
     1847                CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageDatabaseTracker.mm; sourceTree = "<group>"; };
    18461848                CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuImgWithVideo.mm; sourceTree = "<group>"; };
    18471849                CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = ContextMenuImgWithVideo.html; sourceTree = "<group>"; };
     
    22142216                                57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
    22152217                                51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */,
     2218                                CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */,
    22162219                                46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */,
    22172220                                8C10AF96206467770018FD90 /* LocalStoragePersistence.mm */,
     
    36503653                                574F55CF204D37C5002948C6 /* LocalAuthenticator.mm in Sources */,
    36513654                                51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */,
     3655                                CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */,
    36523656                                46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */,
    36533657                                8C10AF99206467A90018FD90 /* LocalStoragePersistence.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.