Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[iOS] Crash when tapping <select> element and calling window.open()
https://bugs.webkit.org/show_bug.cgi?id=229468 rdar://82122972 Reviewed by Wenson Hsieh. Source/WebKit: UIKit throws an exception when attempting to present a context menu for a view that is not in a window. One instance where this can occur in Safari is when a call to window.open() is made in response to a touch on a select element. In this scenario, the call to window.open() opens a new tab, unparenting the current webview. However, the touch also focuses the element, and WebKit attempts to present a context menu in an unparented view. To fix, guard against the case where the view is not parented, and do not attempt to present a context menu. Test: fast/forms/ios/show-select-menu-in-unparented-view-crash.html * UIProcess/ios/WKActionSheetAssistant.mm: Note that the helper method used in other classes is not used in WKActionSheetAssistant, since the hosting view is not always a WKContentView. (-[WKActionSheetAssistant showDataDetectorsUIForPositionInformation:]): (-[WKActionSheetAssistant showMediaControlsContextMenu:items:completionHandler:]): * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView presentContextMenu:atLocation:]): Added a helper method to ensure the view is parented prior to presenting a context menu. (-[WKContentView imageAnalysisGestureDidTimeOut:]): * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm: (-[WKDataListSuggestionsDropdown _showSuggestions]): * UIProcess/ios/forms/WKDateTimeInputControl.mm: (-[WKDateTimePicker showDateTimePicker]): * UIProcess/ios/forms/WKFileUploadPanel.mm: (-[WKFileUploadPanel showDocumentPickerMenu]): * UIProcess/ios/forms/WKFormSelectPicker.mm: (-[WKSelectPicker showSelectPicker]): LayoutTests: Added a test to verify a crash does not occur when tapping a <select> element and unparenting the webview. * fast/forms/ios/show-select-menu-in-unparented-view-crash-expected.txt: Added. * fast/forms/ios/show-select-menu-in-unparented-view-crash.html: Added. Canonical link: https://commits.webkit.org/240943@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281579 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
11 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
LayoutTests/fast/forms/ios/show-select-menu-in-unparented-view-crash-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This test verifies that tapping on a select element and then unparenting the webview does not result in a crash. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
42 changes: 42 additions & 0 deletions
42
LayoutTests/fast/forms/ios/show-select-menu-in-unparented-view-crash.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | ||
<script src="../../../resources/js-test.js"></script> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
</head> | ||
<body> | ||
<select id="select"> | ||
<option>January</option> | ||
<option>February</option> | ||
<option>March</option> | ||
<option>April</option> | ||
<option>May</option> | ||
<option>June</option> | ||
<option>July</option> | ||
<option>August</option> | ||
<option>September</option> | ||
<option>October</option> | ||
<option>November</option> | ||
<option>December</option> | ||
</select> | ||
</body> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
addEventListener("load", async () => { | ||
description("This test verifies that tapping on a select element and then unparenting the webview does not result in a crash."); | ||
|
||
select.addEventListener("touchstart", () => { | ||
UIHelper.removeViewFromWindow(); | ||
}); | ||
|
||
select.addEventListener("focus", async () => { | ||
await UIHelper.ensurePresentationUpdate(); | ||
finishJSTest(); | ||
}); | ||
|
||
UIHelper.activateElement(select); | ||
}); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters