Changeset 255826 in webkit
- Timestamp:
- Feb 5, 2020 10:08:54 AM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r255813 r255826 1 2020-02-05 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION(r255595): page not closed after beforeunload handler returns true 4 https://bugs.webkit.org/show_bug.cgi?id=207189 5 <rdar://problem/59149593> 6 7 Reviewed by Youenn Fablet. 8 9 Add API test coverage for fix landed in r255677. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: 12 (-[SlowBeforeUnloadPromptUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]): 13 (TEST): 14 1 15 2020-02-05 Jonathan Bedard <jbedard@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm
r255595 r255826 146 146 #if PLATFORM(MAC) 147 147 148 static bool didRejectTryClose = false; 148 static bool shouldRejectClosingViaPrompt = false; 149 static bool didRespondToPrompt = false; 149 150 150 151 @interface SlowBeforeUnloadPromptUIDelegate : NSObject <WKUIDelegate> … … 156 157 { 157 158 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ 158 completionHandler( NO);159 didRe jectTryClose= true;159 completionHandler(shouldRejectClosingViaPrompt ? NO : YES); 160 didRespondToPrompt = true; 160 161 }); 161 162 } … … 168 169 @end 169 170 170 TEST(WebKit, SlowBeforeUnloadPrompt )171 TEST(WebKit, SlowBeforeUnloadPromptReject) 171 172 { 172 173 auto slowBeforeUnloadPromptUIDelegate = adoptNS([[SlowBeforeUnloadPromptUIDelegate alloc] init]); … … 182 183 TestWebKitAPI::Util::spinRunLoop(10); 183 184 185 shouldRejectClosingViaPrompt = true; 184 186 [webView _tryClose]; 185 187 186 TestWebKitAPI::Util::run(&didRe jectTryClose);188 TestWebKitAPI::Util::run(&didRespondToPrompt); 187 189 EXPECT_FALSE([webView _isClosed]); 188 190 189 191 TestWebKitAPI::Util::sleep(0.1); 190 192 EXPECT_FALSE([webView _isClosed]); 193 } 194 195 TEST(WebKit, SlowBeforeUnloadPromptAllow) 196 { 197 auto slowBeforeUnloadPromptUIDelegate = adoptNS([[SlowBeforeUnloadPromptUIDelegate alloc] init]); 198 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); 199 [webView setUIDelegate:slowBeforeUnloadPromptUIDelegate.get()]; 200 [webView synchronouslyLoadTestPageNamed:@"beforeunload"]; 201 202 TestWebKitAPI::Util::spinRunLoop(10); 203 204 // Need a user gesture on the page before being allowed to show the beforeunload prompt. 205 [webView sendClicksAtPoint:NSMakePoint(5, 5) numberOfClicks:1]; 206 207 TestWebKitAPI::Util::spinRunLoop(10); 208 209 shouldRejectClosingViaPrompt = false; 210 [webView _tryClose]; 211 212 TestWebKitAPI::Util::run(&didRespondToPrompt); 213 214 while (![webView _isClosed]) 215 TestWebKitAPI::Util::sleep(0.1); 191 216 } 192 217
Note: See TracChangeset
for help on using the changeset viewer.