Changeset 238165 in webkit
- Timestamp:
- Nov 13, 2018 10:14:58 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r238158 r238165 1 2018-11-13 Ryosuke Niwa <rniwa@webkit.org> 2 3 WebKit.GeolocationTransitionToLowAccuracy API crashes when enabling PSON 4 https://bugs.webkit.org/show_bug.cgi?id=191616 5 6 Reviewed by Chris Dumez. 7 8 The crash was caused by WKView in autorelease pool invoking stopUpdatingCallback after 9 GeolocationTransitionToLowAccuracyStateTracker in the stack had been destroyed, 10 resulting in the use-after-free. 11 12 Made the tests more robust by clearing geolocation provider before exiting each test 13 since we can't really prevent WKView from entering an autorelease pool. 14 15 Also made WebKit.GeolocationTransitionToLowAccuracy wait for the success callback 16 instead of simply the end of the navigation so that the test would continue to work 17 even if a web content process was created for the second web view (lowAccuracyWebView) 18 19 * TestWebKitAPI/Tests/WebKit/Geolocation.cpp: 20 (TestWebKitAPI::setupGeolocationProvider): Moved "*" to match the WebKit coding style guideline. 21 (TestWebKitAPI::clearGeolocationProvider): Added. 22 (TestWebKitAPI::runJavaScriptAlert): Added. 23 (TestWebKitAPI::didFinishNavigation): Deleted. 24 * TestWebKitAPI/Tests/WebKit/geolocationWatchPosition.html: 25 1 26 2018-11-13 Chris Dumez <cdumez@apple.com> 2 27 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/Geolocation.cpp
r235117 r238165 105 105 } 106 106 107 void setupGeolocationProvider(WKContextRef context, void *clientInfo)107 void setupGeolocationProvider(WKContextRef context, void* clientInfo) 108 108 { 109 109 WKGeolocationProviderV1 providerCallback; … … 118 118 WKGeolocationManagerSetProvider(WKContextGetGeolocationManager(context), &providerCallback.base); 119 119 } 120 121 void clearGeolocationProvider(WKContextRef context) 122 { 123 WKGeolocationManagerSetProvider(WKContextGetGeolocationManager(context), nullptr); 124 } 120 125 121 126 void setupView(PlatformWebView& webView) … … 169 174 170 175 Util::run(&stateTracker.finished); 176 clearGeolocationProvider(context.get()); 171 177 } 172 178 … … 210 216 211 217 Util::run(&stateTracker.finished); 218 clearGeolocationProvider(context.get()); 212 219 } 213 220 … … 273 280 WKPageLoadURL(lowAccuracyWebView.page(), resetUrl.get()); 274 281 Util::run(&stateTracker.finished); 282 283 clearGeolocationProvider(context.get()); 275 284 } 276 285 … … 308 317 }; 309 318 310 static void didFinishNavigation(WKPageRef page, WKNavigationRef, WKTypeRef userData, const void* clientInfo)319 static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo) 311 320 { 312 321 *static_cast<bool*>(const_cast<void*>(clientInfo)) = true; … … 316 325 { 317 326 WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); 318 WKContextSetMaximumNumberOfProcesses(context.get(), 1);319 327 320 328 GeolocationTransitionToLowAccuracyStateTracker stateTracker; … … 332 340 bool finishedSecondStep = false; 333 341 334 WKPageNavigationClientV0 loaderClient; 335 memset(&loaderClient, 0, sizeof(loaderClient)); 336 337 loaderClient.base.version = 0; 338 loaderClient.base.clientInfo = &finishedSecondStep; 339 loaderClient.didFinishNavigation = didFinishNavigation; 340 341 WKPageSetPageNavigationClient(lowAccuracyWebView.page(), &loaderClient.base); 342 WKPageUIClientV2 uiClient; 343 memset(&uiClient, 0, sizeof(uiClient)); 344 uiClient.base.version = 2; 345 uiClient.base.clientInfo = &finishedSecondStep; 346 uiClient.decidePolicyForGeolocationPermissionRequest = decidePolicyForGeolocationPermissionRequestCallBack; 347 uiClient.runJavaScriptAlert = runJavaScriptAlert; 348 WKPageSetPageUIClient(lowAccuracyWebView.page(), &uiClient.base); 342 349 343 350 WKRetainPtr<WKURLRef> lowAccuracyURL(AdoptWK, Util::createURLForResource("geolocationWatchPosition", "html")); … … 347 354 WKRetainPtr<WKURLRef> resetUrl = adoptWK(WKURLCreateWithUTF8CString("about:blank")); 348 355 WKPageLoadURL(highAccuracyWebView.page(), resetUrl.get()); 356 349 357 Util::run(&stateTracker.disabledHighAccuracy); 358 350 359 WKPageLoadURL(lowAccuracyWebView.page(), resetUrl.get()); 351 360 Util::run(&stateTracker.finished); 361 362 clearGeolocationProvider(context.get()); 352 363 } 353 364 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/geolocationWatchPosition.html
r158689 r238165 1 1 <script> 2 navigator.geolocation.watchPosition(function() { });2 navigator.geolocation.watchPosition(function() { setTimeout(() => alert("SUCCESS"), 0); }, function() { setTimeout(() => alert("FAIL"), 0); }, {timeout: 100}); 3 3 </script>
Note: See TracChangeset
for help on using the changeset viewer.