-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix for Transparent Background Color not applied to WebView #28804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
29842d6
fixed webview backgroundcolor issue
Tamilarasan-Paranthaman 9d72911
Test script changes
Tamilarasan-Paranthaman 7e21ab3
test sample changes
Tamilarasan-Paranthaman bcbcc0d
Test script changes
Tamilarasan-Paranthaman db63d1a
Added Mac snapshots
Tamilarasan-Paranthaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+40 KB
...ests/TestCases.Android.Tests/snapshots/android/VerifyWebViewBackgroundColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.2 KB
...stCases.Android.Tests/snapshots/android/VerifyWebViewDynamicBackgroundColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,48 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 28714, "[iOS] WebView BackgroundColor is not setting correctly", PlatformAffected.iOS)] | ||
public partial class Issue28714 : ContentPage | ||
{ | ||
public Issue28714() | ||
{ | ||
BackgroundColor = Colors.YellowGreen; | ||
var verticalStackLayout = new VerticalStackLayout(); | ||
verticalStackLayout.Spacing = 20; | ||
|
||
var webView = new WebView() | ||
{ | ||
HeightRequest = 300, | ||
WidthRequest = 400, | ||
BackgroundColor = Colors.Transparent, | ||
Source = new HtmlWebViewSource | ||
{ | ||
Html = @" | ||
<!DOCTYPE html> | ||
<html lang='en'> | ||
<body> | ||
<h1>Welcome to WebView</h1> | ||
<p id='message'></p> | ||
</body> | ||
</html>" | ||
} | ||
|
||
}; | ||
|
||
var button = new Button | ||
{ | ||
Text = "Change WebView BackgroundColor", | ||
AutomationId = "button" | ||
}; | ||
button.Clicked += (s, e) => | ||
{ | ||
webView.BackgroundColor = Colors.Red; | ||
}; | ||
|
||
verticalStackLayout.Add(button); | ||
verticalStackLayout.Add(webView); | ||
|
||
|
||
|
||
Content = verticalStackLayout; | ||
} | ||
} |
Binary file added
BIN
+20.8 KB
...ntrols/tests/TestCases.Mac.Tests/snapshots/mac/VerifyWebViewBackgroundColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.9 KB
...tests/TestCases.Mac.Tests/snapshots/mac/VerifyWebViewDynamicBackgroundColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28714.cs
This file contains hidden or 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,32 @@ | ||
#if TEST_FAILS_ON_WINDOWS // The transparent background color is not working on Windows, refer to https://github.com/microsoft/microsoft-ui-xaml/issues/6527 | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
public class Issue28714 : _IssuesUITest | ||
{ | ||
public override string Issue => "[iOS] WebView BackgroundColor is not setting correctly"; | ||
|
||
public Issue28714(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
[Test, Order(1)] | ||
[Category(UITestCategories.WebView)] | ||
public void VerifyWebViewBackgroundColor() | ||
Tamilarasan-Paranthaman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
App.WaitForElement("button"); | ||
VerifyScreenshot(); | ||
} | ||
|
||
[Test, Order(2)] | ||
[Category(UITestCategories.WebView)] | ||
public void VerifyWebViewDynamicBackgroundColor() | ||
{ | ||
App.WaitForElement("button"); | ||
App.Tap("button"); | ||
VerifyScreenshot(); | ||
} | ||
} | ||
#endif |
Binary file added
BIN
+32.2 KB
...ntrols/tests/TestCases.iOS.Tests/snapshots/ios/VerifyWebViewBackgroundColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.5 KB
...tests/TestCases.iOS.Tests/snapshots/ios/VerifyWebViewDynamicBackgroundColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AutomationId 'button' is quite generic and may not be unique across the app; consider using a more descriptive and unique identifier (e.g., 'Issue28714ChangeBackgroundButton') to prevent potential clashes in UI testing.
Copilot uses AI. Check for mistakes.