Changeset 276983 in webkit
- Timestamp:
- May 4, 2021 2:32:05 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r276979 r276983 1 2021-05-04 Alex Christensen <achristensen@webkit.org> 2 3 localStorage changes aren't reflected between WKWebViews using WKWebViewConfiguration._groupIdentifier 4 https://bugs.webkit.org/show_bug.cgi?id=225344 5 <rdar://77496721> 6 7 Reviewed by Brady Eidson. 8 9 When we switched from using _pageGroup to _groupIdentifier, we also broke localStorage by making a new pageGroupID for each WKWebView. 10 This is the low-risk solution to this problem that remembers what pageGroupID we used for this same identifier, creating the effect of 11 using the same StorageNamespaceIdentifier for each _groupIdentifier like we did when we used _pageGroup. 12 See the comment in StorageAreaMap::dispatchLocalStorageEvent. 13 14 The higher-risk solution that needs to be done but probably shouldn't be merged to a branch at this point is to remove StorageNamespaceIdentifier. 15 I plan to do that in a follow-up patch. 16 17 * UIProcess/WebPageGroup.cpp: 18 (WebKit::pageGroupData): 19 1 20 2021-05-04 Jer Noble <jer.noble@apple.com> 2 21 -
trunk/Source/WebKit/UIProcess/WebPageGroup.cpp
r274117 r276983 78 78 WebPageGroupData data; 79 79 80 data.pageGroupID = generatePageGroupID(); 80 static NeverDestroyed<HashMap<String, uint64_t>> map; 81 if (HashMap<String, uint64_t>::isValidKey(identifier)) { 82 data.pageGroupID = map.get().ensure(identifier, [] { 83 return generatePageGroupID(); 84 }).iterator->value; 85 } else 86 data.pageGroupID = generatePageGroupID(); 81 87 82 88 if (!identifier.isEmpty()) -
trunk/Tools/ChangeLog
r276970 r276983 1 2021-05-04 Alex Christensen <achristensen@webkit.org> 2 3 localStorage changes aren't reflected between WKWebViews using WKWebViewConfiguration._groupIdentifier 4 https://bugs.webkit.org/show_bug.cgi?id=225344 5 <rdar://77496721> 6 7 Reviewed by Brady Eidson. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 10 (TEST): 11 1 12 2021-05-04 Aakash Jain <aakash_jain@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm
r267763 r276983 28 28 #import "PlatformUtilities.h" 29 29 #import "Test.h" 30 #import "TestNavigationDelegate.h" 31 #import "TestUIDelegate.h" 30 32 #import <WebKit/WKProcessPoolPrivate.h> 31 33 #import <WebKit/WKUserContentControllerPrivate.h> … … 416 418 finishedRunningScript = false; 417 419 } 420 421 TEST(WKWebView, LocalStorageGroup) 422 { 423 auto runTest = [] (bool setGroupIdentifier) { 424 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 425 [configuration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]]; 426 if (setGroupIdentifier) 427 [configuration _setGroupIdentifier:@"testgroupidentifier"]; 428 auto webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 429 NSString *html1 = @"" 430 "<script>" 431 "localStorage.setItem('testkey', 'testvalue1');" 432 "window.onstorage = function(e) { alert('storage changed key ' + e.key + ' value from ' + e.oldValue + ' to ' + e.newValue) };" 433 "</script>"; 434 [webView1 loadHTMLString:html1 baseURL:[NSURL URLWithString:@"https://webkit.org/"]]; 435 [webView1 _test_waitForDidFinishNavigation]; 436 437 auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 438 NSString *html2 = @"" 439 "<script>" 440 "alert('second web view got value ' + localStorage.getItem('testkey'));" 441 "localStorage.setItem('testkey', 'testvalue2');" 442 "</script>"; 443 [webView2 loadHTMLString:html2 baseURL:[NSURL URLWithString:@"https://webkit.org/"]]; 444 EXPECT_WK_STREQ([webView2 _test_waitForAlert], "second web view got value testvalue1"); 445 446 EXPECT_WK_STREQ([webView1 _test_waitForAlert], "storage changed key testkey value from testvalue1 to testvalue2"); 447 }; 448 runTest(true); 449 runTest(false); 450 }
Note: See TracChangeset
for help on using the changeset viewer.