Move LegacyBindingEnabled / JavascriptBindingPropertyName to per browser settings (#5231)

* Move LegacyBindingEnabled / JavascriptBindingPropertyName to per browser settings

* Stricter test

---------

Co-authored-by: Alex Maitland <amaitland@users.noreply.github.com>
This commit is contained in:
campersau
2026-04-30 13:25:18 +02:00
committed by amaitland
parent a4f649a652
commit a53a2d5c8b
4 changed files with 161 additions and 82 deletions
@@ -65,8 +65,10 @@ namespace CefSharp
auto browserId = browser->GetIdentifier();
_browserWrappers->TryAdd(browserId, wrapper);
auto javascriptBindingSettings = gcnew JavascriptBindingSettings();
_browserJavascriptBindingSettings->TryAdd(browserId, javascriptBindingSettings);
static gcroot<Func<int, JavascriptBindingSettings^>^> factory =
gcnew Func<int, JavascriptBindingSettings^>(CefAppUnmanagedWrapper::JavascriptBindingSettingsFactory);
auto javascriptBindingSettings = _browserJavascriptBindingSettings->GetOrAdd(browserId, factory);
if (!extraInfo.get())
{
@@ -78,9 +80,9 @@ namespace CefSharp
//will override the _legacyBindingEnabled field
if (!browser->IsPopup())
{
_legacyBindingEnabled = extraInfo->GetBool("LegacyBindingEnabled");
javascriptBindingSettings->LegacyBindingEnabled = extraInfo->GetBool("LegacyBindingEnabled");
if (_legacyBindingEnabled)
if (javascriptBindingSettings->LegacyBindingEnabled)
{
auto objects = extraInfo->GetList("LegacyBindingObjects");
if (objects.get() && objects->IsValid())
@@ -127,8 +129,8 @@ namespace CefSharp
if (extraInfo->HasKey("JsBindingPropertyName") || extraInfo->HasKey("JsBindingPropertyNameCamelCase"))
{
//TODO: Create constant for these and legacy binding strings above
_jsBindingPropertyName = extraInfo->GetString("JsBindingPropertyName");
_jsBindingPropertyNameCamelCase = extraInfo->GetString("JsBindingPropertyNameCamelCase");
javascriptBindingSettings->JavascriptBindingPropertyName = StringUtils::ToClr(extraInfo->GetString("JsBindingPropertyName"));
javascriptBindingSettings->JavascriptBindingPropertyNameCamelCase = StringUtils::ToClr(extraInfo->GetString("JsBindingPropertyNameCamelCase"));
}
}
@@ -162,64 +164,68 @@ namespace CefSharp
bool isSameContext = frame->GetV8Context()->IsSame(context);
if (!isSameContext)
return;
auto rootObject = GetJsRootObjectWrapper(browser->GetIdentifier(), frame->GetIdentifier());
if (_legacyBindingEnabled)
{
if (_javascriptObjects->Count > 0 && rootObject != nullptr)
{
rootObject->Bind(_javascriptObjects->Values, context->GetGlobal());
}
}
JavascriptBindingSettings^ javascriptBindingSettings = nullptr;
_browserJavascriptBindingSettings->TryGetValue(browser->GetIdentifier(), javascriptBindingSettings);
if (IsJavascriptBindingApiAllowed(javascriptBindingSettings, frame))
if (!Object::ReferenceEquals(javascriptBindingSettings, nullptr))
{
//TODO: Look at adding some sort of javascript mapping layer to reduce the code duplication
auto global = context->GetGlobal();
auto processId = System::Diagnostics::Process::GetCurrentProcess()->Id;
auto rootObject = GetJsRootObjectWrapper(browser->GetIdentifier(), frame->GetIdentifier());
//TODO: JSB: Split functions into their own classes
//Browser wrapper is only used for BindObjectAsync
auto bindObjAsyncFunction = CefV8Value::CreateFunction(kBindObjectAsync, new BindObjectAsyncHandler(_registerBoundObjectRegistry, _javascriptObjects, rootObject));
auto unBindObjFunction = CefV8Value::CreateFunction(kDeleteBoundObject, new RegisterBoundObjectHandler(_javascriptObjects));
auto removeObjectFromCacheFunction = CefV8Value::CreateFunction(kRemoveObjectFromCache, new RegisterBoundObjectHandler(_javascriptObjects));
auto isObjectCachedFunction = CefV8Value::CreateFunction(kIsObjectCached, new RegisterBoundObjectHandler(_javascriptObjects));
auto postMessageFunction = CefV8Value::CreateFunction(kPostMessage, new JavascriptPostMessageHandler(rootObject == nullptr ? nullptr : rootObject->CallbackRegistry));
auto promiseHandlerFunction = CefV8Value::CreateFunction(kSendEvalScriptResponse, new JavascriptPromiseHandler());
//By default We'll support both CefSharp and cefSharp, for those who prefer the JS style
auto createCefSharpObj = !_jsBindingPropertyName.empty();
auto createCefSharpObjCamelCase = !_jsBindingPropertyNameCamelCase.empty();
if (createCefSharpObj)
if (javascriptBindingSettings->LegacyBindingEnabled)
{
auto cefSharpObj = CefV8Value::CreateObject(nullptr, nullptr);
cefSharpObj->SetValue(kBindObjectAsync, bindObjAsyncFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kDeleteBoundObject, unBindObjFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kRemoveObjectFromCache, removeObjectFromCacheFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kIsObjectCached, isObjectCachedFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kPostMessage, postMessageFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kSendEvalScriptResponse, promiseHandlerFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kRenderProcessId, CefV8Value::CreateInt(processId), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue(_jsBindingPropertyName, cefSharpObj, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
if (_javascriptObjects->Count > 0 && rootObject != nullptr)
{
rootObject->Bind(_javascriptObjects->Values, context->GetGlobal());
}
}
if (createCefSharpObjCamelCase)
if (IsJavascriptBindingApiAllowed(javascriptBindingSettings, frame))
{
auto cefSharpObjCamelCase = CefV8Value::CreateObject(nullptr, nullptr);
cefSharpObjCamelCase->SetValue(kBindObjectAsyncCamelCase, bindObjAsyncFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kDeleteBoundObjectCamelCase, unBindObjFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kRemoveObjectFromCacheCamelCase, removeObjectFromCacheFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kIsObjectCachedCamelCase, isObjectCachedFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kPostMessageCamelCase, postMessageFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kSendEvalScriptResponseCamelCase, promiseHandlerFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kRenderProcessIdCamelCase, CefV8Value::CreateInt(processId), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
//TODO: Look at adding some sort of javascript mapping layer to reduce the code duplication
auto global = context->GetGlobal();
auto processId = System::Diagnostics::Process::GetCurrentProcess()->Id;
global->SetValue(_jsBindingPropertyNameCamelCase, cefSharpObjCamelCase, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
//TODO: JSB: Split functions into their own classes
//Browser wrapper is only used for BindObjectAsync
auto bindObjAsyncFunction = CefV8Value::CreateFunction(kBindObjectAsync, new BindObjectAsyncHandler(_registerBoundObjectRegistry, _javascriptObjects, rootObject));
auto unBindObjFunction = CefV8Value::CreateFunction(kDeleteBoundObject, new RegisterBoundObjectHandler(_javascriptObjects));
auto removeObjectFromCacheFunction = CefV8Value::CreateFunction(kRemoveObjectFromCache, new RegisterBoundObjectHandler(_javascriptObjects));
auto isObjectCachedFunction = CefV8Value::CreateFunction(kIsObjectCached, new RegisterBoundObjectHandler(_javascriptObjects));
auto postMessageFunction = CefV8Value::CreateFunction(kPostMessage, new JavascriptPostMessageHandler(rootObject == nullptr ? nullptr : rootObject->CallbackRegistry));
auto promiseHandlerFunction = CefV8Value::CreateFunction(kSendEvalScriptResponse, new JavascriptPromiseHandler());
//By default We'll support both CefSharp and cefSharp, for those who prefer the JS style
auto createCefSharpObj = !String::IsNullOrEmpty(javascriptBindingSettings->JavascriptBindingPropertyName);
auto createCefSharpObjCamelCase = !String::IsNullOrEmpty(javascriptBindingSettings->JavascriptBindingPropertyNameCamelCase);
if (createCefSharpObj)
{
auto cefSharpObj = CefV8Value::CreateObject(nullptr, nullptr);
cefSharpObj->SetValue(kBindObjectAsync, bindObjAsyncFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kDeleteBoundObject, unBindObjFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kRemoveObjectFromCache, removeObjectFromCacheFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kIsObjectCached, isObjectCachedFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kPostMessage, postMessageFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kSendEvalScriptResponse, promiseHandlerFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObj->SetValue(kRenderProcessId, CefV8Value::CreateInt(processId), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue(StringUtils::ToNative(javascriptBindingSettings->JavascriptBindingPropertyName), cefSharpObj, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
}
if (createCefSharpObjCamelCase)
{
auto cefSharpObjCamelCase = CefV8Value::CreateObject(nullptr, nullptr);
cefSharpObjCamelCase->SetValue(kBindObjectAsyncCamelCase, bindObjAsyncFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kDeleteBoundObjectCamelCase, unBindObjFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kRemoveObjectFromCacheCamelCase, removeObjectFromCacheFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kIsObjectCachedCamelCase, isObjectCachedFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kPostMessageCamelCase, postMessageFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kSendEvalScriptResponseCamelCase, promiseHandlerFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kRenderProcessIdCamelCase, CefV8Value::CreateInt(processId), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue(StringUtils::ToNative(javascriptBindingSettings->JavascriptBindingPropertyNameCamelCase), cefSharpObjCamelCase, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
}
}
}
@@ -30,17 +30,18 @@ namespace CefSharp
gcroot<ConcurrentDictionary<int, JavascriptBindingSettings^>^> _browserJavascriptBindingSettings;
gcroot<ConcurrentDictionary<String^, JavascriptRootObjectWrapper^>^> _jsRootObjectWrappersByFrameId;
bool _focusedNodeChangedEnabled;
bool _legacyBindingEnabled;
// The property names used to call bound objects
CefString _jsBindingPropertyName;
CefString _jsBindingPropertyNameCamelCase;
// The serialized registered object data waiting to be used.
gcroot<Dictionary<String^, JavascriptObject^>^> _javascriptObjects;
gcroot<RegisterBoundObjectRegistry^> _registerBoundObjectRegistry;
bool IsJavascriptBindingApiAllowed(JavascriptBindingSettings^ javascriptBindingSettings, CefRefPtr<CefFrame> frame);
static bool IsJavascriptBindingApiAllowed(JavascriptBindingSettings^ javascriptBindingSettings, CefRefPtr<CefFrame> frame);
static JavascriptBindingSettings^ JavascriptBindingSettingsFactory(int _)
{
return gcnew JavascriptBindingSettings();
}
public:
static const CefString kPromiseCreatorScript;
@@ -56,9 +57,6 @@ namespace CefSharp
_focusedNodeChangedEnabled = enableFocusedNodeChanged;
_javascriptObjects = gcnew Dictionary<String^, JavascriptObject^>();
_registerBoundObjectRegistry = gcnew RegisterBoundObjectRegistry();
_legacyBindingEnabled = false;
_jsBindingPropertyName = "CefSharp";
_jsBindingPropertyNameCamelCase = "cefSharp";
}
~CefAppUnmanagedWrapper()
@@ -20,7 +20,10 @@ namespace CefSharp
public:
JavascriptBindingSettings()
{
LegacyBindingEnabled = false;
JavascriptBindingApiEnabled = true;
JavascriptBindingPropertyName = "CefSharp";
JavascriptBindingPropertyNameCamelCase = "cefSharp";
JavascriptBindingApiHasAllowOrigins = false;
JavascriptBindingApiAllowOrigins = nullptr;
}
@@ -35,7 +38,12 @@ namespace CefSharp
this->!JavascriptBindingSettings();
}
property bool LegacyBindingEnabled;
property bool JavascriptBindingApiEnabled;
property String^ JavascriptBindingPropertyName;
property String^ JavascriptBindingPropertyNameCamelCase;
property bool JavascriptBindingApiHasAllowOrigins;
property CefRefPtr<CefListValue> JavascriptBindingApiAllowOrigins
{
@@ -84,7 +84,73 @@ namespace CefSharp.Test.JavascriptBinding
var result = await browser.EvaluateScriptAsync("bindingApiObject.isObjectCached('doesntexist') === false");
Assert.True(result.Success);
Assert.True(result.Success, result.Message);
}
}
[Fact]
public async Task ShouldWorkWhenUsingCustomGlobalObjectNameInMultipleBrowsers()
{
using var browser1 = new ChromiumWebBrowser(CefExample.BindingApiCustomObjectNameTestUrl, automaticallyCreateBrowser: false);
using var browser2 = new ChromiumWebBrowser(CefExample.BindingApiCustomObjectNameTestUrl, automaticallyCreateBrowser: false);
using var browser3 = new ChromiumWebBrowser(CefExample.BindingApiCustomObjectNameTestUrl, automaticallyCreateBrowser: false);
browser1.JavascriptObjectRepository.Settings.JavascriptBindingApiGlobalObjectName = "bindingApiObject1";
browser2.JavascriptObjectRepository.Settings.JavascriptBindingApiGlobalObjectName = "bindingApiObject2";
//To modify the settings we need to defer browser creation slightly
browser1.CreateBrowser();
browser2.CreateBrowser();
browser3.CreateBrowser();
await browser1.WaitForInitialLoadAsync();
await browser2.WaitForInitialLoadAsync();
await browser3.WaitForInitialLoadAsync();
// Assert browser1
{
var result1 = await browser1.EvaluateScriptAsync("typeof window.bindingApiObject1 === 'undefined'");
var result2 = await browser1.EvaluateScriptAsync("typeof window.bindingApiObject2 === 'undefined'");
var result3 = await browser1.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
Assert.True(result1.Success, result1.Message);
Assert.False((bool)result1.Result);
Assert.True(result2.Success, result2.Message);
Assert.True((bool)result2.Result);
Assert.True(result3.Success, result3.Message);
Assert.True((bool)result3.Result);
}
// Assert browser2
{
var result1 = await browser2.EvaluateScriptAsync("typeof window.bindingApiObject1 === 'undefined'");
var result2 = await browser2.EvaluateScriptAsync("typeof window.bindingApiObject2 === 'undefined'");
var result3 = await browser2.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
Assert.True(result1.Success, result1.Message);
Assert.True((bool)result1.Result);
Assert.True(result2.Success, result2.Message);
Assert.False((bool)result2.Result);
Assert.True(result3.Success, result3.Message);
Assert.True((bool)result3.Result);
}
// Assert browser3
{
var result1 = await browser3.EvaluateScriptAsync("typeof window.bindingApiObject1 === 'undefined'");
var result2 = await browser3.EvaluateScriptAsync("typeof window.bindingApiObject2 === 'undefined'");
var result3 = await browser3.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
Assert.True(result1.Success, result1.Message);
Assert.True((bool)result1.Result);
Assert.True(result2.Success, result2.Message);
Assert.True((bool)result2.Result);
Assert.True(result3.Success, result3.Message);
Assert.False((bool)result3.Result);
}
}
@@ -97,10 +163,10 @@ namespace CefSharp.Test.JavascriptBinding
var loadResponse = await Browser.LoadUrlAsync(CefExample.BindingApiCustomObjectNameTestUrl);
Assert.True(loadResponse.Success);
var response = await Browser.EvaluateScriptAsync(script);
Assert.True(response.Success);
Assert.True(response.Success, response.Message);
Assert.False((bool)response.Result);
}
@@ -122,10 +188,10 @@ namespace CefSharp.Test.JavascriptBinding
var response1 = await browser.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.True((bool)response1.Result);
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.True((bool)response2.Result);
}
}
@@ -152,10 +218,10 @@ namespace CefSharp.Test.JavascriptBinding
var response1 = await browser.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.True((bool)response1.Result);
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.True((bool)response2.Result);
}
}
@@ -179,10 +245,10 @@ namespace CefSharp.Test.JavascriptBinding
var response1 = await browser.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.False((bool)response1.Result);
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.False((bool)response2.Result);
}
}
@@ -208,13 +274,14 @@ namespace CefSharp.Test.JavascriptBinding
var response1 = await browser.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.False((bool)response1.Result);
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.False((bool)response2.Result);
}
}
[Theory]
[InlineData(CefExample.BaseUrl + "/")]
[InlineData("someorigin", CefExample.BaseUrl + "/")]
@@ -239,10 +306,10 @@ namespace CefSharp.Test.JavascriptBinding
var response1 = await browser.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.False((bool)response1.Result);
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.False((bool)response2.Result);
}
}
@@ -265,10 +332,10 @@ namespace CefSharp.Test.JavascriptBinding
var response1 = await browser.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'");
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.False((bool)response1.Result);
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.False((bool)response2.Result);
}
}
@@ -282,7 +349,7 @@ namespace CefSharp.Test.JavascriptBinding
var result = await Browser.EvaluateScriptAsync(script);
Assert.True(result.Success);
Assert.True(result.Success, result.Message);
using var process = Process.GetProcessById(Assert.IsType<int>(result.Result));
@@ -373,7 +440,7 @@ namespace CefSharp.Test.JavascriptBinding
// Binding API should be present on the allowed origin
var response1 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.False((bool)response1.Result);
// Navigate to a different origin that is not in the allow list
@@ -382,7 +449,7 @@ namespace CefSharp.Test.JavascriptBinding
// Binding API should no longer be present on the disallowed origin
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.True((bool)response2.Result);
}
}
@@ -404,7 +471,7 @@ namespace CefSharp.Test.JavascriptBinding
// Binding API should be present on the first allowed origin
var response1 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response1.Success);
Assert.True(response1.Success, response1.Message);
Assert.False((bool)response1.Result);
// Navigate to a second origin that is also in the allow list
@@ -413,7 +480,7 @@ namespace CefSharp.Test.JavascriptBinding
// Binding API should still be present on the second allowed origin
var response2 = await browser.EvaluateScriptAsync("typeof window.CefSharp === 'undefined'");
Assert.True(response2.Success);
Assert.True(response2.Success, response2.Message);
Assert.False((bool)response2.Result);
}
}