From df617c1a474c302fe3059ee227f927a1385eca3a Mon Sep 17 00:00:00 2001 From: amaitland Date: Thu, 13 Jun 2019 22:18:01 +1000 Subject: [PATCH] SendProcessMessage - Remove frame/browserid from messages Not complete or tested yet --- .../Async/JavascriptAsyncMethodHandler.cpp | 9 +- .../CefAppUnmanagedWrapper.cpp | 70 +++++------- .../JavascriptPostMessageHandler.h | 6 +- .../RegisterBoundObjectHandler.h | 10 +- CefSharp.Core/Internals/CefFrameWrapper.cpp | 29 ++++- CefSharp.Core/Internals/ClientAdapter.cpp | 103 +++++------------- CefSharp.Core/Internals/ClientAdapter.h | 3 - .../Internals/JavascriptCallbackProxy.cpp | 8 +- .../Resources/BindingTestSingle.html | 43 +------- 9 files changed, 102 insertions(+), 179 deletions(-) diff --git a/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp b/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp index 525f6626f0..7c45a4b01f 100644 --- a/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp +++ b/CefSharp.BrowserSubprocess.Core/Async/JavascriptAsyncMethodHandler.cpp @@ -59,11 +59,10 @@ namespace CefSharp SerializeV8Object(arguments[i], params, i, _callbackRegistry); } - SetInt64(argList, 0, frame->GetIdentifier()); - SetInt64(argList, 1, _objectId); - SetInt64(argList, 2, callbackId); - argList->SetString(3, name); - argList->SetList(4, params); + SetInt64(argList, 0, _objectId); + SetInt64(argList, 1, callbackId); + argList->SetString(2, name); + argList->SetList(3, params); frame->SendProcessMessage(CefProcessId::PID_BROWSER, request); diff --git a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp index 4a7136db43..b7c6a99677 100644 --- a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp +++ b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp @@ -123,8 +123,6 @@ namespace CefSharp //have been created auto contextCreatedMessage = CefProcessMessage::Create(kOnContextCreatedRequest); - SetInt64(contextCreatedMessage->GetArgumentList(), 0, frame->GetIdentifier()); - frame->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage); }; @@ -141,8 +139,6 @@ namespace CefSharp auto contextReleasedMessage = CefProcessMessage::Create(kOnContextReleasedRequest); - SetInt64(contextReleasedMessage->GetArgumentList(), 0, frame->GetIdentifier()); - frame->SendProcessMessage(CefProcessId::PID_BROWSER, contextReleasedMessage); auto browserWrapper = FindBrowserWrapper(browser->GetIdentifier()); @@ -172,19 +168,16 @@ namespace CefSharp auto focusedNodeChangedMessage = CefProcessMessage::Create(kOnFocusedNodeChanged); auto list = focusedNodeChangedMessage->GetArgumentList(); - // Needed in the browser process to get the frame. - SetInt64(list, 0, frame->GetIdentifier()); - // The node will be empty if an element loses focus but another one // doesn't gain focus. Only transfer information if the node is an // element. if (node != nullptr && node->IsElement()) { // True when a node exists, false if it doesn't. - list->SetBool(1, true); + list->SetBool(0, true); // Store the tag name. - list->SetString(2, node->GetElementTagName()); + list->SetString(1, node->GetElementTagName()); // Transfer the attributes in a Dictionary. auto attributes = CefDictionaryValue::Create(); @@ -195,11 +188,11 @@ namespace CefSharp attributes->SetString(iter.first, iter.second); } - list->SetDictionary(3, attributes); + list->SetDictionary(2, attributes); } else { - list->SetBool(1, false); + list->SetBool(0, false); } frame->SendProcessMessage(CefProcessId::PID_BROWSER, focusedNodeChangedMessage); @@ -210,9 +203,7 @@ namespace CefSharp auto uncaughtExceptionMessage = CefProcessMessage::Create(kOnUncaughtException); auto list = uncaughtExceptionMessage->GetArgumentList(); - // Needed in the browser process to get the frame. - SetInt64(list, 0, frame->GetIdentifier()); - list->SetString(1, exception->GetMessage()); + list->SetString(0, exception->GetMessage()); auto frames = CefListValue::Create(); for (auto i = 0; i < stackTrace->GetFrameCount(); i++) @@ -228,7 +219,7 @@ namespace CefSharp frames->SetList(i, frame); } - list->SetList(2, frames); + list->SetList(1, frames); frame->SendProcessMessage(CefProcessId::PID_BROWSER, uncaughtExceptionMessage); } @@ -304,7 +295,7 @@ namespace CefSharp throw gcnew Exception("Unsupported message type"); } - auto callbackId = GetInt64(argList, 1); + auto callbackId = GetInt64(argList, 0); auto response = CefProcessMessage::Create(responseName); auto responseArgList = response->GetArgumentList(); auto errorMessage = String::Format("Request BrowserId : {0} not found it's likely the browser is already closed", browser->GetIdentifier()); @@ -335,13 +326,12 @@ namespace CefSharp response = CefProcessMessage::Create(kJavascriptCallbackResponse); } - //both messages have the frameId stored at 0 and callbackId stored at index 1 - auto frameId = GetInt64(argList, 0); - int64 callbackId = GetInt64(argList, 1); + //both messages have callbackId stored at index 0 + auto frameId = frame->GetIdentifier(); + int64 callbackId = GetInt64(argList, 0); if (name == kEvaluateJavascriptRequest) { - JavascriptRootObjectWrapper^ rootObjectWrapper; browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper); @@ -357,12 +347,11 @@ namespace CefSharp auto callbackRegistry = rootObjectWrapper->CallbackRegistry; - auto script = argList->GetString(2); - auto scriptUrl = argList->GetString(3); - auto startLine = argList->GetInt(4); + auto script = argList->GetString(1); + auto scriptUrl = argList->GetString(2); + auto startLine = argList->GetInt(3); - auto frame = browser->GetFrame(frameId); - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto context = frame->GetV8Context(); @@ -410,7 +399,7 @@ namespace CefSharp } else { - auto jsCallbackId = GetInt64(argList, 2); + auto jsCallbackId = GetInt64(argList, 1); auto callbackWrapper = callbackRegistry->FindWrapper(jsCallbackId); if (callbackWrapper == nullptr) @@ -426,7 +415,7 @@ namespace CefSharp { try { - auto parameterList = argList->GetList(3); + auto parameterList = argList->GetList(2); CefV8ValueList params; //Needs to be called within the context as for Dictionary (mapped to struct) @@ -478,7 +467,7 @@ namespace CefSharp else if (name == kJavascriptCallbackDestroyRequest) { auto jsCallbackId = GetInt64(argList, 0); - auto frameId = GetInt64(argList, 1); + auto frameId = frame->GetIdentifier(); JavascriptRootObjectWrapper^ rootObjectWrapper; browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper); if (rootObjectWrapper != nullptr && rootObjectWrapper->CallbackRegistry != nullptr) @@ -517,10 +506,10 @@ namespace CefSharp } else { - auto browserId = argList->GetInt(1); - auto frameId = GetInt64(argList, 2); - auto callbackId = GetInt64(argList, 3); - auto javascriptObjects = DeserializeJsObjects(argList, 4); + auto browserId = browser->GetIdentifier(); + auto frameId = frame->GetIdentifier(); + auto callbackId = GetInt64(argList, 1); + auto javascriptObjects = DeserializeJsObjects(argList, 2); //Caching of JavascriptObjects //TODO: JSB Should caching be configurable? On a per object basis? @@ -533,8 +522,7 @@ namespace CefSharp _javascriptObjects->Add(obj->JavascriptName, obj); } - auto frame = browser->GetFrame(frameId); - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto rootObject = GetJsRootObjectWrapper(browser->GetIdentifier(), frameId); @@ -609,8 +597,8 @@ namespace CefSharp } else if (name == kJavascriptAsyncMethodCallResponse) { - auto frameId = GetInt64(argList, 0); - auto callbackId = GetInt64(argList, 1); + auto frameId = frame->GetIdentifier(); + auto callbackId = GetInt64(argList, 0); JavascriptRootObjectWrapper^ rootObjectWrapper; browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper); @@ -620,11 +608,9 @@ namespace CefSharp JavascriptAsyncMethodCallback^ callback; if (rootObjectWrapper->TryGetAndRemoveMethodCallback(callbackId, callback)) { - try { - auto frame = browser->GetFrame(frameId); - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto context = frame->GetV8Context(); @@ -632,14 +618,14 @@ namespace CefSharp { try { - auto success = argList->GetBool(2); + auto success = argList->GetBool(1); if (success) { - callback->Success(DeserializeV8Object(argList, 3)); + callback->Success(DeserializeV8Object(argList, 2)); } else { - callback->Fail(argList->GetString(3)); + callback->Fail(argList->GetString(2)); } } finally diff --git a/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h b/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h index 33d352079b..81fe6c0ea4 100644 --- a/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h +++ b/CefSharp.BrowserSubprocess.Core/JavascriptPostMessageHandler.h @@ -44,7 +44,7 @@ namespace CefSharp { auto frame = context->GetFrame(); - if (context.get() && context->Enter()) + if (frame.get() && frame->IsValid() && context->Enter()) { try { @@ -53,15 +53,13 @@ namespace CefSharp auto request = CefProcessMessage::Create(kJavascriptMessageReceived); auto argList = request->GetArgumentList(); - SetInt64(argList, 0, frame->GetIdentifier()); - auto params = CefListValue::Create(); SerializeV8Object(arguments[0], params, 0, _javascriptCallbackRegistry); //We're only interested in the first param if (params->GetSize() > 0) { - argList->SetValue(1, params->GetValue(0)); + argList->SetValue(0, params->GetValue(0)); } frame->SendProcessMessage(CefProcessId::PID_BROWSER, request); diff --git a/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h b/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h index 64da2d6985..4b764b2aba 100644 --- a/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h +++ b/CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h @@ -277,15 +277,13 @@ namespace CefSharp else { auto frame = context->GetFrame(); - if (frame.get()) + if (frame.get() && frame->IsValid()) { //Obtain a callbackId then send off the Request for objects auto callbackId = _callbackRegistry->SaveMethodCallback(callback); - argList->SetInt(0, browser->GetIdentifier()); - SetInt64(argList, 1, frame->GetIdentifier()); - SetInt64(argList, 2, callbackId); - argList->SetList(3, params); + SetInt64(argList, 0, callbackId); + argList->SetList(1, params); frame->SendProcessMessage(CefProcessId::PID_BROWSER, request); } @@ -295,7 +293,7 @@ namespace CefSharp { auto frame = context->GetFrame(); - if (frame.get()) + if (frame.get() && frame->IsValid()) { //Objects already bound or ignore cache diff --git a/CefSharp.Core/Internals/CefFrameWrapper.cpp b/CefSharp.Core/Internals/CefFrameWrapper.cpp index 9351f70b7c..14b742e811 100644 --- a/CefSharp.Core/Internals/CefFrameWrapper.cpp +++ b/CefSharp.Core/Internals/CefFrameWrapper.cpp @@ -10,6 +10,11 @@ #include "Internals\CefFrameWrapper.h" #include "Internals\StringVisitor.h" #include "Internals\ClientAdapter.h" +#include "Internals\Serialization\Primitives.h" +#include "Internals\Messaging\Messages.h" + +using namespace CefSharp::Internals::Messaging; +using namespace CefSharp::Internals::Serialization; /// // True if this object is currently attached to a valid frame. @@ -240,9 +245,29 @@ Task^ CefFrameWrapper::EvaluateScriptAsync(String^ script, auto browser = _frame->GetBrowser(); auto host = browser->GetHost(); + //If we're unable to get the underlying browser/browserhost then return null + if (!browser.get() || !host.get()) + { + return nullptr; + } + auto client = static_cast(host->GetClient().get()); - return client->EvaluateScriptAsync(browser->GetIdentifier(), browser->IsPopup(), _frame->GetIdentifier(), script, scriptUrl, startLine, timeout); + auto pendingTaskRepository = client->GetPendingTaskRepository(); + + //create a new taskcompletionsource + auto idAndComplectionSource = pendingTaskRepository->CreatePendingTask(timeout); + + auto message = CefProcessMessage::Create(kEvaluateJavascriptRequest); + auto argList = message->GetArgumentList(); + SetInt64(argList, 0, idAndComplectionSource.Key); + argList->SetString(1, StringUtils::ToNative(script)); + argList->SetString(2, StringUtils::ToNative(scriptUrl)); + argList->SetInt(3, startLine); + + _frame->SendProcessMessage(CefProcessId::PID_RENDERER, message); + + return idAndComplectionSource.Value->Task; } /// @@ -388,4 +413,4 @@ void CefFrameWrapper::ThrowIfFrameInvalid() { throw gcnew Exception(L"The underlying frame is no longer valid - please check the IsValid property before calling!"); } -} \ No newline at end of file +} diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index baa14efea0..7135eacaa3 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -635,10 +635,8 @@ namespace CefSharp auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse); auto responseArgList = msg->GetArgumentList(); responseArgList->SetBool(0, true); //Use Legacy Behaviour (auto bind on context creation) - responseArgList->SetInt(1, -1); //BrowserId - SetInt64(responseArgList, 2, 0); //FrameId - SetInt64(responseArgList, 3, 0); //CallbackId - SerializeJsObjects(objectRepository->GetObjects(nullptr), responseArgList, 4); + SetInt64(responseArgList, 1, 0); //CallbackId + SerializeJsObjects(objectRepository->GetObjects(nullptr), responseArgList, 2); browser->GetMainFrame()->SendProcessMessage(CefProcessId::PID_RENDERER, msg); } @@ -1050,10 +1048,8 @@ namespace CefSharp { auto objectRepository = _browserAdapter->JavascriptObjectRepository; - auto browserId = argList->GetInt(0); - auto frameId = GetInt64(argList, 1); - auto callbackId = GetInt64(argList, 2); - auto objectNames = argList->GetList(3); + auto callbackId = GetInt64(argList, 0); + auto objectNames = argList->GetList(1); auto names = gcnew List(objectNames->GetSize()); for (auto i = 0; i < objectNames->GetSize(); i++) @@ -1069,10 +1065,8 @@ namespace CefSharp auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse); auto responseArgList = msg->GetArgumentList(); responseArgList->SetBool(0, false); //Use LegacyBehaviour (false) - responseArgList->SetInt(1, browserId); - SetInt64(responseArgList, 2, frameId); - SetInt64(responseArgList, 3, callbackId); - SerializeJsObjects(objs, responseArgList, 4); + SetInt64(responseArgList, 1, callbackId); + SerializeJsObjects(objs, responseArgList, 2); frame->SendProcessMessage(CefProcessId::PID_RENDERER, msg); } @@ -1103,11 +1097,9 @@ namespace CefSharp } else if (name == kOnContextCreatedRequest) { - auto frame = browser->GetFrame(GetInt64(argList, 0)); - //In certain circumstances the frame has already been destroyed by the time //we get here, only continue if we have a valid frame reference - if (frame.get()) + if (frame.get() && frame->IsValid()) { if (frame->IsMain()) { @@ -1129,11 +1121,9 @@ namespace CefSharp } else if (name == kOnContextReleasedRequest) { - auto frame = browser->GetFrame(GetInt64(argList, 0)); - //In certain circumstances the frame has already been destroyed by the time //we get here, only continue if we have a valid frame reference - if (frame.get()) + if (frame.get() && frame->IsValid()) { if (frame->IsMain()) { @@ -1160,19 +1150,18 @@ namespace CefSharp { IDomNode^ node = nullptr; - // 0: frame ID (int 64) - // 1: is a node (bool) - // 2: tag name (string) - // 3: attributes (dictionary) + // 0: is a node (bool) + // 1: tag name (string) + // 2: attributes (dictionary) auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(browser->GetFrame(GetInt64(argList, 0))); + CefFrameWrapper frameWrapper(frame); - auto notEmpty = argList->GetBool(1); + auto notEmpty = argList->GetBool(0); if (notEmpty) { // Node information was passed from the render process. - auto tagName = StringUtils::ToClr(argList->GetString(2)); - auto argAttributes = argList->GetDictionary(3); + auto tagName = StringUtils::ToClr(argList->GetString(1)); + auto argAttributes = argList->GetDictionary(2); auto attributes = gcnew System::Collections::Generic::Dictionary(); CefDictionaryValue::KeyList keys; argAttributes->GetKeys(keys); @@ -1194,14 +1183,14 @@ namespace CefSharp if (handler != nullptr) { auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - CefFrameWrapper frameWrapper(browser->GetFrame(GetInt64(argList, 0))); + CefFrameWrapper frameWrapper(frame); auto exception = gcnew JavascriptException(); - exception->Message = StringUtils::ToClr(argList->GetString(1)); + exception->Message = StringUtils::ToClr(argList->GetString(0)); auto stackTrace = gcnew System::Collections::Generic::List(); - auto argFrames = argList->GetList(2); + auto argFrames = argList->GetList(1); for (auto i = 0; i < static_cast(argFrames->GetSize()); i++) { @@ -1248,11 +1237,11 @@ namespace CefSharp } else if (name == kJavascriptAsyncMethodCallRequest && !_browserAdapter->IsDisposed) { - auto frameId = GetInt64(argList, 0); - auto objectId = GetInt64(argList, 1); - auto callbackId = GetInt64(argList, 2); - auto methodName = StringUtils::ToClr(argList->GetString(3)); - auto arguments = argList->GetList(4); + auto frameId = frame->GetIdentifier(); + auto objectId = GetInt64(argList, 0); + auto callbackId = GetInt64(argList, 1); + auto methodName = StringUtils::ToClr(argList->GetString(2)); + auto arguments = argList->GetList(3); auto methodInvocation = gcnew MethodInvocation(browser->GetIdentifier(), frameId, objectId, methodName, (callbackId > 0 ? Nullable(callbackId) : Nullable())); for (auto i = 0; i < static_cast(arguments->GetSize()); i++) { @@ -1265,16 +1254,14 @@ namespace CefSharp } else if (name == kJavascriptMessageReceived) { - auto frame = browser->GetFrame(GetInt64(argList, 0)); - //In certain circumstances the frame has already been destroyed by the time //we get here, only continue if we have a valid frame reference - if (frame.get()) + if (frame.get() && frame->IsValid()) { auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); CefFrameWrapper frameWrapper(frame); - auto message = DeserializeObject(argList, 1, callbackFactory); + auto message = DeserializeObject(argList, 0, callbackFactory); _browserControl->SetJavascriptMessageReceived(gcnew JavascriptMessageReceivedEventArgs(browserWrapper, %frameWrapper, message)); } @@ -1285,37 +1272,6 @@ namespace CefSharp return handled; } - Task^ ClientAdapter::EvaluateScriptAsync(int browserId, bool isBrowserPopup, int64 frameId, String^ script, String^ scriptUrl, int startLine, Nullable timeout) - { - auto browser = GetBrowserWrapper(browserId, isBrowserPopup); - - //If we're unable to get the underlying browser wrapper then return null - if (browser == nullptr) - { - return nullptr; - } - - auto browserWrapper = static_cast(browser); - auto cefBrowser = browserWrapper->Browser; - - //create a new taskcompletionsource - auto idAndComplectionSource = _pendingTaskRepository->CreatePendingTask(timeout); - - auto message = CefProcessMessage::Create(kEvaluateJavascriptRequest); - auto argList = message->GetArgumentList(); - SetInt64(argList, 0, frameId); - SetInt64(argList, 1, idAndComplectionSource.Key); - argList->SetString(2, StringUtils::ToNative(script)); - argList->SetString(3, StringUtils::ToNative(scriptUrl)); - argList->SetInt(4, startLine); - - auto frame = cefBrowser->GetFrame(frameId); - - frame->SendProcessMessage(CefProcessId::PID_RENDERER, message); - - return idAndComplectionSource.Value->Task; - } - PendingTaskRepository^ ClientAdapter::GetPendingTaskRepository() { return _pendingTaskRepository; @@ -1327,16 +1283,15 @@ namespace CefSharp { auto message = CefProcessMessage::Create(kJavascriptAsyncMethodCallResponse); auto argList = message->GetArgumentList(); - SetInt64(argList, 0, result->FrameId); - SetInt64(argList, 1, result->CallbackId.Value); - argList->SetBool(2, result->Success); + SetInt64(argList, 0, result->CallbackId.Value); + argList->SetBool(1, result->Success); if (result->Success) { - SerializeV8Object(argList, 3, result->Result); + SerializeV8Object(argList, 2, result->Result); } else { - argList->SetString(3, StringUtils::ToNative(result->Message)); + argList->SetString(2, StringUtils::ToNative(result->Message)); } auto browser = GetBrowserWrapper(result->BrowserId); diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index d5ff0c54cb..2a16876acc 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -207,9 +207,6 @@ namespace CefSharp virtual DECL void OnAudioStreamPacket(CefRefPtr browser, int audio_stream_id, const float** data, int frames, int64 pts) OVERRIDE; virtual DECL void OnAudioStreamStopped(CefRefPtr browser, int audio_stream_id) OVERRIDE; - //sends out an eval script request to the render process - Task^ EvaluateScriptAsync(int browserId, bool isBrowserPopup, int64 frameId, String^ script, String^ scriptUrl, int startLine, Nullable timeout); - IMPLEMENT_REFCOUNTING(ClientAdapter); }; } diff --git a/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp b/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp index 90ca9edcac..324801f721 100644 --- a/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp +++ b/CefSharp.Core/Internals/JavascriptCallbackProxy.cpp @@ -31,16 +31,15 @@ namespace CefSharp auto callbackMessage = CefProcessMessage::Create(kJavascriptCallbackRequest); auto argList = callbackMessage->GetArgumentList(); - SetInt64(argList, 0, _callback->FrameId); - SetInt64(argList, 1, doneCallback.Key); - SetInt64(argList, 2, _callback->Id); + SetInt64(argList, 0, doneCallback.Key); + SetInt64(argList, 1, _callback->Id); auto paramList = CefListValue::Create(); for (int i = 0; i < parameters->Length; i++) { auto param = parameters[i]; SerializeV8Object(paramList, i, param); } - argList->SetList(3, paramList); + argList->SetList(2, paramList); auto frame = browserWrapper->Browser->GetFrame(_callback->FrameId); @@ -65,7 +64,6 @@ namespace CefSharp auto result = CefProcessMessage::Create(kJavascriptCallbackDestroyRequest); auto argList = result->GetArgumentList(); SetInt64(argList, 0, _callback->Id); - SetInt64(argList, 1, _callback->FrameId); return result; } diff --git a/CefSharp.Example/Resources/BindingTestSingle.html b/CefSharp.Example/Resources/BindingTestSingle.html index 7499863105..5160431aaa 100644 --- a/CefSharp.Example/Resources/BindingTestSingle.html +++ b/CefSharp.Example/Resources/BindingTestSingle.html @@ -5,11 +5,6 @@ -
- These tests require CefSharpSettings.ConcurrentTaskExecution = true; - Which by default is set to false -
-
@@ -19,43 +14,15 @@ { await CefSharp.BindObjectAsync("boundAsync"); - QUnit.test("ReturnTaskStringAsync:", function (assert) - { - let asyncCallback = assert.async(); - - boundAsync.returnTaskStringAsync().then(function (actualResult) - { - const expectedResult = 'ReturnTaskStringAsync'; - - assert.equal(expectedResult, actualResult, "Return string " + expectedResult); - - asyncCallback(); - }); - }); - - QUnit.test("VoidReturnAsync Test:", function (assert) + QUnit.test("Async call (Divide 16 / 2):", function (assert) { - let asyncCallback = assert.async(); + var asyncCallback = assert.async(); - boundAsync.voidReturnAsync().then(function (actualResult) + boundAsync.div(16, 2).then(function (actualResult) { - const expectedResult = null; + const expectedResult = 8 - assert.equal(expectedResult, actualResult, "Return null"); - - asyncCallback(); - }); - }); - - QUnit.test("AsyncWaitTwoSeconds Test:", function (assert) - { - let asyncCallback = assert.async(); - - const expectedResult = "This method waited two seconds"; - - boundAsync.asyncWaitTwoSeconds(expectedResult).then(function (actualResult) - { - assert.equal(expectedResult, actualResult, "Return string " + expectedResult); + assert.equal(expectedResult, actualResult, "Divide 16 / 2 resulted in " + expectedResult); asyncCallback(); });