diff --git a/CefSharp.OffScreen/ChromiumWebBrowser.cs b/CefSharp.OffScreen/ChromiumWebBrowser.cs index 9a4197a876..5b9e417fe2 100644 --- a/CefSharp.OffScreen/ChromiumWebBrowser.cs +++ b/CefSharp.OffScreen/ChromiumWebBrowser.cs @@ -579,6 +579,15 @@ public void Load(string url) /// called before the underlying CEF browser is created. public void RegisterJsObject(string name, object objectToBind, BindingOptions options = null) { + if (!CefSharpSettings.LegacyJavascriptBindingEnabled) + { + throw new Exception(@"CefSharpSettings.LegacyJavascriptBindingEnabled is curretly false, + for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true + before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246 + for details on the new binding options. If you perform cross-site navigations bound objects will + no longer be registered and you will have to migrate to the new method."); + } + if (IsBrowserInitialized) { throw new Exception("Browser is already initialized. RegisterJsObject must be" + @@ -611,6 +620,15 @@ public void RegisterJsObject(string name, object objectToBind, BindingOptions op /// object will be a standard javascript Promise object which is usable to wait for completion or failure. public void RegisterAsyncJsObject(string name, object objectToBind, BindingOptions options = null) { + if (!CefSharpSettings.LegacyJavascriptBindingEnabled) + { + throw new Exception(@"CefSharpSettings.LegacyJavascriptBindingEnabled is curretly false, + for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true + before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246 + for details on the new binding options. If you perform cross-site navigations bound objects will + no longer be registered and you will have to migrate to the new method."); + } + if (IsBrowserInitialized) { throw new Exception("Browser is already initialized. RegisterJsObject must be" + diff --git a/CefSharp.WinForms/ChromiumWebBrowser.cs b/CefSharp.WinForms/ChromiumWebBrowser.cs index 53f2c55f9f..ea794f878c 100644 --- a/CefSharp.WinForms/ChromiumWebBrowser.cs +++ b/CefSharp.WinForms/ChromiumWebBrowser.cs @@ -486,6 +486,15 @@ public void Load(String url) /// called before the underlying CEF browser is created. public void RegisterJsObject(string name, object objectToBind, BindingOptions options = null) { + if (!CefSharpSettings.LegacyJavascriptBindingEnabled) + { + throw new Exception(@"CefSharpSettings.LegacyJavascriptBindingEnabled is curretly false, + for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true + before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246 + for details on the new binding options. If you perform cross-site navigations bound objects will + no longer be registered and you will have to migrate to the new method."); + } + if (IsBrowserInitialized) { throw new Exception("Browser is already initialized. RegisterJsObject must be" + @@ -520,6 +529,15 @@ public void RegisterJsObject(string name, object objectToBind, BindingOptions op /// object will be a standard javascript Promise object which is usable to wait for completion or failure. public void RegisterAsyncJsObject(string name, object objectToBind, BindingOptions options = null) { + if (!CefSharpSettings.LegacyJavascriptBindingEnabled) + { + throw new Exception(@"CefSharpSettings.LegacyJavascriptBindingEnabled is curretly false, + for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true + before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246 + for details on the new binding options. If you perform cross-site navigations bound objects will + no longer be registered and you will have to migrate to the new method."); + } + if (IsBrowserInitialized) { throw new Exception("Browser is already initialized. RegisterJsObject must be" + diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 5843544087..2bbe5fffe1 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -2272,6 +2272,15 @@ private void ZoomReset() /// called before the underlying CEF browser is created. public void RegisterJsObject(string name, object objectToBind, BindingOptions options = null) { + if(!CefSharpSettings.LegacyJavascriptBindingEnabled) + { + throw new Exception(@"CefSharpSettings.LegacyJavascriptBindingEnabled is curretly false, + for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true + before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246 + for details on the new binding options. If you perform cross-site navigations bound objects will + no longer be registered and you will have to migrate to the new method."); + } + if (InternalIsBrowserInitialized()) { throw new Exception("Browser is already initialized. RegisterJsObject must be" + @@ -2304,6 +2313,15 @@ public void RegisterJsObject(string name, object objectToBind, BindingOptions op /// object will be a standard javascript Promise object which is usable to wait for completion or failure. public void RegisterAsyncJsObject(string name, object objectToBind, BindingOptions options = null) { + if (!CefSharpSettings.LegacyJavascriptBindingEnabled) + { + throw new Exception(@"CefSharpSettings.LegacyJavascriptBindingEnabled is curretly false, + for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true + before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246 + for details on the new binding options. If you perform cross-site navigations bound objects will + no longer be registered and you will have to migrate to the new method."); + } + if (InternalIsBrowserInitialized()) { throw new Exception("Browser is already initialized. RegisterJsObject must be" +