summaryrefslogtreecommitdiff
path: root/fxjse/class.cpp
diff options
context:
space:
mode:
authorjochen <jochen@chromium.org>2016-07-06 05:26:23 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-06 05:26:23 -0700
commitc4dedf32b1f5c71740df5be2a9b1446a01df304c (patch)
treec435b0a5d64c9827cca9b56b4bb12995342c90c0 /fxjse/class.cpp
parent2798a7a6549ddddaeb8d4d7f7c31b96aa5e6edd3 (diff)
downloadpdfium-c4dedf32b1f5c71740df5be2a9b1446a01df304c.tar.xz
Remove prototypes from v8 functions that aren't constructors
BUG=chromium:625823 R=haraken@chromium.org,thestig@chromium.org Review-Url: https://codereview.chromium.org/2123153002
Diffstat (limited to 'fxjse/class.cpp')
-rw-r--r--fxjse/class.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/fxjse/class.cpp b/fxjse/class.cpp
index 1dba7f073f..a4ed0916bd 100644
--- a/fxjse/class.cpp
+++ b/fxjse/class.cpp
@@ -104,6 +104,9 @@ static void FXJSE_V8SetterCallback_Wrapper(
static void FXJSE_V8ConstructorCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
+ if (!info.IsConstructCall()) {
+ return;
+ }
const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
static_cast<FXJSE_CLASS_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
@@ -228,13 +231,14 @@ CFXJSE_Class* CFXJSE_Class::Create(
}
if (lpClassDefinition->methNum) {
for (int32_t i = 0; i < lpClassDefinition->methNum; i++) {
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
+ pIsolate, FXJSE_V8FunctionCallback_Wrapper,
+ v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
+ lpClassDefinition->methods + i)));
+ fun->RemovePrototype();
hObjectTemplate->Set(
v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name),
- v8::FunctionTemplate::New(
- pIsolate, FXJSE_V8FunctionCallback_Wrapper,
- v8::External::New(pIsolate,
- const_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
- lpClassDefinition->methods + i))),
+ fun,
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
}
}
@@ -260,12 +264,12 @@ CFXJSE_Class* CFXJSE_Class::Create(
}
}
if (bIsJSGlobal) {
- hObjectTemplate->Set(
- v8::String::NewFromUtf8(pIsolate, "toString"),
- v8::FunctionTemplate::New(
- pIsolate, FXJSE_Context_GlobalObjToString,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(
- lpClassDefinition))));
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
+ pIsolate, FXJSE_Context_GlobalObjToString,
+ v8::External::New(
+ pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
+ fun->RemovePrototype();
+ hObjectTemplate->Set(v8::String::NewFromUtf8(pIsolate, "toString"), fun);
}
pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate);
lpContext->m_rgClasses.push_back(std::unique_ptr<CFXJSE_Class>(pClass));