Core - Cancel pending tasks when browser crashed or v8 context gets released (#5145)

* Core - Cancel pending tasks when browser crashed or v8 context gets released

* Use TrySetCanceled to cancel pending tasks

* Adjust test to use chrome://crash for simulating a crash

* Add tests for javascript callbacks

* Rename tests and add tests for calling Execute multiple times

* Move FramePendingTaskRepository to its own file

* Rename test to ShouldCancelAfterV8ContextChange

* Fix compile error on .NET Framework

* adjust ShouldTimeoutIfNavigationOccurs test which now throws a TaskCanceledException on navigation
This commit is contained in:
campersau
2025-08-22 04:14:38 +02:00
committed by amaitland
parent c1f335346e
commit cf5f836a6c
10 changed files with 287 additions and 51 deletions
@@ -237,7 +237,7 @@ Task<JavascriptResponse^>^ CefFrameWrapper::EvaluateScriptAsync(String^ script,
//If we're unable to get the underlying browser/browserhost then return null
if (!browser.get() || !host.get())
{
return nullptr;
return Task::FromException<JavascriptResponse^>(gcnew InvalidOperationException("Browser host not available"));
}
auto client = static_cast<ClientAdapter*>(host->GetClient().get());
@@ -245,7 +245,7 @@ Task<JavascriptResponse^>^ CefFrameWrapper::EvaluateScriptAsync(String^ script,
auto pendingTaskRepository = client->GetPendingTaskRepository();
//create a new taskcompletionsource
auto idAndComplectionSource = pendingTaskRepository->CreatePendingTask(timeout);
auto idAndComplectionSource = pendingTaskRepository->CreatePendingTask(Identifier, timeout);
if (useImmediatelyInvokedFuncExpression)
{