7#include "fxjs/xfa/cfxjse_runtimedata.h"
11#include "fxjs/cfxjs_engine.h"
13#include "fxjs/xfa/cfxjse_isolatetracker.h"
14#include "third_party/base/check_op.h"
15#include "v8/include/v8-context.h"
16#include "v8/include/v8-external.h"
17#include "v8/include/v8-isolate.h"
18#include "v8/include/v8-object.h"
19#include "v8/include/v8-primitive.h"
20#include "v8/include/v8-template.h"
22CFXJSE_RuntimeData::CFXJSE_RuntimeData() =
default;
26std::unique_ptr<CFXJSE_RuntimeData> CFXJSE_RuntimeData::Create(
27 v8::Isolate* pIsolate) {
28 std::unique_ptr<CFXJSE_RuntimeData> pRuntimeData(
new CFXJSE_RuntimeData());
30 v8::Local<v8::FunctionTemplate> hFuncTemplate =
31 v8::FunctionTemplate::New(pIsolate);
33 v8::Local<v8::ObjectTemplate> hGlobalTemplate =
34 hFuncTemplate->InstanceTemplate();
35 hGlobalTemplate->Set(v8::Symbol::GetToStringTag(pIsolate),
36 fxv8::NewStringHelper(pIsolate,
"global"));
38 v8::Local<v8::Context> hContext =
39 v8::Context::New(pIsolate,
nullptr, hGlobalTemplate);
41 DCHECK_EQ(hContext->Global()->InternalFieldCount(), 0);
43 hContext->Global()->GetPrototype().As<v8::Object>()->InternalFieldCount(),
46 hContext->SetSecurityToken(v8::External::New(pIsolate, pIsolate));
47 pRuntimeData->root_context_global_template_.Reset(pIsolate, hFuncTemplate);
48 pRuntimeData->root_context_.Reset(pIsolate, hContext);
52CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
53 FXJS_PerIsolateData::SetUp(pIsolate);
55 if (!pData->GetExtension())
56 pData->SetExtension(CFXJSE_RuntimeData::Create(pIsolate));
61 v8::Isolate* pIsolate) {
62 return v8::Local<v8::Context>::New(pIsolate, root_context_);
v8::Local< v8::Context > GetRootContext(v8::Isolate *pIsolate)
~CFXJSE_RuntimeData() override
ExtensionIface * GetExtension()