Skip to content

Legacy Javascript Binding changed from a global setting to per browser #2977

@amaitland

Description

@amaitland

Previously the Legacy JavaScript binding behaviour was configured via a global static property CefSharpSettings.LegacyJavascriptBindingEnabled

Now it's configured through JavascriptBindingSettings.LegacyBindingEnabled
which defaults to CefSharpSettings.LegacyJavascriptBindingEnabled.

When LegacyBindingEnabled is enabled, the ResolveObject event will now be called with args.ObjectName == Legacy. Which provides a much more predictable place to register objects with the legacy behaviour.

Example

chromiumWebBrowser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;

chromiumWebBrowser.JavascriptObjectRepository.ResolveObject += (s, e) =>
{
	if(e.ObjectName == JavascriptObjectRepository.LegacyObjects)
	{
		//ADD YOUR LEGACY
		e.ObjectRepository.Register("myObject", new MyObject(), isAsync:true);
	}
};

The CefSharpSettings.LegacyJavascriptBindingEnabled property will be removed at some point in the future.

UPDATE
CefSharpSettings.LegacyJavascriptBindingEnabled needs to be set before you create the ChromiumWebBrowser instance to take effect as the JavascriptBindingSettings.LegacyBindingEnabled property is set as part of the JavascriptBindingSettings constructor.


  • Raise ResolveObject event with Legacy param.
  • Map out how the property will be set in WPF. Make sure it's usable.
  • Add Unit test

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions