#include "core/dom/Document.h"
#include "core/dom/ExecutionContextTask.h"
#include "core/frame/DOMWindow.h"
+#include "core/frame/UseCounter.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/workers/WorkerGlobalScope.h"
#include "platform/Task.h"
v8::Local<v8::Value> originatorValue = originatorInternal->GetInternalField(V8PromiseCustom::InternalResultIndex);
if (originatorState == V8PromiseCustom::Fulfilled) {
if (originatorValue->IsObject()) {
- ExecutionContext* executionContext = getExecutionContext();
+ ExecutionContext* executionContext = currentExecutionContext(isolate);
ASSERT(executionContext && executionContext->isContextThread());
executionContext->postTask(adoptPtr(new UpdateDerivedTask(derivedPromise, onFulfilled, onRejected, originatorValue.As<v8::Object>(), isolate, executionContext)));
} else {
{
v8SetReturnValue(info, v8::Local<v8::Value>());
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ UseCounter::count(executionContext, UseCounter::PromiseConstructor);
if (!info.Length() || !info[0]->IsFunction()) {
throwTypeError("Promise constructor takes a function argument", isolate);
return;
createClosure(promiseRejectCallback, promise, isolate)
};
v8::TryCatch trycatch;
- if (V8ScriptRunner::callFunction(init, getExecutionContext(), v8::Undefined(isolate), WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
+ if (V8ScriptRunner::callFunction(init, currentExecutionContext(isolate), v8::Undefined(isolate), WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
// An exception is thrown. Reject the promise if its resolved flag is unset.
V8PromiseCustom::reject(promise, trycatch.Exception(), isolate);
}
void V8Promise::castMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ UseCounter::count(executionContext, UseCounter::PromiseCast);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ UseCounter::count(executionContext, UseCounter::PromiseResolve);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
void V8Promise::rejectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
+ ExecutionContext* executionContext = activeExecutionContext(isolate);
+ UseCounter::count(executionContext, UseCounter::PromiseReject);
v8::Local<v8::Value> result = v8::Undefined(isolate);
if (info.Length() > 0)
result = info[0];
createClosure(promiseRejectCallback, promise, isolate)
};
v8::TryCatch trycatch;
- if (V8ScriptRunner::callFunction(then, getExecutionContext(), thenable, WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
+ if (V8ScriptRunner::callFunction(then, currentExecutionContext(isolate), thenable, WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
reject(promise, trycatch.Exception(), isolate);
}
setHiddenValue(isolate, thenable, "thenableHiddenPromise", promise);
void V8PromiseCustom::callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> handler, v8::Handle<v8::Value> argument, PromiseState originatorState, v8::Isolate* isolate)
{
ASSERT(originatorState == Fulfilled || originatorState == Rejected);
- ExecutionContext* executionContext = getExecutionContext();
+ ExecutionContext* executionContext = currentExecutionContext(isolate);
ASSERT(executionContext && executionContext->isContextThread());
executionContext->postTask(adoptPtr(new CallHandlerTask(promise, handler, argument, originatorState, isolate, executionContext)));
}