Commit Graph

37 Commits

Author SHA1 Message Date
campersau e31faa6ca9 OffScreen - Fix ResizeAsync with deviceScalingFactor (#3964)
* OffScreen - Fix ResizeAsync with deviceScalingFactor

* OffScreen - Fix CaptureScreenshotAsync Width / Height calculation to include X and Y

Always apply Scale changes
2022-01-18 11:04:59 +10:00
Alex Maitland d0c9adcf9d Core - Add TryGetBrowserCoreById
- Can be used to obtain an IBrowser reference by Browser Identifier (Id).
- Added a couple of basic unit tests.
2022-01-05 10:47:48 +10:00
Alex Maitland 4a07af26e9 Core - Rename WaitForBrowserInitialLoadAsync to WaitForInitialLoadAsync and simplify
- Initial intention was to have a reusable method that could be used CefSharp.Wpf.HwndHost,
  upon further deliberation I've decided to build the functionality into the ChromiumWebBrowser.Partial.cs
  and will need to duplicate the functionality in CefSharp.Wpf.HwndHost. This guarantees that the
  Task will be resolved in all cases. The previous implementation there was a theoretical change we'd
  miss subscribing to the relevant events
- Remove CancellationToken as it's not possible to cancel

Issue #3842
2021-10-28 10:31:03 +10:00
Alex Maitland 91b7514a1c WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync
Second attempt at WaitForBrowserInitialLoadAsync, includes optional
CancellationToken param.

Issue #3842
2021-10-27 13:58:57 +10:00
Alex Maitland 239372a780 Test - Rearrange Assert args 2021-10-26 13:57:27 +10:00
Alex Maitland fd78c0cffc Test - CanLoadRequestWithPostData now navigates to domain of same origin first
When Chromium Site Isolation is enabled we must first navigate to
a web page of the same origin to use LoadRequest
When Site Isolation is disabled we can navigate to any web page
https://magpcss.org/ceforum/viewtopic.php?f=10&t=18672&p=50266#p50249

Issue #2967
2021-10-14 10:11:33 +10:00
Alex Maitland 544abc68d1 Revert "WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync"
Tests started failing so will revisit later.

This reverts commit 08e5140060.
2021-10-11 10:14:31 +10:00
Alex Maitland 08e5140060 WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync
Change all the tests to use WaitForBrowserInitialLoadAsync instead of LoadUrlAsync
as LoadUrlAsync will require a Url as part of #3842
2021-10-10 14:41:04 +10:00
Alex Maitland a3504aa5ad Tests - Add CanEvaluateScriptInParallel 2021-09-25 11:01:43 +10:00
Alex Maitland fa2b6e22e3 Test - Rewrite test case to use Theory with Inline data
- Use inline data
- Move test into OffScreenBrowserBasicFacts as it's not actually javascript binding
  at a later point all the tests should be rearranged so they're  not just all lumped into OffScreenBrowserBasicFacts

Issue  #3808
2021-09-16 10:13:33 +10:00
Alex Maitland 4a20b19e6b Test - Minor cleanup 2021-07-05 11:16:25 +10:00
Alex Maitland d842a2583a Test - CanLoadExpiredBadSsl can now validate CefErrorCode
With PR https://bitbucket.org/chromiumembedded/cef/pull-requests/373
it's possible  to get the certificate error in OnLoadError so now
LoadUrlAsync returns the correct CefErrorCode
2021-06-18 16:08:51 +10:00
Alex Maitland 4e16f3b16d Enhancement - Add LoadUrlAsync (#3596)
Core - Add LoadUrlAsync

- Add IWebBrowser.LoadUrlAsync
- Add LoadUrlAsyncResponse
- Update unit tests to use new method
-  Add static method to allow for CefSharp.Wpf.HwndHost to share the same code.
2021-06-04 13:29:40 +10:00
Alex Maitland 96117f9a47 OffScreen - Add CreateBrowserAsync
Issue #3594
2021-06-02 19:42:04 +10:00
Alex Maitland bec06b2495 Add Fluent DownloadHandler (#3576)
* Core - Add Fluent DownloadHandler implementation and IFrame.DownloadUrlAsync

Resolves #3550
2021-06-01 13:34:21 +10:00
Alex Maitland e0dab5a37e Test - Add OffScreen CanLoadMultipleBrowserInstancesSequentially
Create/Dispose of 1000 OffScreen ChromiumWebBrowser instances

Issue #3552
2021-05-14 13:55:27 +10:00
Alex Maitland f91001135a Core - Add IRequestContext.SetProxyAsync
Can be called on any Thread to change the proxy at runtime
2021-04-17 12:13:07 +10:00
Alex Maitland 497e75c267 Test - Add CanLoadRequestWithPostData test 2021-01-15 13:40:37 +10:00
pgodwin b8a36411ce Add async to EvaluateScriptAsPromiseAsync and tests (#3314)
Co-authored-by: Peter Godwin <peter.godwin@health.qld.gov.au>
2020-12-11 13:01:27 +10:00
Alex Maitland e213f37285 Core - EvaluateScriptAsPromiseAsync not working when JavascriptBindingApiGlobalObjectName specified
Resolves #3281
2020-11-14 12:07:38 +10:00
amaitland 841156c8ee Test - Add CanEvaluateScriptAsPromiseAsyncReturnObject
Promise return complex object

Issue #3251
2020-10-20 07:18:28 +10:00
Alex Maitland 3eca8bdba6 Enhancement - Simplify Setting of RequestContext Proxy (#3250)
Core - Simplify Setting of Proxy for new RequestContext

- Throw exception if requestContext.CanSetPreference returns false.
Proxy likely set via command line args.
- Add IRequestContext.SetPreferenceAsync
-  Test - Add SelfHosted Proxy
Use Titanium.Web.Proxy to self host a proxy for testing proxy settings
Only run Proxy Tests when run locally
- Add RequestContext Builder Fluent API
2020-10-13 13:40:46 +10:00
Alex Maitland fd46a4c145 Core - Add EvaluateScriptAsPromiseAsync (#3251)
- Add useImmediatelyInvokedFuncExpression param to EvaluateScriptAsync which wraps the script in an IIFE
  with the cefSharpInternalCallbackId variable defined in scope to allow for deferred completion
- Wrap script in Immediately Invoked Function Expression and call promise.resolve to guarantee a promise.
- Return 'CefSharpDefEvalScriptRes' as the result of the js function to defer execution of the callback
- Call newly added cefSharp.sendEvalScriptResponse method in javascript when promise has been resolved/rejected

This is built up of a few parts and can technically be used by the new user to defer the response until they are ready.
Just return `'CefSharpDefEvalScriptRes'` and manually call cefSharp.sendEvalScriptResponse using the cefSharpInternalCallbackId
variable which is injected into the script execution (wrapped in an IIFE to limit scope)
2020-10-06 15:19:37 +10:00
amaitland f11785e44b Core - Fix some compiler warnings 2020-08-18 18:08:09 +10:00
amaitland 1af1065f03 Net Core - Add XUnit Test Project
Issue #3197
2020-07-24 21:07:29 +10:00
campersau 1e3b1c6305 add test for binding object multiple times (#3195)
see 4b2fe1e0d7
2020-07-23 05:31:05 +10:00
amaitland 3ba91f5798 Test - OffScreenBrowserBasicFacts remove assert
It's possible that BrowserRefCounter.Instance.Count is 0 after
we Dispose, so we'll update our test to make sure we have at most
one instance, and it's fine we if have 0
2020-05-30 19:28:51 +10:00
amaitland b86a3ac59a Tests - Add OffScreenBrowserBasicFacts.CanExecuteJavascriptInMainFrameAfterNavigatingToDifferentOrigin
Confirm CanExecuteJavascriptInMainFrame is true after navigating to a different origin

Resolves #3021
2020-05-19 08:23:47 +10:00
amaitland 7100c3d0ec Core - Add Cef.WaitForBrowsersToClose helper function
- Add BrowserRefCounter to increment/decrement CefBrowser instance creation
- Add Cef.WaitForBrowsersToClose to dispose of all browser instances and call WaitForBrowsersToClose

Before calling CefShutdown it's important that CEF has finished closing/disposing of all the CefBrowser instances.
If you call CefShutdown before this has finished then you can get the error
"Check failed: !IsCefShutdown(). Object reference incorrectly held at CefShutdown".
This is more a problem when using MultiThreadedMessageLoop where CEF close/dispose happens on a different thread.
Calling ChromiumWebBrowser.Dispose will start to free the resources, CEF internally executes code on it's own thread.

#3047
2020-02-14 19:39:12 +10:00
amaitland ec8d58bcec Core - Rename CefSharp.Internals.CefUrlRequestWrapper to CefSharp.UrlRequest
- Make public
- Add public constructor
2019-11-23 15:11:14 +10:00
amaitland 4a79b75726 IUrlRequest - Minor formatting and xml doc improvements
- Formatting
- Xml doc improvements
- Rewrite test case to run continuation async

Issue #2881
2019-10-01 20:44:46 +10:00
David M Iserovich a843407dab Core - Add IURLRequest #1721 (#2881)
* Core - Add IURLRequest #1721

Add IURLRequest, IURLRequestClient, and GetURLRequest to IFrame

* Rename URL classes to Url, add xmldoc and licenses

* Add UrlRequestClient to CefSharp.Example, more minor cleanup

* Getters

* Rebase tweaks

* Fix filenames, remove unused

* Use UnmanagedMemoryStream instead of byte array for IUrlRequestClient.OnDownloadData
2019-10-01 20:11:10 +10:00
Chris bef5dd37c4 Maintenance - Fixed formatting, file encoding, and copyright year (#2504)
* Applied formatting

* Fixed file encoding + Updated copyright year

* Updated License

* Fixed more file encoding

* Copyright notice now shows the year the file was created
2018-09-10 10:41:13 +10:00
amaitland 431fe76a39 WebBrowserExtensions - Add ExecuteScriptAsyncEncodeString to allow for custom encoding of string params used with ExecuteScriptAsync overload
Also rename test case and add comment

Follow up to #2340
2018-04-03 14:12:10 +10:00
Garr Godfrey 7e30861bc2 Encode string parameters to pass unchanged.
enter the commit message for your changes. Lines starting
2018-03-28 22:28:01 -07:00
amaitland 2b3508d60a OffScreen/OffScreenBrowserBasicFacts- Add CrossSiteNavigationJavascriptBinding Test case
Very basic, little crude, passing though
Still having some problems with Xunit and shutting down on the correct thread.
2018-01-22 13:06:09 +10:00
amaitland 9407ba1828 Due to limitations of VC++ we must run our tests in the default appdomain, it's possible to use xunit for testing.
Readd CefSharp.Test.csproj to solution
Add some very basic unit tests using xunit, DisableTestParallelization, Set xunit.appDomain to denied in app.config to disable using appdomains (https://xunit.github.io/docs/configuring-with-xml.html)
Add xunit vs test running packages, using 2.2.0 version as 2.3.0 was throwing an exception similar to https://github.com/xunit/xunit/issues/1514
TODO: Take a look at https://github.com/NuGet/NuGetGallery/tree/master/tests/NuGetGallery.Facts for some ideas on structuring xunit tests (look at implementing Theory)

NOTE: I am not providing this as a definitive set of tests, it's simply here to get someone else started in creating tests as it appears people have trouble dealing with AppDomain problem
Only includes Tests for the OffScreen version at this stage.
2017-10-25 10:44:38 +10:00