-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Fix crash closing Popup with WebView (#21923)
* [iOS] Fix crash closing Popup with WebView (#21718) * Added repro sample * Fix the issue * Added UI Test * Updated csproj * More changes * Removed sample and test * More changes * Removed unnecesary changes * Added UITest * Update Issue21846.xaml.cs * Update Issue21846Modal.xaml.cs * Update Issue21846.cs --------- Co-authored-by: Javier Suárez <[email protected]>
- Loading branch information
1 parent
9fd58d7
commit 94d4aa2
Showing
6 changed files
with
153 additions
and
9 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846.xaml
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue21846" | ||
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<ScrollView> | ||
<VerticalStackLayout | ||
Padding="30,0" | ||
Spacing="25"> | ||
<Button | ||
x:Name="TestButton" | ||
AutomationId="OpenModalButton" | ||
Text="Open" | ||
Clicked="OnButtonClicked" /> | ||
</VerticalStackLayout> | ||
</ScrollView> | ||
</ContentPage> |
22 changes: 22 additions & 0 deletions
22
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846.xaml.cs
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,22 @@ | ||
using System; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 21846, "Fix crash closing Popup with WebView", PlatformAffected.iOS)] | ||
public partial class Issue21846 : ContentPage | ||
{ | ||
public Issue21846() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
async void OnButtonClicked(object sender, System.EventArgs e) | ||
{ | ||
await Navigation.PushModalAsync(new Issue21846Modal()); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846Modal.xaml
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,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue21846Modal" | ||
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<ScrollView> | ||
<Grid | ||
RowDefinitions="*, Auto" | ||
Padding="30,0"> | ||
<WebView | ||
x:Name="TestWebView" | ||
Source="https://www.microsoft.com"/> | ||
<Button | ||
Grid.Row="1" | ||
AutomationId="CloseModalButton" | ||
Text="Close" | ||
Clicked="OnButtonClicked" /> | ||
</Grid> | ||
</ScrollView> | ||
</ContentPage> |
34 changes: 34 additions & 0 deletions
34
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21846Modal.xaml.cs
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,34 @@ | ||
using System; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class Issue21846Modal : ContentPage | ||
{ | ||
public Issue21846Modal() | ||
{ | ||
InitializeComponent(); | ||
|
||
BindingContext = this; | ||
} | ||
|
||
async void OnButtonClicked(object sender, System.EventArgs e) | ||
{ | ||
if (TestWebView is IElement visualElement) | ||
{ | ||
if (visualElement.Handler != null) | ||
{ | ||
if (visualElement.Handler is IDisposable disposableHandler) | ||
disposableHandler.Dispose(); | ||
|
||
visualElement.Handler.DisconnectHandler(); | ||
} | ||
} | ||
|
||
await Navigation.PopModalAsync(); | ||
} | ||
} | ||
} |
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,28 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue21846 : _IssuesUITest | ||
{ | ||
public Issue21846(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "Fix crash closing Popup with WebView"; | ||
|
||
[Test] | ||
[Category(UITestCategories.WebView)] | ||
public void WebViewNoCrashPopup() | ||
{ | ||
this.IgnoreIfPlatforms([TestDevice.Android, TestDevice.Windows]); | ||
|
||
App.WaitForElement("OpenModalButton"); | ||
App.Click("OpenModalButton"); | ||
|
||
App.WaitForElement("CloseModalButton"); | ||
App.Click("CloseModalButton"); | ||
} | ||
} | ||
} |
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