146 Commits

Author SHA1 Message Date
Alex Maitland a1b5d87f06 Test - Fix IntegrationTestFacts.LoadJavaScriptBindingAsyncTaskQunitTestsSuccessfulCompletion
Add method interceptor so tests pass. Without it we get an VoidTaskResult object.
2022-01-27 16:41:29 +10:00
Alex Maitland a9ac70ee91 Test - Add IntegrationTestFacts.LoadJavaScriptBindingAsyncTaskQunitTestsSuccessfulCompletion
- Runs the AsyncTask binding tests
2022-01-27 16:17:42 +10:00
Alex Maitland 02c39917b8 Javascript Binding - IJavascriptCallbackProxy.ExecuteAsync correctly creates pending task using callback Id
- Previously a new PendingTask(TaskCompletionSource) was created using a new Id which worked when the Ids matched
  between the browser and render process. If you skipped executing a callback then the Ids would get out of sync.

Issue #3979
2022-01-27 15:23:21 +10:00
Alex Maitland ece5119e43 Test - Update HelloWorld.html to include JS so can be used for testing 2021-10-23 11:38:49 +10:00
Alex Maitland a441c1a318 Test - Attempt to log more detailed failure from JSB Tests
Currently only some of the legacy tests are failing with Chromium Site isolation enabled
2021-10-16 17:52:39 +10:00
Alex Maitland d5c74771f1 Test - Add Test to verify workaround for issue #3470 2021-04-06 13:12:44 +10:00
Alex Maitland f278d3d69a Test - Fix a couple of javascript warnings 2021-03-16 14:54:05 +10:00
Alex Maitland 9214052868 Javascript Binding - Add/Improve examples 2021-02-26 12:16:50 +10:00
Alex Maitland ede36bf009 Javascript Callback - Move Test
Move test into BindingTestsAsyncTask as build is failing.
Will run all async tests as part of build in near future.
2021-02-15 15:21:28 +10:00
Alex Maitland 6d9f214196 Javascript Callback - Add very basic support for executing a Promise
It's a manual process at this stage and requires the end user to deal to:
- Return "CefSharpDefEvalScriptRes" immediately after the promise function has been created
- Call cefSharp.sendEvalScriptResponse when the async/await (promise) processing has completed
2021-02-15 13:43:51 +10:00
Alex Maitland 151f806534 Core - Javascript Binding Cleanup
- Move TryCallMethodResult to Internals namespace
- Fix BindingTestsAsyncTask.html (mistake in javascript)
2021-01-09 13:29:32 +10:00
Alex Maitland ab8223d4b9 Core - Add IAsyncMethodInterceptor (#3296)
Core - Add IAsyncMethodInterceptor
  - Add IAsyncMethodInterceptor
    Extension of IMethodInterceptor to allow for easier evaluation of async taskScheduler
  - Add Additional unit tests
  - Add JavascriptBindingSettings.AlwaysInterceptAsynchronously for cases where you'd like all method calls to use 
    IAsyncMethodInterceptor.InterceptAsync

Follow up to PR #3291

Co-authored-by: Andrew Sampson <andrew@rainway.com>
Co-authored-by: Emily Hudson <emily33901@gmail.com>
2021-01-09 13:17:50 +10:00
Alex Maitland bc9b3d1a16 Test - Update remaining QUnit tests to async
Follow up to #3298
2020-12-16 11:26:29 +10:00
Timo Tijhof d06d5100be Example - Simplify BindObjectAsync tests with QUnit (#3298)
* Example - Update to QUnit 2.10

Follows ae41e10d71, which introduced a few references
to QUnit 2.10.

* Example - Simplify the BindObjectAsync unit tests

The `QUnit.test()` may take an async function and/or to return a Promise.
This uses JavaScript's native async/await capabilities to wait for that,
much the same way manual tracking via `assert.async()` would.
Using this can simplify the test structures by a lot.

`assert.rejects()` asserts that a promise throws an error.
`assert.throws()` asserts that a block directly throws an error.

I've also tried to use `assert.deepEqual()`. I suspect a copy
of this function was placed here directly, but I couldn't find
in the history why, so perhaps worth trying if the built-in
one now works.
2020-12-16 10:59:23 +10:00
Alex Maitland 8a367fbdc4 Refactor CefSharp.Core into CefSharp.Core.Runtime (#3311)
* Net Core - Rename CefSharp.Core.dll to CefSharp.Core.Runtime.dll

Partial rename, only Net Core, folder not renamed

* Net Core - Rename CefSharp.Core.RefAssembly to CefSharp.Core.netcore

Remove GenApi

* Core - Rename CefDragDataWrapper to DragData

Move into CefSharp.Core namespace

* WinForms/WPF/OffScreen - Migrate from GitLink command line to Nuget package

* Net Core - Refactor to have CefSharp.Core.dll contain only public Api

* Net Core - Remove CefSharp.Core.RefAssembly

* Net Core - Change CefSharp.Core.netcore output folder

* Net Core - Restructure nuget packages

* Net Core - Add Cefsharp.Core.Runtime.RefAssembly

* Net Core - Hide CLI/C++ classes from intellisense

Make sure users don't attempt to load them directly

* Rename CefSharp.Core to CefSharp.Core.Runtime

* Core - Restructure Net 4.5.2 packages to use CefSharp.Core.dll anycpu variant

Attempt to load CefSharp.Core.Runtime at runtime rather than having to use msbuild to copy the correct version

* Rename CefSharp.Core.netcore to CefSharp.Core

* WPF/WinForms/OffScreen - Change from x86/64 to AnyCPU

As they are all managed assemblies they can target AnyCPU.
Includes CefSharp.dll

* Convert RequestContextBuilder from C++ to C#

Now part of the CefSharp.Core PublicApi

* Update version number to 87.1.11

* Migrate more of the public Api to C#

* Net Core - Basic restructure complete

* Net Core - ModuleInitializer (Doesn't work yet)

* Remove direct references to BrowserSettings

* Net Core - ModuleInitializer load CefShar.Core.Runtime.dl

* Net Core - Load libcef.dll via CLR Module initializer

If no RID is specified then we can load libcef.dll using the module initializer

* Add version to CefSharp.Core

* Remove dependency on CefSharp.Core.Runtime
Rewrite common targets

* AnyCPU app.config transform

Improve AnyCPU support

* Improve Net Core 3 support
Only delete CefSharp.Core.Runtime.dll when AnyCPU

* Nuget - Add CefSharp.Core.Runtime reference when TargetFramework = NetCore

* Fix Typos

Based on #3306

* Net Core - Rename CefSharp.Core.Runtime RefAssembly source file

* Net Full - Generate CefSharp.Core.Runtime Ref Assembly

For now the powershell build script generates the .cs file based on a x86 release build.ps1
It's not possible to directly install GenApi as it requires a Sdk style project

* Net Core - Old packages copy files to required folders

* Test - Install newer .Net Compiler and set Lang Version to 7.3

* Net Core - Exclude Net 452 Runtime generated reference source

* Core - Add Refactoring TODO

* Ref Assembly - Generate source as part of build

- Move ref assembly source generate into GenerateRefAssemblySource.ps1
- Call before project build

Runs locally, see if Appveyor has a problem with the powershell script execution

* Core - Add more factory methods to create instances of managed wrappers

* Net Core - Make Initialzier properties internal

Not quite sure what the public API should look like as yet, so making internal for now.
2020-12-16 10:47:34 +10:00
Alex Maitland f2c80f54df Example - Update BindingTestsAsyncTask tests
Update the Multiple Async Download File Test to download 4 files concurrently instead of two
2020-11-27 11:17:25 +10:00
Alex Maitland 83ae9399dd Core - MethodRunnerQueue use TaskCreationOptions.HideScheduler to
To prevent subtasks from attempting to use our LimitedConcurrencyLevelTaskScheduler we need to
specify TaskCreationOptions.HideScheduler when creating the Task

Resolves #3293
2020-11-25 15:16:57 +10:00
amaitland 124490ed20 Core - Legacy Javascript Binding Integration Test
Post QUnitExecutionComplete on test completion

#2977
2020-09-16 20:31:06 +10:00
amaitland 53f15f22eb Upgrade to CEF 85.3.6+gacfac2f+chromium-85.0.4183.102 / Chromium 85.0.4183.102
- Remove CefSettings.RegisterExtension (#3184)
- Add IRenderProcessHandler.OnWebKitInitialized
- Add Cef.RegisterExtension (Browser SubProcess specific implementation)

Resolves #3184
2020-09-16 13:49:37 +10:00
amaitland 22d494b230 Net Core - Split Binding Test into Sync/Async
- In preparation for adding a Net Core Specific XUnit project file

Issue #3197
2020-07-24 20:42:14 +10:00
amaitland ae41e10d71 Core - Javascript Binding Configure Property Name
- Rename settings object to JavascriptBindingSettings
- Validate JavascriptBindingSettings.JsBindingGlobalObjectName in setter to provide immediate
  feedback
- Add FreezableBase which throws exception when frozen (we can reuse this for some other settings classes)
- Add some basic Unit Tests (More would be better)

Follow on from #3126
2020-05-30 19:28:50 +10:00
amaitland e1401e7092 Core - Ensure CachePath/RootCachePath/LocalesDirPath/BrowserSubprocessPath are absolute
CEF now requires this to be absolute, we enforce this by throwing exception if non-absolute

Resolves  #3102
2020-05-03 16:59:57 +10:00
amaitland d82370eb14 Example - Add additional popup test
Also remove unused file
2020-05-01 11:00:45 +10:00
amaitland d693ece3ca Example - Fix more home.html links 2019-12-13 19:40:35 +10:00
amaitland c26053ae22 Example - Fix broken link in Home.html 2019-12-13 18:59:43 +10:00
amaitland e438e22741 Example - Add JSB Qunit Tests for Binder UInt conversion
Issue #2906
2019-09-27 08:07:37 +10:00
amaitland f088a7c169 CefSettings - Add custom dictionary to allow setting of command line args with no value
- Updated CefExample to remove "1" values from the command line arg examples

Issue #2858
2019-09-06 13:05:50 +10:00
amaitland 209bde2c04 BindingTest.html - Reformat using editorconfig 2019-07-20 12:28:51 +10:00
Angshuman Agarwal 48eaff87dc Javascript Integration - Passing empty array in JS now maps to empty list/array instead of null (#2829)
* Set empty list instead of null

* Added QUnit Test for testing Empty Array
2019-07-20 12:17:44 +10:00
amaitland 750fc9f22e Javascript Binding - Add support for JsonString
JsonString is parsed into CefValue using the CefParseJson function
If your data is already stored in JSON then it can be parsed directly
or you can use a serializer of your choosing to turn a object into JSON
2019-07-20 12:11:43 +10:00
amaitland 0542c5138b SendProcessMessage - Remove frame/browserid from messages
Not complete or tested yet
2019-06-25 19:24:57 +10:00
Alex Maitland fe98124c9b Async JavascriptBinding - Add support for returning Task (#2771)
* Async JavascriptBinding - Add support for returning Task

Remove Parallel Task execution code from MethodRunnerQueue
Add ParallelMethodRunnerQueue
  - For the new code path the Func is executed, if the Result is a generic Task we wait for it's completion
  - If the task is not generic then we return immediately

This is only enabled when CefSharpSettings.ConcurrentTaskExecution = true;
* MethodRunnerQueue - Display error message when method returns Task
* ParallelMethodRunnerQueue - Rename to ConcurrentMethodRunnerQueue
* MethodRunnerQueue - Improve formatting of error message when method returns Task
* Async JavascriptBinding Return Task - Add Basic xUnit Test

Very quick test, needs to be refined a little. The basics are working as expected.

* Add Binding Test Async Task Example to the WPF Example menu

* Async JSB Task - Add additional tests and improve error messaging
2019-06-08 17:21:49 +10:00
Alex Maitland 1a2c8ffcb6 Add CefSharp.PostMessage (#2799)
- JavascriptMessageReceived event added to ChromiumWebBrowser/IWebBrowser
- CefSharp.PostMessage and cefSharp.postMessage added to V8Context on creation for use in Javascript
- Add PostMessageTest.html
2019-06-03 21:08:03 +10:00
amaitland 335c884b08 Javascript Callback - Add additional tests
Add Basic tests, still need some more work.
Test changes added in #2748
2019-04-26 14:17:58 +10:00
amaitland ea843f31c1 Formatting fixes
Follow up to #2691
2019-04-05 12:02:02 +10:00
João Neves 6692749728 WPF - Implement UpdateDragCursor (#2691)
* Close cefsharp subprocess if main process dies

* Implemented UpdateDragCursor

* Fixed braces position

* Added license header

* Fixed cursor flickering

* Added test

* Fixed build

* Fixed move cursor

* Fixed braces

* Simplified solution

* Fixed dropping Link effect

* Fixed encoding + Removed leftovers
2019-04-05 11:58:27 +10:00
kurtzky aaa5054d6c Added QUnit tests for DateTime serialization (#2695)
* Added QUnit tests for DateTime serialization

Related to Issue #2662
2019-03-20 21:15:50 +10:00
amaitland 72ee102bcf V8Serialization - ConvertDateTimeToCefTime convert to UTC time
BindingTest.html - Add QUnit test

Resolves #2662
2019-02-28 20:27:06 +10:00
amaitland 8e016789c9 Example - Update Home.html
Fix some mistakes
2018-10-23 12:58:36 +10:00
amaitland 62d2bb3071 CefSharp.Example/Resources/Home.html - Remove unused js file reference 2018-09-25 14:12:22 +10:00
amaitland 54c625c57b WPF - Tooltip Wrap
Wrap the tooltip content in a text block, so that it gets wrapped (was previously going off screen)

Related to #2488
2018-09-04 19:41:37 +10:00
amaitland 61f95f6893 BindingTest.html - Fix formatting
Braces on new lines
Remove blank line
2018-06-25 21:31:17 +10:00
Mark Vulfson d1b78bcbd7 Serialize any Enumerable (List<T>) type to V8 object properly (#2393)
* Serialize any Enumerable (List<T>) type to V8 object properly (Issue #2392)
Handle any enumarable, not just arrays when serializing (e.g. when calling
`IJavascriptCallback.ExecuteAsync`).
Otherwise, `System.Reflection.TargetParameterCountException` is thrown during serialization

* fixup! Serialize any Enumerable (List<T>) type to V8 object properly (Issue #2392) Handle any enumarable, not just arrays when serializing (e.g. when calling `IJavascriptCallback.ExecuteAsync`). Otherwise, `System.Reflection.TargetParameterCountException` is thrown during serialization

* fixup! fixup! Serialize any Enumerable (List<T>) type to V8 object properly (Issue #2392) Handle any enumarable, not just arrays when serializing (e.g. when calling `IJavascriptCallback.ExecuteAsync`). Otherwise, `System.Reflection.TargetParameterCountException` is thrown during serialization
2018-06-25 11:20:42 +10:00
amaitland 8f7692ae6e JSB - Add JavascriptBindingCompleteEventArgs and config options to CefSharp.BindObjectAsync
CefSharp.BindObjectAsync can now take an optional config object as first param
Include additional information when binding complete
Add option for cefSharp.bindObjectAsync (starting with lowercase latters)
Add new syntax options - not entirely complete, no variant for the options object
Add ignore cache option
2018-04-27 16:40:39 +10:00
WarWithinMe dace5d8f47 Serialize Dictionary type to V8 object (#2303)
* Serialize Dictionary type to V8 object

Handle Dictionary type, otherwise it will be treated as class/structs and cause exception.

* Make the testcase covert IDictionary interface & ensure consistent bracket style.
2018-03-22 11:00:52 +10:00
amaitland 3175968339 Fix Async JSB unable to return class
Added note about memory leak
Added Test case to validate fix
2018-03-05 14:02:59 +10:00
amaitland 4b4e568f7d Add BindingTestSingle.html
Simple test page that can be used to test cases in isolation (useful for debugging purposes)
2018-03-05 14:02:59 +10:00
amaitland df1ab21c01 ScriptedMethodsTest.html - Update to use JSB v2 CefSharp.BindObjectAsync 2018-02-07 10:16:19 +10:00
amaitland 6bcca7ac5e JSB LegacyBindingTest.html Import Property Tests
Copy the tests that were added to BindingTest.html
2018-01-30 12:38:16 +10:00
amaitland 1b00c277b8 JSB Add Caching
Bound object meta data is cached within a render process
CefSharp.IsObjectCached - JS method to test if object cached
CefSharp.RemoveObjectFromCache - JS method to remove object from cache

If a request is made for multiple objects with not all of them being cached then a IPC message is sent.
When all objects already bound return response object for consistency
FindBrowserWrapper signature change - it's really not safe to throw a managed exception in the middle of unmanaged code, changed to logging and null checking
JavascriptObjectRepository - Add All Constant - Used when All objects are requested for binding (objects can also be requested by name)

TODO: Add a JS library to improve user experience when dealing with cached objects
2018-01-30 10:16:28 +10:00