Index: Source/bindings/v8/ScriptPromiseResolverWithContext.cpp |
diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp |
index 0678ffcff0684341864e918a297cc72b24ae6ecc..5b3852918a10ef2853b6e90a9369e5a1ac7b3e8c 100644 |
--- a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp |
+++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp |
@@ -5,13 +5,15 @@ |
#include "config.h" |
#include "bindings/v8/ScriptPromiseResolverWithContext.h" |
+#include "bindings/v8/V8PerIsolateData.h" |
+ |
namespace WebCore { |
ScriptPromiseResolverWithContext::ScriptPromiseResolverWithContext(NewScriptState* scriptState) |
: ActiveDOMObject(scriptState->executionContext()) |
, m_state(Pending) |
, m_scriptState(scriptState) |
- , m_timer(this, &ScriptPromiseResolverWithContext::resolveOrRejectImmediately) |
+ , m_timer(this, &ScriptPromiseResolverWithContext::onTimerFired) |
, m_resolver(ScriptPromiseResolver::create(m_scriptState->executionContext())) { } |
void ScriptPromiseResolverWithContext::suspend() |
@@ -31,20 +33,31 @@ void ScriptPromiseResolverWithContext::stop() |
clear(); |
} |
-void ScriptPromiseResolverWithContext::resolveOrRejectImmediately(Timer<ScriptPromiseResolverWithContext>*) |
+void ScriptPromiseResolverWithContext::onTimerFired(Timer<ScriptPromiseResolverWithContext>*) |
+{ |
+ RefPtr<ScriptPromiseResolverWithContext> protect(this); |
+ NewScriptState::Scope scope(m_scriptState.get()); |
+ v8::Isolate* isolate = m_scriptState->isolate(); |
+ resolveOrRejectImmediately(); |
+ |
+ v8::V8::RunMicrotasks(isolate); |
+} |
+ |
+void ScriptPromiseResolverWithContext::resolveOrRejectImmediately() |
{ |
ASSERT(!executionContext()->activeDOMObjectsAreStopped()); |
ASSERT(!executionContext()->activeDOMObjectsAreSuspended()); |
if (m_state == Resolving) { |
- NewScriptState::Scope scope(m_scriptState.get()); |
m_resolver->resolve(m_value.newLocal(m_scriptState->isolate())); |
} else { |
ASSERT(m_state == Rejecting); |
- NewScriptState::Scope scope(m_scriptState.get()); |
m_resolver->reject(m_value.newLocal(m_scriptState->isolate())); |
} |
m_state = ResolvedOrRejected; |
clear(); |
+ |
+ // ref() was called in resolveOrRejected. |
+ deref(); |
} |
void ScriptPromiseResolverWithContext::clear() |