blob: 7eaf1451ca71f9d4642b2a84d18e29cbdb906fde [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
dsinclair64376be2016-03-31 20:03:24 -07007#include "fpdfsdk/javascript/cjs_runtime.h"
Tom Sepez37458412015-10-06 11:33:46 -07008
tsepez41a53ad2016-03-28 16:59:30 -07009#include <algorithm>
10
dsinclair64376be2016-03-31 20:03:24 -070011#include "fpdfsdk/include/fsdk_mgr.h"
Dan Sinclairf766ad22016-03-14 13:51:24 -040012#include "fpdfsdk/javascript/Consts.h"
13#include "fpdfsdk/javascript/Document.h"
14#include "fpdfsdk/javascript/Field.h"
15#include "fpdfsdk/javascript/Icon.h"
Dan Sinclairf766ad22016-03-14 13:51:24 -040016#include "fpdfsdk/javascript/JS_Define.h"
17#include "fpdfsdk/javascript/JS_EventHandler.h"
18#include "fpdfsdk/javascript/JS_GlobalData.h"
19#include "fpdfsdk/javascript/JS_Object.h"
20#include "fpdfsdk/javascript/JS_Value.h"
21#include "fpdfsdk/javascript/PublicMethods.h"
22#include "fpdfsdk/javascript/app.h"
dsinclair89bdd082016-04-06 10:47:54 -070023#include "fpdfsdk/javascript/cjs_context.h"
Dan Sinclairf766ad22016-03-14 13:51:24 -040024#include "fpdfsdk/javascript/color.h"
25#include "fpdfsdk/javascript/console.h"
26#include "fpdfsdk/javascript/event.h"
27#include "fpdfsdk/javascript/global.h"
28#include "fpdfsdk/javascript/report.h"
29#include "fpdfsdk/javascript/util.h"
Lei Zhangcd2bb302015-12-22 13:49:44 -080030#include "third_party/base/stl_util.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070031
Tom Sepez40e9ff32015-11-30 12:39:54 -080032#ifdef PDF_ENABLE_XFA
dsinclair89bdd082016-04-06 10:47:54 -070033#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
dsinclair08fea802016-07-12 10:37:52 -070034#include "fxjs/include/cfxjse_value.h"
Tom Sepez40e9ff32015-11-30 12:39:54 -080035#endif // PDF_ENABLE_XFA
36
Tom Sepez67fd5df2015-10-08 12:24:19 -070037// static
Tom Sepez452b4f32015-10-13 09:27:27 -070038void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {
39 FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate));
40}
41
42// static
thestig2d6dda12016-06-28 07:39:09 -070043void IJS_Runtime::Destroy() {
44 FXJS_Release();
45}
46
47// static
Tom Sepezba038bc2015-10-08 12:03:00 -070048IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) {
Tom Sepez37458412015-10-06 11:33:46 -070049 return new CJS_Runtime(pEnv);
50}
51
Tom Sepez67fd5df2015-10-08 12:24:19 -070052// static
53CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) {
54 const CJS_Context* pContext = static_cast<const CJS_Context*>(cc);
55 return pContext->GetJSRuntime();
56}
57
Nico Weber9d8ec5a2015-08-04 13:00:21 -070058CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
59 : m_pApp(pApp),
thestig1cd352e2016-06-07 17:53:06 -070060 m_pDocument(nullptr),
Nico Weber9d8ec5a2015-08-04 13:00:21 -070061 m_bBlocking(FALSE),
thestig1cd352e2016-06-07 17:53:06 -070062 m_isolate(nullptr),
Jochen Eisinger29007842015-08-05 09:02:13 +020063 m_isolateManaged(false) {
Tom Sepez51da0932015-11-25 16:05:49 -080064#ifndef PDF_ENABLE_XFA
65 IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform;
66 if (pPlatform->version <= 2) {
67 unsigned int embedderDataSlot = 0;
68 v8::Isolate* pExternalIsolate = nullptr;
69 if (pPlatform->version == 2) {
70 pExternalIsolate = reinterpret_cast<v8::Isolate*>(pPlatform->m_isolate);
71 embedderDataSlot = pPlatform->m_v8EmbedderSlot;
dsinclaird71bae02016-06-09 14:21:20 -070072 }
73 FXJS_Initialize(embedderDataSlot, pExternalIsolate);
74 }
75 m_isolateManaged = FXJS_GetIsolate(&m_isolate);
Tom Sepez51da0932015-11-25 16:05:49 -080076#else
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 if (CPDFXFA_App::GetInstance()->GetJSERuntime()) {
78 // TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate.
79 m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime();
Tom Sepeza72e8e22015-10-07 10:17:53 -070080 } else {
81 IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform;
82 if (pPlatform->version <= 2) {
83 unsigned int embedderDataSlot = 0;
84 v8::Isolate* pExternalIsolate = nullptr;
85 if (pPlatform->version == 2) {
86 pExternalIsolate = reinterpret_cast<v8::Isolate*>(pPlatform->m_isolate);
87 embedderDataSlot = pPlatform->m_v8EmbedderSlot;
88 }
89 FXJS_Initialize(embedderDataSlot, pExternalIsolate);
90 }
91 m_isolateManaged = FXJS_GetIsolate(&m_isolate);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070092 }
Tom Sepezd2cc1b92015-04-30 15:19:03 -070093
Nico Weber9d8ec5a2015-08-04 13:00:21 -070094 v8::Isolate* isolate = m_isolate;
95 v8::Isolate::Scope isolate_scope(isolate);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070096 v8::HandleScope handle_scope(isolate);
Tom Sepezed7b2b52015-09-22 08:36:17 -070097 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070098 CJS_Context* pContext = (CJS_Context*)NewContext();
Tom Sepez4237aed2015-11-10 15:19:17 -080099 FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700100 ReleaseContext(pContext);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700101 return;
102 }
Tom Sepez51da0932015-11-25 16:05:49 -0800103#endif
dsinclaird71bae02016-06-09 14:21:20 -0700104
Lei Zhang3fa115b2015-10-08 12:04:47 -0700105 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
106 DefineJSObjects();
107
Tom Sepez51da0932015-11-25 16:05:49 -0800108#ifdef PDF_ENABLE_XFA
Tom Sepezed7b2b52015-09-22 08:36:17 -0700109 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE);
Tom Sepez51da0932015-11-25 16:05:49 -0800110#endif
dsinclaird71bae02016-06-09 14:21:20 -0700111
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112 CJS_Context* pContext = (CJS_Context*)NewContext();
Tom Sepez4237aed2015-11-10 15:19:17 -0800113 FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114 ReleaseContext(pContext);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115}
116
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700117CJS_Runtime::~CJS_Runtime() {
Lei Zhang2d5a0e12015-10-05 17:00:03 -0700118 for (auto* obs : m_observers)
119 obs->OnDestroyed();
120
tsepez41a53ad2016-03-28 16:59:30 -0700121 m_ContextArray.clear();
Tom Sepez297b5152016-03-04 13:43:46 -0800122 m_ConstArrays.clear();
Tom Sepez51da0932015-11-25 16:05:49 -0800123 FXJS_ReleaseRuntime(GetIsolate(), &m_context, &m_StaticObjects);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700124 m_context.Reset();
Jochen Eisinger29007842015-08-05 09:02:13 +0200125 if (m_isolateManaged)
126 m_isolate->Dispose();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700127}
128
Tom Sepez142165e2015-09-11 13:21:50 -0700129void CJS_Runtime::DefineJSObjects() {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700130 v8::Isolate::Scope isolate_scope(GetIsolate());
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 v8::HandleScope handle_scope(GetIsolate());
132 v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
133 v8::Context::Scope context_scope(context);
Tom Sepez570875c2015-09-11 08:35:03 -0700134
135 // The call order determines the "ObjDefID" assigned to each class.
136 // ObjDefIDs 0 - 2
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700137 CJS_Border::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
138 CJS_Display::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
139 CJS_Font::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140
Tom Sepez570875c2015-09-11 08:35:03 -0700141 // ObjDefIDs 3 - 5
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700142 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
143 CJS_Position::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
144 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700145
Tom Sepez570875c2015-09-11 08:35:03 -0700146 // ObjDefIDs 6 - 8
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700147 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
148 CJS_Style::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
149 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150
Tom Sepez570875c2015-09-11 08:35:03 -0700151 // ObjDefIDs 9 - 11
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700152 CJS_App::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
153 CJS_Color::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
154 CJS_Console::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700155
Tom Sepez570875c2015-09-11 08:35:03 -0700156 // ObjDefIDs 12 - 14
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700157 CJS_Document::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_GLOBAL);
158 CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
159 CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700160
Tom Sepez570875c2015-09-11 08:35:03 -0700161 // ObjDefIDs 15 - 17
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700162 CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
163 CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
164 CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
Tom Sepez570875c2015-09-11 08:35:03 -0700165
Tom Sepez142165e2015-09-11 13:21:50 -0700166 // ObjDefIDs 18 - 20 (these can't fail, return void).
167 CJS_PublicMethods::DefineJSObjects(GetIsolate());
Tom Sepez67fd5df2015-10-08 12:24:19 -0700168 CJS_GlobalConsts::DefineJSObjects(this);
169 CJS_GlobalArrays::DefineJSObjects(this);
Tom Sepez570875c2015-09-11 08:35:03 -0700170
Tom Sepez142165e2015-09-11 13:21:50 -0700171 // ObjDefIDs 21 - 22.
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700172 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
173 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700174}
175
Tom Sepezba038bc2015-10-08 12:03:00 -0700176IJS_Context* CJS_Runtime::NewContext() {
tsepez41a53ad2016-03-28 16:59:30 -0700177 m_ContextArray.push_back(std::unique_ptr<CJS_Context>(new CJS_Context(this)));
178 return m_ContextArray.back().get();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700179}
180
Tom Sepezba038bc2015-10-08 12:03:00 -0700181void CJS_Runtime::ReleaseContext(IJS_Context* pContext) {
tsepez41a53ad2016-03-28 16:59:30 -0700182 for (auto it = m_ContextArray.begin(); it != m_ContextArray.end(); ++it) {
183 if (it->get() == static_cast<CJS_Context*>(pContext)) {
184 m_ContextArray.erase(it);
185 return;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186 }
187 }
188}
189
Tom Sepezba038bc2015-10-08 12:03:00 -0700190IJS_Context* CJS_Runtime::GetCurrentContext() {
tsepez41a53ad2016-03-28 16:59:30 -0700191 return m_ContextArray.empty() ? nullptr : m_ContextArray.back().get();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700192}
193
194void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
195 if (m_pDocument != pReaderDoc) {
196 v8::Isolate::Scope isolate_scope(m_isolate);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700197 v8::HandleScope handle_scope(m_isolate);
198 v8::Local<v8::Context> context =
199 v8::Local<v8::Context>::New(m_isolate, m_context);
200 v8::Context::Scope context_scope(context);
201
202 m_pDocument = pReaderDoc;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700203 if (pReaderDoc) {
Tom Sepez39bfe122015-09-17 15:25:23 -0700204 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate());
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700205 if (!pThis.IsEmpty()) {
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700206 if (FXJS_GetObjDefnID(pThis) == CJS_Document::g_nObjDefnID) {
Tom Sepez39bfe122015-09-17 15:25:23 -0700207 if (CJS_Document* pJSDocument =
Tom Sepezd5a0e952015-09-17 15:40:06 -0700208 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())
210 pDocument->AttachDoc(pReaderDoc);
211 }
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700212 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213 }
Tom Sepez2f2ffec2015-07-23 14:42:09 -0700214 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700216}
217
weili625ad662016-06-15 11:21:33 -0700218CPDFSDK_Document* CJS_Runtime::GetReaderDocument() {
219 return m_pDocument;
220}
221
dsinclair884b4f92016-06-06 09:49:32 -0700222int CJS_Runtime::Execute(const CFX_WideString& script, CFX_WideString* info) {
Tom Sepez33420902015-10-13 15:00:10 -0700223 FXJSErr error = {};
dsinclair884b4f92016-06-06 09:49:32 -0700224 int nRet = FXJS_Execute(m_isolate, script, &error);
Tom Sepez33420902015-10-13 15:00:10 -0700225 if (nRet < 0) {
226 info->Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline,
227 error.message);
228 }
229 return nRet;
230}
231
Tom Sepez5d0e8432015-09-22 15:50:03 -0700232bool CJS_Runtime::AddEventToSet(const FieldEvent& event) {
233 return m_FieldEventSet.insert(event).second;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700234}
235
Tom Sepez5d0e8432015-09-22 15:50:03 -0700236void CJS_Runtime::RemoveEventFromSet(const FieldEvent& event) {
237 m_FieldEventSet.erase(event);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700238}
239
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700240v8::Local<v8::Context> CJS_Runtime::NewJSContext() {
241 return v8::Local<v8::Context>::New(m_isolate, m_context);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700242}
243
Tom Sepez297b5152016-03-04 13:43:46 -0800244void CJS_Runtime::SetConstArray(const CFX_WideString& name,
245 v8::Local<v8::Array> array) {
246 m_ConstArrays[name] = v8::Global<v8::Array>(m_isolate, array);
247}
248
249v8::Local<v8::Array> CJS_Runtime::GetConstArray(const CFX_WideString& name) {
250 return v8::Local<v8::Array>::New(m_isolate, m_ConstArrays[name]);
251}
252
dsinclaird71bae02016-06-09 14:21:20 -0700253void CJS_Runtime::AddObserver(Observer* observer) {
254 ASSERT(!pdfium::ContainsKey(m_observers, observer));
255 m_observers.insert(observer);
256}
257
258void CJS_Runtime::RemoveObserver(Observer* observer) {
259 ASSERT(pdfium::ContainsKey(m_observers, observer));
260 m_observers.erase(observer);
261}
262
Tom Sepez51da0932015-11-25 16:05:49 -0800263#ifdef PDF_ENABLE_XFA
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700264CFX_WideString ChangeObjName(const CFX_WideString& str) {
265 CFX_WideString sRet = str;
266 sRet.Replace(L"_", L".");
267 return sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700268}
dsinclair12a6b0c2016-05-26 11:14:08 -0700269FX_BOOL CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
270 CFXJSE_Value* pValue) {
dsinclair179bebb2016-04-05 11:02:18 -0700271 const FX_CHAR* name = utf8Name.c_str();
Bo Xufdc00a72014-10-28 23:03:33 -0700272
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700273 v8::Isolate::Scope isolate_scope(GetIsolate());
274 v8::HandleScope handle_scope(GetIsolate());
Tom Sepez4f4603c2015-11-10 15:03:12 -0800275 v8::Local<v8::Context> old_context = GetIsolate()->GetCurrentContext();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700276 v8::Local<v8::Context> context =
277 v8::Local<v8::Context>::New(GetIsolate(), m_context);
278 v8::Context::Scope context_scope(context);
Bo Xufdc00a72014-10-28 23:03:33 -0700279
Tom Sepez4f4603c2015-11-10 15:03:12 -0800280 // Caution: We're about to hand to XFA an object that in order to invoke
281 // methods will require that the current v8::Context always has a pointer
282 // to a CJS_Runtime in its embedder data slot. Unfortunately, XFA creates
283 // its own v8::Context which has not initialized the embedder data slot.
284 // Do so now.
285 // TODO(tsepez): redesign PDF-side objects to not rely on v8::Context's
286 // embedder data slots, and/or to always use the right context.
287 FXJS_SetRuntimeForV8Context(old_context, this);
288
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700289 v8::Local<v8::Value> propvalue =
290 context->Global()->Get(v8::String::NewFromUtf8(
291 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength()));
Bo Xufdc00a72014-10-28 23:03:33 -0700292
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700293 if (propvalue.IsEmpty()) {
dsinclairf27aeec2016-06-07 19:36:18 -0700294 pValue->SetUndefined();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700295 return FALSE;
296 }
dsinclair12a6b0c2016-05-26 11:14:08 -0700297 pValue->ForceSetValue(propvalue);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700298 return TRUE;
Bo Xufdc00a72014-10-28 23:03:33 -0700299}
dsinclair12a6b0c2016-05-26 11:14:08 -0700300FX_BOOL CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name,
301 CFXJSE_Value* pValue) {
dsinclair12a6b0c2016-05-26 11:14:08 -0700302 if (utf8Name.IsEmpty() || !pValue)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700303 return FALSE;
dsinclair179bebb2016-04-05 11:02:18 -0700304 const FX_CHAR* name = utf8Name.c_str();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700305 v8::Isolate* pIsolate = GetIsolate();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700306 v8::Isolate::Scope isolate_scope(pIsolate);
307 v8::HandleScope handle_scope(pIsolate);
308 v8::Local<v8::Context> context =
309 v8::Local<v8::Context>::New(pIsolate, m_context);
310 v8::Context::Scope context_scope(context);
Bo Xufdc00a72014-10-28 23:03:33 -0700311
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700312 // v8::Local<v8::Context> tmpCotext =
313 // v8::Local<v8::Context>::New(GetIsolate(), m_context);
dsinclair12a6b0c2016-05-26 11:14:08 -0700314 v8::Local<v8::Value> propvalue =
315 v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue());
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700316 context->Global()->Set(
317 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString,
318 utf8Name.GetLength()),
319 propvalue);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700320 return TRUE;
Bo Xufdc00a72014-10-28 23:03:33 -0700321}
Tom Sepez51da0932015-11-25 16:05:49 -0800322#endif