45 Commits

Author SHA1 Message Date
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 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
amaitland 2b49105b6f JSB - Fix bug where properties weren't being analysed for sync bound objects
Added test case
Reordered method to make it more logical, used named properties so it's clear what's being set.
Add TODO for unresolved object event
2018-01-29 10:15:01 +10:00
Alex Maitland 9b01b69d2f Implement Javascript Binding v2 (#2247)
* JSB Rewrite - Add CefSharp.RegisterBoundObject javascript method

To get around the problem of IPC timing, I've reversed the communication, now it's the render process requesting
the bound objects, the implementation is incomplete at this stage, more just a basic proof of concept

Rewrite BindingTest.html using QUnit
One of the tests doesn't map correctly as it requires def user interaction

TODO:

- Get objects by name
- Rename Messages.h values that relate to this change so they are more descriptive
- Better error handling
- Caching of objects within a render process
- Investigate global context options, don't think it's possible to call an async method directly in the global context

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB Improve Request/Response message names

* BindingTest.html - Output stress test results

* Remove JavascriptRootObject was leftover from time we used WCF to transmit objects

* JavascriptObjectRepository - Objects are now sent in the same list with an IsAsync flag

Separation when sending over IPC with two unique lists isn't necessary

* JavascriptObjectRepository - Return objects by name or return all by default

Untabify CefAppUnmanagedWrapper.cpp
Add minor comment to CefBrowserWrapper for a reminder that we use Frame Identifier as dictionary key

* Add //TODO: JSB comments for work that's left to be done

Ideally within a render process we cache bound objects once they've been communicated,
It would also be nice to make multiple binding requests so objects can later be added dynamically

* JSB Allow multiple calls to CefSharp.RegisterBoundObject

Update BindingTest.html to name two distinct calls to different bound objects

* JSB - Add some notes about caching, no working implementation yet

* JSB - Dynamically Register object on Request

* JSB Add ability to unbind an object and rename RegisterBoundObject to BindObjectAsync

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB BindObjectAsync - if objects already bound then return false

* JSB - Ignore Indexer properties

Were previously throwing an exception

* JSB - Add LegacyJavascriptBindingEnabled option so preserve existing behaviour

This is only useful for SPA application and those that only navigate to pages
hosting within a single domain. Any sort of cross-site navigation and a new
render process will be spawned and objects won't be bound automatically
(You can use the new methods to request they're bound yourself, at least in theory,
more testing required on this)

* Add LegacyBindingTest.html

Current disabled by default. To enable uncomment CefSharpSettings.LegacyJavascriptBindingEnabled = true;
in CefExample.cs

* RegisterJsObject and RegisterAsyncJsObject can now only be used when CefSharpSettings.LegacyJavascriptBindingEnabled = true

See https://github.com/cefsharp/CefSharp/issues/2246 for details
2018-01-22 10:24:25 +10:00
amaitland 67b8b038af Untabify
Follow up to #2218
2018-01-18 11:51:09 +10:00
João Neves b1b8f43859 Dont discard null Values from arrays (#2218)
* Don't discard arrays that contain null values
* Revert unintended change in this branch
* Added qunit test
* Code review and added new tests
2018-01-18 11:46:58 +10:00
amaitland c303e1ca0f JSB - Add support for async methods to return classes
Structs and classes can now be returned from an async method
Properties and fields are supported now. The returned class/struct is readonly effectively, no updates will be sent to the bound object.

Just to clarify this is only for objects bound using RegisterAsyncJsObject
2018-01-08 15:12:52 +10:00
amaitland 751b8366c5 BindingTest.html - Rewrite using QUnit
Rewrite the tests using the QUnit framework, makes for much nicer presentation and should be easier to maintain them, also verifies tests completed successfully.
Tests are wrapped in an anon closure, will be used later for some JSB changes.
2018-01-08 14:45:37 +10:00
amaitland 7a0b06ad0b JSB Add support for dynamic keyword (using ExpandoObject)
As ExpandoObject implements IDictionary we can use it interchangeable with only minor breaking changes.
Those expecting Dictionary<string, object> should change to IDictionary<string, object> or ExpandoObject for their param types
This will also impact anyone who has implemented their own custom IBinder
I'd suggest changing the type checking from explicitly checking Dictionary<string, object> to use Type.IsAssignableFrom or another method of comparison
DefaultBinder binder has been updated to accommodate ExpandoObject (now being returned by ObjectsSerialization.cpp)
Add new async binding for testing new assignment method
Rewrite some of the async bound object tests to use await and let - modernize them
2017-12-21 13:00:36 +10:00
Per Lundberg 8dd46377be Fixed typos + whitespace cleanups. 2017-11-28 00:07:47 +02:00
jankurianski 65808ae8a4 Fix formatting in BindingTest.html 2017-10-24 09:52:43 +11:00
ieremyashev f029a22f45 Fix return value serialization for async JS bindings (#2167) 2017-10-24 09:48:58 +11:00
amaitland 504d04dc43 Include FindReplaceMultiResponseFilter in example project, update it's copyright year and tweak it's formatting 2017-05-08 16:02:46 +10:00
João Neves bc83d6c247 Allow calling managed methods from objects bound with RegisterAsyncJsObject that return arrays of structs (#1981)
* Fixed problem when calling CefV8Value::CreateArray. Needs prior call to V8 context enter
* Call callback dispose in case of failure
* Support serialization of struct arrays to JS side
* Fixed formatting
2017-03-13 21:37:55 +10:00
Alex Maitland d4feffb554 Feature - Add IBinder (#1749)
* Add basic ModelBinding which was imported from NancyFx framework - more can be stripped out that's unused

* Add IBinder as a param when registering an object for binding
Binding is disabled by default

* Add license and remove unused using statements

* Make bind method virtual to allow for overriding
Make methods protected

* Add very basic collection support - only primitive types supported for now.
Remove unused exceptions

* Support binding a list of sub objects

* Add null check for null params

* Add BindingOptions class - remove binder and CamelCaseJavascriptNames properties - allow for additional options in the future
Breaking change.

* Add support for List<object> binding type
2016-07-20 13:38:24 +10:00
amaitland c8f6017fa5 Change TestCallbackFromObject to use new DynamicDictionary helper class 2016-07-06 11:06:00 +10:00
tuxan 2f89c530ba Added support to use object parameters with anonymous function callback inside as parameter of bound functions. 2016-06-30 18:17:39 -04:00
amaitland c9944c981a Split paramArray and missing arg logic out into two if statements. Previously null was being replaced by Type.Missing.
Two seperate if statement branches allows for a method that has options params and a param array

Resolve #1673
2016-04-29 18:10:43 +10:00
amaitland 669404f74c Change new paramAray test methods in BindingTest.html to execute immediately (same as all the majority)
Revert changes to NuGet.config
Remove unused using statement from ScriptedMethodsBoundObject
Rename JavascriptMethod.Parameters to just JavascriptMethod.Parameters (it's in the context of the method so naming was redundant)
Pre compute HasParamArray for minor (very minor) performance improvement - relevant when executing method many times in a tight loop
2016-04-05 17:03:33 +10:00
Chris Bardsley d3d6907dac Refactored changes from build#1644 to account for discussed changes. 2016-04-04 21:44:22 -07:00
amaitland 3f15b53ab7 Resolves #1407
More the DeserializeV8Object call to within the context->Enter so a V8Object can be created
Change callback to use a struct as it's return type to demo the solution to this bug
Add missing list->SetDictionary call in V8Serialization.cpp
2015-11-18 09:17:16 +10:00
amaitland 17b7f0ced1 BindingTest - Braces on new lines
Fix CefAppUnmanagedWrapper code formatting
Slightly more descriptive error message when frame not found
2015-10-19 13:24:24 +10:00
Greg Martin a64f25193f This should fix #1336 (IJavascriptCallback.ExecuteAsync never returns when callback no longer exists) and likely fixes as-of-yet undiscovered related callback problems.
The code previously in CefAppUnmanagedWrapper.cpp's OnProcessMessageReceived method did not check for a nullptr callbackWrapper resulting in an exception.
Also note that previously the success and reponse variables were not initialized by default which I believe to have been a mistake after following all of the if..else code paths (most importantly some error conditions would never be returned back).
I added a new test to BindingTest.html entitled "Test Disposed Callback" which makes the same 1.5 second delayed callback that "Test Callback" does, but then immediately navigate the page to www.google.com.  Without the fix in CefAppUnmanagedWrapper.cpp the browser's renderer process will die in about 10 seconds.
2015-10-19 13:24:24 +10:00
amaitland 20ae2b51e4 Add a little more detail to BindingTest.html async output 2015-08-03 10:57:36 +10:00
amaitland 52f5ac5302 Formatting, make class private 2015-08-03 10:37:09 +10:00
cefsharp-ms f74b245e9b added examples for async bindings 2015-07-31 17:17:48 +02:00
amaitland 5f3d4abf69 Fix json test error (<= should have just been <)
Change a few `==` checks to `===` to make visual studio happy (just comparing strings, so no fancy type conversion necessary)
2015-05-19 19:48:18 +10:00
amaitland 0f48c637db Execute jsb callback in a Task 2015-03-12 11:48:42 +10:00
amaitland c9d65caa49 Reformat BindingTest.html 2015-03-11 11:47:06 +10:00
David Serfozo 609b13a758 few tests for js callback 2015-03-08 16:23:49 +01:00
amaitland e68b11a5db Add simple test case of bound.getSubObject().simpleProperty to BindingTest.html 2015-01-09 12:35:03 +10:00
amaitland 40f3328b5b Add simple JSON example to BindingTest.html 2014-12-16 21:44:13 +10:00
Sylvain Hamel 678f45835c CefRenderProcess process creates too many channels (and does not close them) 2014-11-11 09:06:52 -05:00
amaitland fd77db19f2 Example demonstrating that Issue #260 has been resolved 2014-09-17 15:44:45 +10:00
amaitland df5cecb1d0 Expand BindingTest to output sub properties and functions of a complex property (isn't fully recursive) 2014-08-29 19:13:13 +10:00
Per Lundberg 608af903c6 Added test case for the method casing & updated existing tests (since the method names are now camelCased). 2013-06-05 14:15:37 +03:00
Per Lundberg 73b86797c5 Added listing of the properties bound. 2013-06-05 11:28:11 +03:00
anthony taranto 0079dd4501 move test logic into CefSharp.Example, run all example tests in wpf 2012-02-24 17:03:55 -08:00
anthony taranto 04be2df6e6 rename CefSharp.Example to CefSharp.WinFormsExample 2012-02-17 14:12:07 -08:00
chillitom 97b26909c5 added a binding test page to CefSharp.Example 2010-12-14 21:26:23 +08:00