| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! | 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! |
| 32 | 32 |
| 33 #include "config.h" | 33 #include "config.h" |
| 34 #include "V8TestActiveDOMObject.h" | 34 #include "V8TestCheckSecurityInterface.h" |
| 35 | 35 |
| 36 #include "RuntimeEnabledFeatures.h" | 36 #include "RuntimeEnabledFeatures.h" |
| 37 #include "V8Node.h" | 37 #include "V8Node.h" |
| 38 #include "bindings/v8/BindingSecurity.h" | 38 #include "bindings/v8/BindingSecurity.h" |
| 39 #include "bindings/v8/ExceptionMessages.h" | 39 #include "bindings/v8/ExceptionMessages.h" |
| 40 #include "bindings/v8/ExceptionState.h" | 40 #include "bindings/v8/ExceptionState.h" |
| 41 #include "bindings/v8/ScriptController.h" | 41 #include "bindings/v8/ScriptController.h" |
| 42 #include "bindings/v8/V8Binding.h" | 42 #include "bindings/v8/V8Binding.h" |
| 43 #include "bindings/v8/V8DOMActivityLogger.h" | 43 #include "bindings/v8/V8DOMActivityLogger.h" |
| 44 #include "bindings/v8/V8DOMConfiguration.h" | 44 #include "bindings/v8/V8DOMConfiguration.h" |
| 45 #include "bindings/v8/V8DOMWrapper.h" | 45 #include "bindings/v8/V8DOMWrapper.h" |
| 46 #include "core/dom/ContextFeatures.h" | 46 #include "core/dom/ContextFeatures.h" |
| 47 #include "core/dom/Document.h" | 47 #include "core/dom/Document.h" |
| 48 #include "platform/TraceEvent.h" | 48 #include "platform/TraceEvent.h" |
| 49 #include "wtf/UnusedParam.h" | 49 #include "wtf/UnusedParam.h" |
| 50 | 50 |
| 51 namespace WebCore { | 51 namespace WebCore { |
| 52 | 52 |
| 53 static void initializeScriptWrappableForInterface(TestActiveDOMObject* object) | 53 static void initializeScriptWrappableForInterface(TestCheckSecurityInterface* ob
ject) |
| 54 { | 54 { |
| 55 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | 55 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
| 56 ScriptWrappable::setTypeInfoInObject(object, &V8TestActiveDOMObject::wra
pperTypeInfo); | 56 ScriptWrappable::setTypeInfoInObject(object, &V8TestCheckSecurityInterfa
ce::wrapperTypeInfo); |
| 57 else | 57 else |
| 58 ASSERT_NOT_REACHED(); | 58 ASSERT_NOT_REACHED(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace WebCore | 61 } // namespace WebCore |
| 62 | 62 |
| 63 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: | 63 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: |
| 64 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function | 64 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function |
| 65 // in the global namespace. | 65 // in the global namespace. |
| 66 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) | 66 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) |
| 67 void webCoreInitializeScriptWrappableForInterface(WebCore::TestActiveDOMObject*
object) | 67 void webCoreInitializeScriptWrappableForInterface(WebCore::TestCheckSecurityInte
rface* object) |
| 68 { | 68 { |
| 69 WebCore::initializeScriptWrappableForInterface(object); | 69 WebCore::initializeScriptWrappableForInterface(object); |
| 70 } | 70 } |
| 71 | 71 |
| 72 namespace WebCore { | 72 namespace WebCore { |
| 73 const WrapperTypeInfo V8TestActiveDOMObject::wrapperTypeInfo = { V8TestActiveDOM
Object::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0, 0, V8TestActiveDO
MObject::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype }; | 73 const WrapperTypeInfo V8TestCheckSecurityInterface::wrapperTypeInfo = { V8TestCh
eckSecurityInterface::GetTemplate, V8TestCheckSecurityInterface::derefObject, 0,
0, 0, V8TestCheckSecurityInterface::installPerContextEnabledMethods, 0, Wrapper
TypeObjectPrototype }; |
| 74 | 74 |
| 75 namespace TestActiveDOMObjectV8Internal { | 75 namespace TestCheckSecurityInterfaceV8Internal { |
| 76 | 76 |
| 77 template <typename T> void V8_USE(T) { } | 77 template <typename T> void V8_USE(T) { } |
| 78 | 78 |
| 79 static void excitingAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value
>& info) | 79 static void excitingAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value
>& info) |
| 80 { | 80 { |
| 81 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder()); | 81 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf
o.Holder()); |
| 82 v8SetReturnValueInt(info, imp->excitingAttr()); | 82 v8SetReturnValueInt(info, imp->excitingAttr()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 static void excitingAttrAttributeGetterCallback(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) | 85 static void excitingAttrAttributeGetterCallback(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) |
| 86 { | 86 { |
| 87 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 87 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 88 TestActiveDOMObjectV8Internal::excitingAttrAttributeGetter(info); | 88 TestCheckSecurityInterfaceV8Internal::excitingAttrAttributeGetter(info); |
| 89 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 89 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) | 92 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) |
| 93 { | 93 { |
| 94 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(host); | 94 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(ho
st); |
| 95 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); | 95 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
::AccessType type, v8::Local<v8::Value>) | 98 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
::AccessType type, v8::Local<v8::Value>) |
| 99 { | 99 { |
| 100 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(host); | 100 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(ho
st); |
| 101 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); | 101 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe
curityError); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static void excitingFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>& in
fo) | 104 static void excitingFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>& in
fo) |
| 105 { | 105 { |
| 106 if (UNLIKELY(info.Length() < 1)) { | 106 if (UNLIKELY(info.Length() < 1)) { |
| 107 throwTypeError(ExceptionMessages::failedToExecute("excitingFunction", "T
estActiveDOMObject", ExceptionMessages::notEnoughArguments(1, info.Length())), i
nfo.GetIsolate()); | 107 throwTypeError(ExceptionMessages::failedToExecute("excitingFunction", "T
estCheckSecurityInterface", ExceptionMessages::notEnoughArguments(1, info.Length
())), info.GetIsolate()); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder()); | 110 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf
o.Holder()); |
| 111 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 111 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 112 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { | 112 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 113 exceptionState.throwIfNeeded(); | 113 exceptionState.throwIfNeeded(); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 V8TRYCATCH_VOID(Node*, nextChild, V8Node::hasInstance(info[0], info.GetIsola
te(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::C
ast(info[0])) : 0); | 116 V8TRYCATCH_VOID(Node*, nextChild, V8Node::hasInstance(info[0], info.GetIsola
te(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::C
ast(info[0])) : 0); |
| 117 imp->excitingFunction(nextChild); | 117 imp->excitingFunction(nextChild); |
| 118 } | 118 } |
| 119 | 119 |
| 120 static void excitingFunctionMethodCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 120 static void excitingFunctionMethodCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 121 { | 121 { |
| 122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 123 TestActiveDOMObjectV8Internal::excitingFunctionMethod(info); | 123 TestCheckSecurityInterfaceV8Internal::excitingFunctionMethod(info); |
| 124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 125 } | 125 } |
| 126 | 126 |
| 127 static void postMessageMethod(const v8::FunctionCallbackInfo<v8::Value>& info) | 127 static void postMessageMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 128 { | 128 { |
| 129 if (UNLIKELY(info.Length() < 1)) { | 129 if (UNLIKELY(info.Length() < 1)) { |
| 130 throwTypeError(ExceptionMessages::failedToExecute("postMessage", "TestAc
tiveDOMObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.G
etIsolate()); | 130 throwTypeError(ExceptionMessages::failedToExecute("postMessage", "TestCh
eckSecurityInterface", ExceptionMessages::notEnoughArguments(1, info.Length())),
info.GetIsolate()); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder()); | 133 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf
o.Holder()); |
| 134 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, message, info[0]); | 134 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, message, info[0]); |
| 135 imp->postMessage(message); | 135 imp->postMessage(message); |
| 136 } | 136 } |
| 137 | 137 |
| 138 static void postMessageMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&
info) | 138 static void postMessageMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 139 { | 139 { |
| 140 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 140 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 141 TestActiveDOMObjectV8Internal::postMessageMethod(info); | 141 TestCheckSecurityInterfaceV8Internal::postMessageMethod(info); |
| 142 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 142 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 143 } | 143 } |
| 144 | 144 |
| 145 static void postMessageAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>
& info) | 145 static void postMessageAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>
& info) |
| 146 { | 146 { |
| 147 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 147 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
| 148 static int privateTemplateUniqueKey; | 148 static int privateTemplateUniqueKey; |
| 149 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 149 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
| 150 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 150 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
| 151 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::postMes
sageMethodCallback, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(inf
o.GetIsolate())->rawTemplate(&V8TestActiveDOMObject::wrapperTypeInfo, currentWor
ldType)), 1); | 151 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal::
postMessageMethodCallback, v8Undefined(), v8::Signature::New(V8PerIsolateData::f
rom(info.GetIsolate())->rawTemplate(&V8TestCheckSecurityInterface::wrapperTypeIn
fo, currentWorldType)), 1); |
| 152 | 152 |
| 153 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType)); | 153 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType)); |
| 154 if (holder.IsEmpty()) { | 154 if (holder.IsEmpty()) { |
| 155 // can only reach here by 'object.__proto__.func', and it should passed | 155 // can only reach here by 'object.__proto__.func', and it should passed |
| 156 // domain security check already | 156 // domain security check already |
| 157 v8SetReturnValue(info, privateTemplate->GetFunction()); | 157 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 158 return; | 158 return; |
| 159 } | 159 } |
| 160 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder); | 160 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol
der); |
| 161 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { | 161 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { |
| 162 static int sharedTemplateUniqueKey; | 162 static int sharedTemplateUniqueKey; |
| 163 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::postM
essageMethodCallback, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(i
nfo.GetIsolate())->rawTemplate(&V8TestActiveDOMObject::wrapperTypeInfo, currentW
orldType)), 1); | 163 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal
::postMessageMethodCallback, v8Undefined(), v8::Signature::New(V8PerIsolateData:
:from(info.GetIsolate())->rawTemplate(&V8TestCheckSecurityInterface::wrapperType
Info, currentWorldType)), 1); |
| 164 v8SetReturnValue(info, sharedTemplate->GetFunction()); | 164 v8SetReturnValue(info, sharedTemplate->GetFunction()); |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 | 167 |
| 168 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("postMessage")); | 168 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("postMessage")); |
| 169 if (!hiddenValue.IsEmpty()) { | 169 if (!hiddenValue.IsEmpty()) { |
| 170 v8SetReturnValue(info, hiddenValue); | 170 v8SetReturnValue(info, hiddenValue); |
| 171 return; | 171 return; |
| 172 } | 172 } |
| 173 | 173 |
| 174 v8SetReturnValue(info, privateTemplate->GetFunction()); | 174 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 static void postMessageAttributeGetterCallback(v8::Local<v8::String>, const v8::
PropertyCallbackInfo<v8::Value>& info) | 177 static void postMessageAttributeGetterCallback(v8::Local<v8::String>, const v8::
PropertyCallbackInfo<v8::Value>& info) |
| 178 { | 178 { |
| 179 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 179 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 180 TestActiveDOMObjectV8Internal::postMessageAttributeGetter(info); | 180 TestCheckSecurityInterfaceV8Internal::postMessageAttributeGetter(info); |
| 181 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 181 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 182 } | 182 } |
| 183 | 183 |
| 184 static void perWorldBindingsMethodWithDoNotCheckSecurityMethod(const v8::Functio
nCallbackInfo<v8::Value>& info) | 184 static void perWorldBindingsMethodWithDoNotCheckSecurityMethod(const v8::Functio
nCallbackInfo<v8::Value>& info) |
| 185 { | 185 { |
| 186 if (UNLIKELY(info.Length() < 1)) { | 186 if (UNLIKELY(info.Length() < 1)) { |
| 187 throwTypeError(ExceptionMessages::failedToExecute("perWorldBindingsMetho
dWithDoNotCheckSecurity", "TestActiveDOMObject", ExceptionMessages::notEnoughArg
uments(1, info.Length())), info.GetIsolate()); | 187 throwTypeError(ExceptionMessages::failedToExecute("perWorldBindingsMetho
dWithDoNotCheckSecurity", "TestCheckSecurityInterface", ExceptionMessages::notEn
oughArguments(1, info.Length())), info.GetIsolate()); |
| 188 return; | 188 return; |
| 189 } | 189 } |
| 190 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder()); | 190 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf
o.Holder()); |
| 191 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, url, info[0]); | 191 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, url, info[0]); |
| 192 imp->perWorldBindingsMethodWithDoNotCheckSecurity(url); | 192 imp->perWorldBindingsMethodWithDoNotCheckSecurity(url); |
| 193 } | 193 } |
| 194 | 194 |
| 195 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodCallback(const v8:
:FunctionCallbackInfo<v8::Value>& info) | 195 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodCallback(const v8:
:FunctionCallbackInfo<v8::Value>& info) |
| 196 { | 196 { |
| 197 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 197 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 198 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); | 198 V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->Ge
tCurrentContext()); |
| 199 if (contextData && contextData->activityLogger()) { | 199 if (contextData && contextData->activityLogger()) { |
| 200 Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle
<v8::Value> >(info, 0); | 200 Vector<v8::Handle<v8::Value> > loggerArgs = toNativeArguments<v8::Handle
<v8::Value> >(info, 0); |
| 201 contextData->activityLogger()->log("TestActiveDOMObject.perWorldBindings
MethodWithDoNotCheckSecurity", info.Length(), loggerArgs.data(), "Method"); | 201 contextData->activityLogger()->log("TestCheckSecurityInterface.perWorldB
indingsMethodWithDoNotCheckSecurity", info.Length(), loggerArgs.data(), "Method"
); |
| 202 } | 202 } |
| 203 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityM
ethod(info); | 203 TestCheckSecurityInterfaceV8Internal::perWorldBindingsMethodWithDoNotCheckSe
curityMethod(info); |
| 204 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 204 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 205 } | 205 } |
| 206 | 206 |
| 207 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetter(const v8
::PropertyCallbackInfo<v8::Value>& info) | 207 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetter(const v8
::PropertyCallbackInfo<v8::Value>& info) |
| 208 { | 208 { |
| 209 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 209 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
| 210 static int privateTemplateUniqueKey; | 210 static int privateTemplateUniqueKey; |
| 211 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 211 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
| 212 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 212 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
| 213 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWorl
dBindingsMethodWithDoNotCheckSecurityMethodCallback, v8Undefined(), v8::Signatur
e::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestActiveDOMOb
ject::wrapperTypeInfo, currentWorldType)), 1); | 213 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal::
perWorldBindingsMethodWithDoNotCheckSecurityMethodCallback, v8Undefined(), v8::S
ignature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestChec
kSecurityInterface::wrapperTypeInfo, currentWorldType)), 1); |
| 214 | 214 |
| 215 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType)); | 215 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType)); |
| 216 if (holder.IsEmpty()) { | 216 if (holder.IsEmpty()) { |
| 217 // can only reach here by 'object.__proto__.func', and it should passed | 217 // can only reach here by 'object.__proto__.func', and it should passed |
| 218 // domain security check already | 218 // domain security check already |
| 219 v8SetReturnValue(info, privateTemplate->GetFunction()); | 219 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder); | 222 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol
der); |
| 223 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { | 223 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { |
| 224 static int sharedTemplateUniqueKey; | 224 static int sharedTemplateUniqueKey; |
| 225 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWo
rldBindingsMethodWithDoNotCheckSecurityMethodCallback, v8Undefined(), v8::Signat
ure::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestActiveDOM
Object::wrapperTypeInfo, currentWorldType)), 1); | 225 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal
::perWorldBindingsMethodWithDoNotCheckSecurityMethodCallback, v8Undefined(), v8:
:Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8TestCh
eckSecurityInterface::wrapperTypeInfo, currentWorldType)), 1); |
| 226 v8SetReturnValue(info, sharedTemplate->GetFunction()); | 226 v8SetReturnValue(info, sharedTemplate->GetFunction()); |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 | 229 |
| 230 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("perWorldBindingsMethodWithDoNotCheckSecurity")); | 230 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("perWorldBindingsMethodWithDoNotCheckSecurity")); |
| 231 if (!hiddenValue.IsEmpty()) { | 231 if (!hiddenValue.IsEmpty()) { |
| 232 v8SetReturnValue(info, hiddenValue); | 232 v8SetReturnValue(info, hiddenValue); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 | 235 |
| 236 v8SetReturnValue(info, privateTemplate->GetFunction()); | 236 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 237 } | 237 } |
| 238 | 238 |
| 239 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterCallback(
v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) | 239 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterCallback(
v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 240 { | 240 { |
| 241 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 241 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 242 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityA
ttributeGetter(info); | 242 TestCheckSecurityInterfaceV8Internal::perWorldBindingsMethodWithDoNotCheckSe
curityAttributeGetter(info); |
| 243 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 243 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 244 } | 244 } |
| 245 | 245 |
| 246 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodForMainWorld(const
v8::FunctionCallbackInfo<v8::Value>& info) | 246 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodForMainWorld(const
v8::FunctionCallbackInfo<v8::Value>& info) |
| 247 { | 247 { |
| 248 if (UNLIKELY(info.Length() < 1)) { | 248 if (UNLIKELY(info.Length() < 1)) { |
| 249 throwTypeError(ExceptionMessages::failedToExecute("perWorldBindingsMetho
dWithDoNotCheckSecurity", "TestActiveDOMObject", ExceptionMessages::notEnoughArg
uments(1, info.Length())), info.GetIsolate()); | 249 throwTypeError(ExceptionMessages::failedToExecute("perWorldBindingsMetho
dWithDoNotCheckSecurity", "TestCheckSecurityInterface", ExceptionMessages::notEn
oughArguments(1, info.Length())), info.GetIsolate()); |
| 250 return; | 250 return; |
| 251 } | 251 } |
| 252 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(info.Holder()); | 252 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(inf
o.Holder()); |
| 253 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, url, info[0]); | 253 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, url, info[0]); |
| 254 imp->perWorldBindingsMethodWithDoNotCheckSecurity(url); | 254 imp->perWorldBindingsMethodWithDoNotCheckSecurity(url); |
| 255 } | 255 } |
| 256 | 256 |
| 257 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWor
ld(const v8::FunctionCallbackInfo<v8::Value>& info) | 257 static void perWorldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWor
ld(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 258 { | 258 { |
| 259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 260 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityM
ethodForMainWorld(info); | 260 TestCheckSecurityInterfaceV8Internal::perWorldBindingsMethodWithDoNotCheckSe
curityMethodForMainWorld(info); |
| 261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 262 } | 262 } |
| 263 | 263 |
| 264 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterForMainWo
rld(const v8::PropertyCallbackInfo<v8::Value>& info) | 264 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterForMainWo
rld(const v8::PropertyCallbackInfo<v8::Value>& info) |
| 265 { | 265 { |
| 266 // This is only for getting a unique pointer which we can pass to privateTem
plate. | 266 // This is only for getting a unique pointer which we can pass to privateTem
plate. |
| 267 static int privateTemplateUniqueKey; | 267 static int privateTemplateUniqueKey; |
| 268 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 268 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
| 269 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 269 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
| 270 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWorl
dBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWorld, v8Undefined(),
v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8Tes
tActiveDOMObject::wrapperTypeInfo, currentWorldType)), 1); | 270 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur
rentWorldType, &privateTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal::
perWorldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWorld, v8Undefi
ned(), v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate
(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 1); |
| 271 | 271 |
| 272 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType)); | 272 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), currentWorldType)); |
| 273 if (holder.IsEmpty()) { | 273 if (holder.IsEmpty()) { |
| 274 // can only reach here by 'object.__proto__.func', and it should passed | 274 // can only reach here by 'object.__proto__.func', and it should passed |
| 275 // domain security check already | 275 // domain security check already |
| 276 v8SetReturnValue(info, privateTemplate->GetFunction()); | 276 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder); | 279 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol
der); |
| 280 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { | 280 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu
rityError)) { |
| 281 static int sharedTemplateUniqueKey; | 281 static int sharedTemplateUniqueKey; |
| 282 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::perWo
rldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWorld, v8Undefined()
, v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&V8T
estActiveDOMObject::wrapperTypeInfo, currentWorldType)), 1); | 282 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(
currentWorldType, &sharedTemplateUniqueKey, TestCheckSecurityInterfaceV8Internal
::perWorldBindingsMethodWithDoNotCheckSecurityMethodCallbackForMainWorld, v8Unde
fined(), v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTempla
te(&V8TestCheckSecurityInterface::wrapperTypeInfo, currentWorldType)), 1); |
| 283 v8SetReturnValue(info, sharedTemplate->GetFunction()); | 283 v8SetReturnValue(info, sharedTemplate->GetFunction()); |
| 284 return; | 284 return; |
| 285 } | 285 } |
| 286 | 286 |
| 287 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("perWorldBindingsMethodWithDoNotCheckSecurity")); | 287 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N
ewSymbol("perWorldBindingsMethodWithDoNotCheckSecurity")); |
| 288 if (!hiddenValue.IsEmpty()) { | 288 if (!hiddenValue.IsEmpty()) { |
| 289 v8SetReturnValue(info, hiddenValue); | 289 v8SetReturnValue(info, hiddenValue); |
| 290 return; | 290 return; |
| 291 } | 291 } |
| 292 | 292 |
| 293 v8SetReturnValue(info, privateTemplate->GetFunction()); | 293 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 294 } | 294 } |
| 295 | 295 |
| 296 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterCallbackF
orMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& in
fo) | 296 static void perWorldBindingsMethodWithDoNotCheckSecurityAttributeGetterCallbackF
orMainWorld(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& in
fo) |
| 297 { | 297 { |
| 298 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 298 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 299 TestActiveDOMObjectV8Internal::perWorldBindingsMethodWithDoNotCheckSecurityA
ttributeGetterForMainWorld(info); | 299 TestCheckSecurityInterfaceV8Internal::perWorldBindingsMethodWithDoNotCheckSe
curityAttributeGetterForMainWorld(info); |
| 300 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 300 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 301 } | 301 } |
| 302 | 302 |
| 303 static void TestActiveDOMObjectDomainSafeFunctionSetter(v8::Local<v8::String> na
me, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 303 static void TestCheckSecurityInterfaceDomainSafeFunctionSetter(v8::Local<v8::Str
ing> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& i
nfo) |
| 304 { | 304 { |
| 305 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestActiveDOMObject::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())
)); | 305 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
TestCheckSecurityInterface::GetTemplate(info.GetIsolate(), worldType(info.GetIso
late()))); |
| 306 if (holder.IsEmpty()) | 306 if (holder.IsEmpty()) |
| 307 return; | 307 return; |
| 308 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder); | 308 TestCheckSecurityInterface* imp = V8TestCheckSecurityInterface::toNative(hol
der); |
| 309 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 309 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 310 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { | 310 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 311 exceptionState.throwIfNeeded(); | 311 exceptionState.throwIfNeeded(); |
| 312 return; | 312 return; |
| 313 } | 313 } |
| 314 | 314 |
| 315 info.This()->SetHiddenValue(name, jsValue); | 315 info.This()->SetHiddenValue(name, jsValue); |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace TestActiveDOMObjectV8Internal | 318 } // namespace TestCheckSecurityInterfaceV8Internal |
| 319 | 319 |
| 320 static const V8DOMConfiguration::AttributeConfiguration V8TestActiveDOMObjectAtt
ributes[] = { | 320 static const V8DOMConfiguration::AttributeConfiguration V8TestCheckSecurityInter
faceAttributes[] = { |
| 321 {"excitingAttr", TestActiveDOMObjectV8Internal::excitingAttrAttributeGetterC
allback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8
::PropertyAttribute>(v8::None), 0 /* on instance */}, | 321 {"excitingAttr", TestCheckSecurityInterfaceV8Internal::excitingAttrAttribute
GetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_
cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 322 }; | 322 }; |
| 323 | 323 |
| 324 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestActiveDOMObjectTemplate(v
8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperW
orldType currentWorldType) | 324 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestCheckSecurityInterfaceTem
plate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, W
rapperWorldType currentWorldType) |
| 325 { | 325 { |
| 326 functionTemplate->ReadOnlyPrototype(); | 326 functionTemplate->ReadOnlyPrototype(); |
| 327 | 327 |
| 328 v8::Local<v8::Signature> defaultSignature; | 328 v8::Local<v8::Signature> defaultSignature; |
| 329 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestActiveDOMObject", v8::Local<v8::FunctionTemplate>(), V8TestActiveDOMOb
ject::internalFieldCount, | 329 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestCheckSecurityInterface", v8::Local<v8::FunctionTemplate>(), V8TestChec
kSecurityInterface::internalFieldCount, |
| 330 V8TestActiveDOMObjectAttributes, WTF_ARRAY_LENGTH(V8TestActiveDOMObjectA
ttributes), | 330 V8TestCheckSecurityInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestCheckSecu
rityInterfaceAttributes), |
| 331 0, 0, | 331 0, 0, |
| 332 0, 0, | 332 0, 0, |
| 333 isolate, currentWorldType); | 333 isolate, currentWorldType); |
| 334 UNUSED_PARAM(defaultSignature); | 334 UNUSED_PARAM(defaultSignature); |
| 335 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT
emplate(); | 335 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT
emplate(); |
| 336 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp
eTemplate(); | 336 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp
eTemplate(); |
| 337 UNUSED_PARAM(instanceTemplate); | 337 UNUSED_PARAM(instanceTemplate); |
| 338 UNUSED_PARAM(prototypeTemplate); | 338 UNUSED_PARAM(prototypeTemplate); |
| 339 instanceTemplate->SetAccessCheckCallbacks(TestActiveDOMObjectV8Internal::nam
edSecurityCheck, TestActiveDOMObjectV8Internal::indexedSecurityCheck, v8::Extern
al::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestActiveDOMObject::wrapperTyp
eInfo))); | 339 instanceTemplate->SetAccessCheckCallbacks(TestCheckSecurityInterfaceV8Intern
al::namedSecurityCheck, TestCheckSecurityInterfaceV8Internal::indexedSecurityChe
ck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8TestCheckSecurity
Interface::wrapperTypeInfo))); |
| 340 | 340 |
| 341 // Custom Signature 'excitingFunction' | 341 // Custom Signature 'excitingFunction' |
| 342 const int excitingFunctionArgc = 1; | 342 const int excitingFunctionArgc = 1; |
| 343 v8::Handle<v8::FunctionTemplate> excitingFunctionArgv[excitingFunctionArgc]
= { V8PerIsolateData::from(isolate)->rawTemplate(&V8Node::wrapperTypeInfo, curre
ntWorldType) }; | 343 v8::Handle<v8::FunctionTemplate> excitingFunctionArgv[excitingFunctionArgc]
= { V8PerIsolateData::from(isolate)->rawTemplate(&V8Node::wrapperTypeInfo, curre
ntWorldType) }; |
| 344 v8::Handle<v8::Signature> excitingFunctionSignature = v8::Signature::New(fun
ctionTemplate, excitingFunctionArgc, excitingFunctionArgv); | 344 v8::Handle<v8::Signature> excitingFunctionSignature = v8::Signature::New(fun
ctionTemplate, excitingFunctionArgc, excitingFunctionArgv); |
| 345 prototypeTemplate->Set(v8::String::NewSymbol("excitingFunction"), v8::Functi
onTemplate::New(TestActiveDOMObjectV8Internal::excitingFunctionMethodCallback, v
8Undefined(), excitingFunctionSignature, 1)); | 345 prototypeTemplate->Set(v8::String::NewSymbol("excitingFunction"), v8::Functi
onTemplate::New(TestCheckSecurityInterfaceV8Internal::excitingFunctionMethodCall
back, v8Undefined(), excitingFunctionSignature, 1)); |
| 346 | 346 |
| 347 // Function 'postMessage' (Extended Attributes: 'DoNotCheckSecurity') | 347 // Function 'postMessage' (Extended Attributes: 'DoNotCheckSecurity') |
| 348 prototypeTemplate->SetAccessor(v8::String::NewSymbol("postMessage"), TestAct
iveDOMObjectV8Internal::postMessageAttributeGetterCallback, TestActiveDOMObjectV
8Internal::TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL_C
AN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 348 prototypeTemplate->SetAccessor(v8::String::NewSymbol("postMessage"), TestChe
ckSecurityInterfaceV8Internal::postMessageAttributeGetterCallback, TestCheckSecu
rityInterfaceV8Internal::TestCheckSecurityInterfaceDomainSafeFunctionSetter, v8U
ndefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete)
); |
| 349 | 349 |
| 350 // Function 'perWorldBindingsMethodWithDoNotCheckSecurity' (Extended Attribu
tes: 'DoNotCheckSecurity PerWorldBindings ActivityLogging') | 350 // Function 'perWorldBindingsMethodWithDoNotCheckSecurity' (Extended Attribu
tes: 'DoNotCheckSecurity PerWorldBindings ActivityLogging') |
| 351 if (currentWorldType == MainWorld) { | 351 if (currentWorldType == MainWorld) { |
| 352 prototypeTemplate->SetAccessor(v8::String::NewSymbol("perWorldBindingsMe
thodWithDoNotCheckSecurity"), TestActiveDOMObjectV8Internal::perWorldBindingsMet
hodWithDoNotCheckSecurityAttributeGetterCallbackForMainWorld, TestActiveDOMObjec
tV8Internal::TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL
_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 352 prototypeTemplate->SetAccessor(v8::String::NewSymbol("perWorldBindingsMe
thodWithDoNotCheckSecurity"), TestCheckSecurityInterfaceV8Internal::perWorldBind
ingsMethodWithDoNotCheckSecurityAttributeGetterCallbackForMainWorld, TestCheckSe
curityInterfaceV8Internal::TestCheckSecurityInterfaceDomainSafeFunctionSetter, v
8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelet
e)); |
| 353 } else { | 353 } else { |
| 354 prototypeTemplate->SetAccessor(v8::String::NewSymbol("perWorldBindingsMe
thodWithDoNotCheckSecurity"), TestActiveDOMObjectV8Internal::perWorldBindingsMet
hodWithDoNotCheckSecurityAttributeGetterCallback, TestActiveDOMObjectV8Internal:
:TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, s
tatic_cast<v8::PropertyAttribute>(v8::DontDelete)); | 354 prototypeTemplate->SetAccessor(v8::String::NewSymbol("perWorldBindingsMe
thodWithDoNotCheckSecurity"), TestCheckSecurityInterfaceV8Internal::perWorldBind
ingsMethodWithDoNotCheckSecurityAttributeGetterCallback, TestCheckSecurityInterf
aceV8Internal::TestCheckSecurityInterfaceDomainSafeFunctionSetter, v8Undefined()
, v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete)); |
| 355 } | 355 } |
| 356 | 356 |
| 357 // Custom toString template | 357 // Custom toString template |
| 358 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c
urrent()->toStringTemplate()); | 358 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c
urrent()->toStringTemplate()); |
| 359 return functionTemplate; | 359 return functionTemplate; |
| 360 } | 360 } |
| 361 | 361 |
| 362 v8::Handle<v8::FunctionTemplate> V8TestActiveDOMObject::GetTemplate(v8::Isolate*
isolate, WrapperWorldType currentWorldType) | 362 v8::Handle<v8::FunctionTemplate> V8TestCheckSecurityInterface::GetTemplate(v8::I
solate* isolate, WrapperWorldType currentWorldType) |
| 363 { | 363 { |
| 364 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 364 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 365 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 365 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); |
| 366 if (result != data->templateMap(currentWorldType).end()) | 366 if (result != data->templateMap(currentWorldType).end()) |
| 367 return result->value.newLocal(isolate); | 367 return result->value.newLocal(isolate); |
| 368 | 368 |
| 369 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 369 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 370 v8::HandleScope handleScope(isolate); | 370 v8::HandleScope handleScope(isolate); |
| 371 v8::Handle<v8::FunctionTemplate> templ = | 371 v8::Handle<v8::FunctionTemplate> templ = |
| 372 ConfigureV8TestActiveDOMObjectTemplate(data->rawTemplate(&wrapperTypeInf
o, currentWorldType), isolate, currentWorldType); | 372 ConfigureV8TestCheckSecurityInterfaceTemplate(data->rawTemplate(&wrapper
TypeInfo, currentWorldType), isolate, currentWorldType); |
| 373 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 373 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 374 return handleScope.Close(templ); | 374 return handleScope.Close(templ); |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool V8TestActiveDOMObject::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isola
te* isolate, WrapperWorldType currentWorldType) | 377 bool V8TestCheckSecurityInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8
::Isolate* isolate, WrapperWorldType currentWorldType) |
| 378 { | 378 { |
| 379 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 379 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool V8TestActiveDOMObject::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue,
v8::Isolate* isolate) | 382 bool V8TestCheckSecurityInterface::hasInstanceInAnyWorld(v8::Handle<v8::Value> j
sValue, v8::Isolate* isolate) |
| 383 { | 383 { |
| 384 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) | 384 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) |
| 385 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, IsolatedWorld) | 385 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, IsolatedWorld) |
| 386 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, WorkerWorld); | 386 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, WorkerWorld); |
| 387 } | 387 } |
| 388 | 388 |
| 389 v8::Handle<v8::Object> V8TestActiveDOMObject::createWrapper(PassRefPtr<TestActiv
eDOMObject> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 389 v8::Handle<v8::Object> V8TestCheckSecurityInterface::createWrapper(PassRefPtr<Te
stCheckSecurityInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isol
ate* isolate) |
| 390 { | 390 { |
| 391 ASSERT(impl); | 391 ASSERT(impl); |
| 392 ASSERT(!DOMDataStore::containsWrapper<V8TestActiveDOMObject>(impl.get(), iso
late)); | 392 ASSERT(!DOMDataStore::containsWrapper<V8TestCheckSecurityInterface>(impl.get
(), isolate)); |
| 393 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 393 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 394 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | 394 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 395 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | 395 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have |
| 396 // the same object de-ref functions, though, so use that as the basis of
the check. | 396 // the same object de-ref functions, though, so use that as the basis of
the check. |
| 397 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | 397 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); |
| 398 } | 398 } |
| 399 | 399 |
| 400 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | 400 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); |
| 401 if (UNLIKELY(wrapper.IsEmpty())) | 401 if (UNLIKELY(wrapper.IsEmpty())) |
| 402 return wrapper; | 402 return wrapper; |
| 403 | 403 |
| 404 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | 404 installPerContextEnabledProperties(wrapper, impl.get(), isolate); |
| 405 V8DOMWrapper::associateObjectWithWrapper<V8TestActiveDOMObject>(impl, &wrapp
erTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); | 405 V8DOMWrapper::associateObjectWithWrapper<V8TestCheckSecurityInterface>(impl,
&wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); |
| 406 return wrapper; | 406 return wrapper; |
| 407 } | 407 } |
| 408 | 408 |
| 409 void V8TestActiveDOMObject::derefObject(void* object) | 409 void V8TestCheckSecurityInterface::derefObject(void* object) |
| 410 { | 410 { |
| 411 fromInternalPointer(object)->deref(); | 411 fromInternalPointer(object)->deref(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace WebCore | 414 } // namespace WebCore |
| OLD | NEW |