Commit Graph

57 Commits

Author SHA1 Message Date
amaitland 60303e9a2a wait for browsers to close before running test 2026-11-17 21:17:16 +10:00
amaitland a0cb0eb7de use embedded url 2026-11-17 20:13:46 +10:00
Alex Maitland 59545852a5 Make BrowserRefCount test more reliable 2026-11-17 19:08:21 +10:00
campersau 6acdcc3031 Test - Use TaskCreationOptions instead of TaskContinuationOptions for TaskCompletionSource (#4942) 2024-09-28 07:41:06 +10:00
Alex Maitland 4f8bdc5f2c OffScreen - ChromeRuntime doesn't work with LoadURL
- After switching to the Chrome bootstrap, the browser wouldn't load if you passed in an empty
  string to the constructor, we can defer loading until after another LoadUrl call is made.

Resolves #4832
2024-06-21 19:55:53 +10:00
Alex Maitland dcb9d61cb3 Tests - Renable ShouldFailWhenLoadingBadSsl
- Might just have been a transient error with badssl website
2024-05-06 16:47:08 +10:00
Alex Maitland 33dad392fb Tests - Add missing brace 2024-05-06 16:31:27 +10:00
Alex Maitland eacdd9c93c Tests - Skip failing tests with Chrome bootstrap enabled. 2024-05-06 16:30:30 +10:00
Alex Maitland 8d5790eaaf Test - ShouldWorkWhenLoadingRequestWithPostData add extra logging 2023-08-01 05:46:10 +10:00
Alex Maitland cafd378859 Test - Code Cleanup
- Start splitting tests out into own files where relevant
- Improve call ordering
- Use Assert.RaisesAsync where possible
- Classes have been renamed (Tests is now the standard suffix)

TODO: Some of the classes still need their method names changed
2023-02-17 13:53:23 +10:00
Alex Maitland a51da76ad9 OffScreen - Add useLegacyRenderHandler optional param to constructor
- Defaults to true
- For those using CaptureScreenshotAsync set to false to avoid
  creating DefaultRenderHandler
2023-01-15 11:33:08 +10:00
Alex Maitland a819fc4e4d Test - Add EvaluateScriptAsPromiseAsyncFacts
- Move tests from OffScreenBrowserBasicFacts
- Enable Cef.WaitForBrowsersToClose();
2022-09-19 16:35:45 +10:00
Alex Maitland 6713caf739 Test - Increase Cef.WaitForBrowsersToClose timeout 2022-08-09 10:18:48 +10:00
Alex Maitland 2cd1c9b5ae Core - Add Cef.WaitForBrowsersToClose(int) overload
- Allow for specifying the timeout in ms
- Update the tests to 5000ms timeout
2022-06-20 13:03:15 +10:00
Alex Maitland 15cb6d4754 Core - BrowserRefCount add some basic logging
Logs some basic information so we can see what type of ChromiumWebBrowser hasn't been closed
within as part of the xUnit tests.

* Meant for internal use and might be subject to change.
2022-05-31 15:43:34 +10:00
Alex Maitland 81178bb9ba Test - Increase BrowserRefCountDecrementedOnDispose reliability 2022-05-31 14:08:00 +10:00
Alex Maitland 787665bcfe Core - WebBrowserExtensions throw explicit ObjectDisposedException if IsDisposed
- Make it clear that the ChromiumWebBrowser instance has been disposed.
  Previously when the browser was disposed BrowserCore would be null.
  An explicit ObjectDisposedException is now thrown.
2022-05-31 10:56:13 +10:00
Alex Maitland cae407f9f1 WPF/OffScreen - Add WaitForRenderIdleAsync CancellationToken test 2022-05-30 19:22:25 +10:00
Alex Maitland b8b27f6885 WPF/OffScreen - Add WaitForRenderIdleAsync (#4080)
* WPF/OffScreen - Add WaitForRenderIdleAsync

- Task resolves when render has been idle for the specified time
- Make TaskTimeoutExtensions public (they're not extension methods as this was expected)
2022-05-30 19:11:17 +10:00
Alex Maitland 7eb6d6f3b7 OffScreen - CaptureScreenshotAsync change to Scale default
- Previously when no Scale was specified, then the previous ChromiumWebBrowser scale was used.
- Now Viewport defaults to a scale of 1, so the behaviour has been changed so the scale passed as
  the param is always used.
- Test updated

This is a minor breaking change.

Resolves #4091
2022-05-05 19:27:29 +10:00
campersau 5e16914d9a 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:03:44 +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