Changeset 249625 in webkit
- Timestamp:
- Sep 7, 2019 10:11:48 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249615 r249625 1 2019-09-07 Chris Dumez <cdumez@apple.com> 2 3 Rewrite storage/domstorage/localstorage/private-browsing-affects-storage.html as an API test 4 https://bugs.webkit.org/show_bug.cgi?id=201547 5 6 Reviewed by Alex Christensen. 7 8 Drop outdated test. 9 10 * storage/domstorage/localstorage/private-browsing-affects-storage.html: Removed. 11 * storage/domstorage/localstorage/resources/private-browsing-1.html: Removed. 12 * storage/domstorage/localstorage/resources/private-browsing-2.html: Removed. 13 1 14 2019-09-07 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations
r249059 r249625 67 67 http/wpt/cache-storage/cache-quota-add.any.html [ Slow ] 68 68 69 webkit.org/b/196376 [ Debug ] storage/domstorage/localstorage/private-browsing-affects-storage.html [ Pass ]70 71 69 webkit.org/b/196403 imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html [ Pass Failure ] 72 70 -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r249561 r249625 922 922 webkit.org/b/194916 fast/mediastream/MediaStream-video-element.html [ Pass Failure ] 923 923 924 webkit.org/b/196376 storage/domstorage/localstorage/private-browsing-affects-storage.html [ Pass ]925 926 924 webkit.org/b/196400 fast/mediastream/MediaStreamTrack-getSettings.html [ Pass Failure ] 927 925 -
trunk/Tools/ChangeLog
r249622 r249625 1 2019-09-07 Chris Dumez <cdumez@apple.com> 2 3 Rewrite storage/domstorage/localstorage/private-browsing-affects-storage.html as an API test 4 https://bugs.webkit.org/show_bug.cgi?id=201547 5 6 Reviewed by Alex Christensen. 7 8 Rewrite storage/domstorage/localstorage/private-browsing-affects-storage.html as an API test so 9 it can use a true ephemeral session instead of the testRunner.setPrivateBrowsingEnabled_DEPRECATED() 10 hack. 11 12 * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: 13 (-[LocalStorageNavigationDelegate webView:decidePolicyForNavigationAction:preferences:decisionHandler:]): 14 (-[LocalStorageNavigationDelegate webView:didFinishNavigation:]): 15 (TEST): 16 1 17 2019-09-07 Alex Christensen <achristensen@webkit.org> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm
r248734 r249625 31 31 #import <WebKit/WKUserContentControllerPrivate.h> 32 32 #import <WebKit/WKWebViewConfigurationPrivate.h> 33 #import <WebKit/WKWebpagePreferencesPrivate.h> 33 34 #import <WebKit/WebKit.h> 34 35 #import <WebKit/_WKProcessPoolConfiguration.h> … … 39 40 static bool readyToContinue; 40 41 static bool receivedScriptMessage; 42 static bool didFinishNavigation; 41 43 static RetainPtr<WKScriptMessage> lastScriptMessage; 42 44 static RetainPtr<WKWebView> createdWebView; … … 55 57 @end 56 58 57 @interface LocalStorageNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegate> 59 @interface LocalStorageNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegate> { 60 @public void (^decidePolicyForNavigationActionHandler)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)); 61 } 58 62 @end 59 63 … … 63 67 { 64 68 createdWebView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]); 69 [createdWebView setNavigationDelegate:self]; 65 70 return createdWebView.get(); 71 } 72 73 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler 74 { 75 if (decidePolicyForNavigationActionHandler) 76 decidePolicyForNavigationActionHandler(navigationAction, preferences, decisionHandler); 77 else 78 decisionHandler(WKNavigationActionPolicyAllow, preferences); 79 } 80 81 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 82 { 83 didFinishNavigation = true; 66 84 } 67 85 … … 235 253 EXPECT_WK_STREQ(@"local:storage", [lastScriptMessage body]); 236 254 } 255 256 TEST(WKWebView, PrivateBrowsingAffectsLocalStorage) 257 { 258 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 259 [configuration _setAllowUniversalAccessFromFileURLs:YES]; 260 [configuration setWebsiteDataStore:[WKWebsiteDataStore defaultDataStore]]; 261 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 262 263 auto delegate = adoptNS([[LocalStorageNavigationDelegate alloc] init]); 264 [webView setNavigationDelegate:delegate.get()]; 265 266 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 267 [webView loadRequest:request]; 268 269 TestWebKitAPI::Util::run(&didFinishNavigation); 270 didFinishNavigation = false; 271 272 bool finishedRunningScript = false; 273 [webView evaluateJavaScript:@"localStorage.setItem('testItem', 'Persistent item!');" completionHandler: [&] (id result, NSError *error) { 274 finishedRunningScript = true; 275 }]; 276 TestWebKitAPI::Util::run(&finishedRunningScript); 277 finishedRunningScript = false; 278 279 [webView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 280 NSString *value = (NSString *)result; 281 EXPECT_WK_STREQ(@"Persistent item!", value); 282 finishedRunningScript = true; 283 }]; 284 TestWebKitAPI::Util::run(&finishedRunningScript); 285 finishedRunningScript = false; 286 287 delegate->decidePolicyForNavigationActionHandler = ^(WKNavigationAction *navigationAction, WKWebpagePreferences *preferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { 288 // Switch to an ephemeral session. 289 preferences._websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore]; 290 decisionHandler(WKNavigationActionPolicyAllow, preferences); 291 }; 292 293 [webView reload]; 294 TestWebKitAPI::Util::run(&didFinishNavigation); 295 didFinishNavigation = false; 296 297 [webView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 298 EXPECT_TRUE([result isEqual:NSNull.null]); 299 finishedRunningScript = true; 300 }]; 301 TestWebKitAPI::Util::run(&finishedRunningScript); 302 finishedRunningScript = false; 303 304 [webView evaluateJavaScript:@"localStorage.setItem('testItem', 'FirstValue');" completionHandler: [&] (id result, NSError *error) { 305 finishedRunningScript = true; 306 }]; 307 TestWebKitAPI::Util::run(&finishedRunningScript); 308 finishedRunningScript = false; 309 310 [webView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 311 NSString *value = (NSString *)result; 312 EXPECT_WK_STREQ(@"FirstValue", value); 313 finishedRunningScript = true; 314 }]; 315 TestWebKitAPI::Util::run(&finishedRunningScript); 316 finishedRunningScript = false; 317 318 [webView evaluateJavaScript:@"localStorage.setItem('testItem', 'ChangedValue');" completionHandler: [&] (id result, NSError *error) { 319 finishedRunningScript = true; 320 }]; 321 TestWebKitAPI::Util::run(&finishedRunningScript); 322 finishedRunningScript = false; 323 324 [webView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 325 NSString *value = (NSString *)result; 326 EXPECT_WK_STREQ(@"ChangedValue", value); 327 finishedRunningScript = true; 328 }]; 329 TestWebKitAPI::Util::run(&finishedRunningScript); 330 finishedRunningScript = false; 331 332 delegate->decidePolicyForNavigationActionHandler = ^(WKNavigationAction *navigationAction, WKWebpagePreferences *preferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { 333 // Switch back to the default session. 334 preferences._websiteDataStore = [WKWebsiteDataStore defaultDataStore]; 335 decisionHandler(WKNavigationActionPolicyAllow, preferences); 336 }; 337 338 [webView reload]; 339 TestWebKitAPI::Util::run(&didFinishNavigation); 340 didFinishNavigation = false; 341 342 [webView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 343 NSString *value = (NSString *)result; 344 EXPECT_WK_STREQ(@"Persistent item!", value); 345 finishedRunningScript = true; 346 }]; 347 TestWebKitAPI::Util::run(&finishedRunningScript); 348 finishedRunningScript = false; 349 } 350 351 TEST(WKWebView, AuxiliaryWindowsShareLocalStorage) 352 { 353 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 354 [configuration _setAllowUniversalAccessFromFileURLs:YES]; 355 [configuration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]]; 356 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 357 358 auto delegate = adoptNS([[LocalStorageNavigationDelegate alloc] init]); 359 [webView setNavigationDelegate:delegate.get()]; 360 [webView setUIDelegate:delegate.get()]; 361 362 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 363 [webView loadRequest:request]; 364 365 TestWebKitAPI::Util::run(&didFinishNavigation); 366 didFinishNavigation = false; 367 368 bool finishedRunningScript = false; 369 [webView evaluateJavaScript:@"localStorage.setItem('testItem', 'Persistent item!');" completionHandler: [&] (id result, NSError *error) { 370 finishedRunningScript = true; 371 }]; 372 TestWebKitAPI::Util::run(&finishedRunningScript); 373 finishedRunningScript = false; 374 375 createdWebView = nullptr; 376 [webView evaluateJavaScript:@"open(window.location)" completionHandler: [&] (id result, NSError *error) { 377 finishedRunningScript = true; 378 }]; 379 TestWebKitAPI::Util::run(&finishedRunningScript); 380 finishedRunningScript = false; 381 382 TestWebKitAPI::Util::run(&didFinishNavigation); 383 didFinishNavigation = false; 384 385 EXPECT_TRUE(!!createdWebView); 386 387 [createdWebView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 388 NSString *value = (NSString *)result; 389 EXPECT_WK_STREQ(@"Persistent item!", value); 390 finishedRunningScript = true; 391 }]; 392 TestWebKitAPI::Util::run(&finishedRunningScript); 393 finishedRunningScript = false; 394 395 [createdWebView evaluateJavaScript:@"localStorage.setItem('testItem', 'ChangedValue');" completionHandler: [&] (id result, NSError *error) { 396 finishedRunningScript = true; 397 }]; 398 TestWebKitAPI::Util::run(&finishedRunningScript); 399 finishedRunningScript = false; 400 401 [createdWebView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 402 NSString *value = (NSString *)result; 403 EXPECT_WK_STREQ(@"ChangedValue", value); 404 finishedRunningScript = true; 405 }]; 406 TestWebKitAPI::Util::run(&finishedRunningScript); 407 finishedRunningScript = false; 408 409 [webView evaluateJavaScript:@"localStorage.getItem('testItem');" completionHandler: [&] (id result, NSError *error) { 410 NSString *value = (NSString *)result; 411 EXPECT_WK_STREQ(@"ChangedValue", value); 412 finishedRunningScript = true; 413 }]; 414 TestWebKitAPI::Util::run(&finishedRunningScript); 415 finishedRunningScript = false; 416 }
Note: See TracChangeset
for help on using the changeset viewer.