Skip to content

Commit

Permalink
Make WkWebViewRenderer default for iOS WebView (xamarin#7367)
Browse files Browse the repository at this point in the history
* Make WkWebViewRenderer default for iOS

* Update AssemblyInfo.cs

* Update Xamarin.Forms.Platform.cs

* Revert "Update AssemblyInfo.cs"

This reverts commit ca0c034.

* Fix test 26993 iOS

* Update Bugzilla26993.cs
  • Loading branch information
jfversluis authored and alanag13 committed Oct 20, 2019
1 parent cbc3f5f commit 42c6ebb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Stubs/Xamarin.Forms.Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ internal class _CarouselViewRenderer { }
[RenderWith (typeof (SliderRenderer))]
internal class _SliderRenderer { }

[RenderWith (typeof (WebViewRenderer))]
#if __IOS__
[RenderWith (typeof (WkWebViewRenderer))]
internal class _WebViewRenderer { }
#else
[RenderWith(typeof(WebViewRenderer))]
internal class _WebViewRenderer { }
#endif

[RenderWith (typeof (SearchBarRenderer))]
internal class _SearchBarRenderer { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ protected override void Dispose(bool disposing)
}
}

public class PerformanceTrackingWebView : WebViewRenderer, IDrawnObservable
public class PerformanceTrackingWebView : WkWebViewRenderer, IDrawnObservable
{
readonly SubviewWatcher<PerformanceTrackingWebView> _watcher;
int _Drawn;
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.ControlGallery.iOS/local.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<body>
<h1 id="#LocalHtmlPage">Xamarin.Forms</h1>
<p>This is a local iOS Html page</p>
<a href="https://www.google.com">Go to Google</a>
<a id="#LocalHtmlPageLink" href="https://www.google.com">Go to Google</a>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Xamarin.Forms.CustomAttributes;
using System.Collections.Generic;
using Xamarin.Forms.Internals;
using System.Linq;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
Expand Down Expand Up @@ -101,19 +102,33 @@ public void Bugzilla26993Test()
{
RunningApp.Screenshot("I am at BZ26993");

#if __IOS__
RunningApp.WaitForElement(q => q.Class("WKWebView"), postTimeout: TimeSpan.FromSeconds(5));

RunningApp.Query(q => q.Class("WKWebView").Index(0).InvokeJS("document.getElementById('LinkID0').click()"));
RunningApp.Screenshot("Load local HTML");

RunningApp.WaitForNoElement(q => q.Class("WKWebView").Css("#LinkID0"));
UITest.Queries.AppWebResult[] newElem =
RunningApp.QueryUntilPresent(() => RunningApp.Query(q => q.Class("WKWebView").Css("a")));

Assert.AreEqual("#LocalHtmlPageLink", newElem[0].Id);
#elif __ANDROID__
RunningApp.WaitForElement(q => q.WebView(0).Css("#CellID0"));
RunningApp.Tap(q => q.WebView(0).Css("#LinkID0"));

RunningApp.Screenshot("Load local HTML");

RunningApp.WaitForNoElement(q => q.WebView(0).Css("#LinkID0"));

UITest.Queries.AppWebResult[] newElem =
RunningApp.QueryUntilPresent(() => RunningApp.Query(q => q.WebView(0).Css("h1")));

Assert.AreEqual("#LocalHtmlPage", newElem[0].Id);
#endif

RunningApp.Screenshot("I see the Label");
}
#endif
}
}
}
}
1 change: 1 addition & 0 deletions Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Xamarin.Forms.Platform.iOS
{
[Obsolete("WebViewRenderer is obsolete as of 4.4.0. Please use the WkWebViewRenderer instead.")]
public class WebViewRenderer : UIWebView, IVisualElementRenderer, IWebViewDelegate, IEffectControlProvider, ITabStop
{
EventTracker _events;
Expand Down

0 comments on commit 42c6ebb

Please sign in to comment.