Changeset 244251 in webkit
- Timestamp:
- Apr 14, 2019 9:47:39 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r244249 r244251 1 2019-04-14 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 API test WKAttachmentTests.AddAttachmentToConnectedImageElement is a flaky failure on Mac Release builds 4 https://bugs.webkit.org/show_bug.cgi?id=196905 5 <rdar://problem/49886096> 6 7 Reviewed by Tim Horton. 8 9 This flaky test exercises a race condition between when attachment insertion updates are dispatched from the web 10 process to the UI process, and when script is executed via -[WKWebView evaluateJavaScript:completionHandler:]. 11 Since attachment insertion and removal updates from the web process to the UI process are scheduled on a zero- 12 delay timer, we end up with this sequence of events in the problematic (failure) case: 13 14 (a) [UI] Run script #1 (which calls `HTMLAttachmentElement.getAttachmentIdentifier`) 15 ...IPC from UI to web process... 16 (b) [Web] Evaluate script #1 in the web process, which schedules attachment updates on a zero-delay timer 17 ...IPC from web to UI process... 18 (c) [UI] Invoke completion handler for script #1 19 (d) [UI] Run script #2 (which calls `document.querySelector('img').attachmentIdentifier`) 20 ...IPC from UI to web process... 21 (e) [Web] Evaluate script #2 in the web process 22 (f) [Web] Zero-delay timer fires and dispatches attachment updates to the UI process 23 24 ...which means that script #2 will complete before the UI process has received the attachment updates sent in 25 step (f). However, in the case where the flaky test succeeds, the zero-delay timer in (f) fires *before* script 26 #2 is run in step (e). 27 28 This patch fixes the flaky test by waiting until attachment insertion updates are guaranteed to be received in 29 the UI process by waiting on a script message posted by the web process, after attachment updates are 30 dispatched. 31 32 * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: 33 (TestWebKitAPI::TEST): 34 1 35 2019-04-14 Aakash Jain <aakash_jain@apple.com> 2 36 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
r244249 r244251 1347 1347 } 1348 1348 1349 TEST(WKAttachmentTests, DISABLED_AddAttachmentToConnectedImageElement)1349 TEST(WKAttachmentTests, AddAttachmentToConnectedImageElement) 1350 1350 { 1351 1351 auto webView = webViewForTestingAttachments(); 1352 1352 [webView _synchronouslyExecuteEditCommand:@"InsertHTML" argument:@"<img></img>"]; 1353 1353 1354 __block bool doneWaitingForAttachmentInsertion = false; 1355 [webView performAfterReceivingMessage:@"inserted" action:^{ 1356 doneWaitingForAttachmentInsertion = true; 1357 }]; 1358 1359 const char *scriptForEnsuringAttachmentIdentifier = \ 1360 "const identifier = HTMLAttachmentElement.getAttachmentIdentifier(document.querySelector('img'));" 1361 "setTimeout(() => webkit.messageHandlers.testHandler.postMessage('inserted'), 0);" 1362 "identifier"; 1363 1354 1364 ObserveAttachmentUpdatesForScope observer(webView.get()); 1355 NSString *attachmentIdentifier = [webView stringByEvaluatingJavaScript:@ "HTMLAttachmentElement.getAttachmentIdentifier(document.querySelector('img'))"];1365 NSString *attachmentIdentifier = [webView stringByEvaluatingJavaScript:@(scriptForEnsuringAttachmentIdentifier)]; 1356 1366 auto attachment = retainPtr([webView _attachmentForIdentifier:attachmentIdentifier]); 1357 1367 EXPECT_WK_STREQ(attachmentIdentifier, [attachment uniqueIdentifier]); 1358 1368 EXPECT_WK_STREQ(attachmentIdentifier, [webView stringByEvaluatingJavaScript:@"document.querySelector('img').attachmentIdentifier"]); 1369 Util::run(&doneWaitingForAttachmentInsertion); 1359 1370 observer.expectAttachmentUpdates(@[ ], @[ attachment.get() ]); 1360 1371
Note: See TracChangeset
for help on using the changeset viewer.