Commit 438a845c authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] check callback before calling on promise collected

R=dgozman@chromium.org

Bug: chromium:754560
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I3c0d5c4eebc3e8dbfa6663210046d6a86b1226b5
Reviewed-on: https://chromium-review.googlesource.com/612452Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47321}
parent c820b89b
......@@ -137,8 +137,7 @@ class InjectedScript::ProtocolPromiseHandler {
data.GetParameter()->m_wrapper.Reset();
data.SetSecondPassCallback(cleanup);
} else {
data.GetParameter()->m_callback->sendFailure(
Response::Error("Promise was collected"));
data.GetParameter()->sendPromiseCollected();
delete data.GetParameter();
}
}
......@@ -219,6 +218,19 @@ class InjectedScript::ProtocolPromiseHandler {
callback->sendSuccess(std::move(wrappedValue), std::move(exceptionDetails));
}
void sendPromiseCollected() {
V8InspectorSessionImpl* session =
m_inspector->sessionById(m_contextGroupId, m_sessionId);
if (!session) return;
InjectedScript::ContextScope scope(session, m_executionContextId);
Response response = scope.initialize();
if (!response.isSuccess()) return;
std::unique_ptr<EvaluateCallback> callback =
scope.injectedScript()->takeEvaluateCallback(m_callback);
if (!callback) return;
callback->sendFailure(Response::Error("Promise was collected"));
}
V8InspectorImpl* m_inspector;
int m_sessionId;
int m_contextGroupId;
......
......@@ -229,3 +229,4 @@ Destroying context..
id : <messageId>
}
Context destroyed
Triggering weak callback..
......@@ -129,10 +129,12 @@ InspectorTest.runAsyncTestSuite([
async function testImmediatelyResolvedAfterAfterContextDestroyed()
{
Protocol.Runtime.evaluate({
expression: 'a = new Promise(() => 42)',
expression: 'new Promise(() => 42)',
awaitPromise: true }).then(InspectorTest.logMessage);
InspectorTest.log('Destroying context..');
await Protocol.Runtime.evaluate({expression: 'inspector.fireContextDestroyed()'});
InspectorTest.log('Context destroyed');
InspectorTest.log('Triggering weak callback..');
await Protocol.HeapProfiler.collectGarbage();
}
]);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment