summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/custom')
-rw-r--r--WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp18
-rw-r--r--WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp29
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp35
3 files changed, 70 insertions, 12 deletions
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 1b069cf..b3007a4 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -46,6 +46,7 @@
#include "V8BindingState.h"
#include "V8DOMWindow.h"
#include "V8Database.h"
+#include "V8HiddenPropertyName.h"
#include "V8JavaScriptCallFrame.h"
#include "V8Node.h"
#include "V8Proxy.h"
@@ -120,6 +121,21 @@ ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource
return ScriptObject(inspectedScriptState, injectedScript);
}
+void InjectedScriptHost::discardInjectedScript(ScriptState* inspectedScriptState)
+{
+ v8::HandleScope handleScope;
+ v8::Local<v8::Context> context = inspectedScriptState->context();
+ v8::Context::Scope contextScope(context);
+
+ v8::Local<v8::Object> global = context->Global();
+ // Skip proxy object. The proxy object will survive page navigation while we need
+ // an object whose lifetime consides with that of the inspected context.
+ global = v8::Local<v8::Object>::Cast(global->GetPrototype());
+
+ v8::Handle<v8::String> key = V8HiddenPropertyName::devtoolsInjectedScript();
+ global->DeleteHiddenValue(key);
+}
+
v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Arguments& args)
{
INC_STATS("InjectedScriptHost.nodeForId()");
@@ -206,7 +222,7 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScrip
// an object whose lifetime consides with that of the inspected context.
global = v8::Local<v8::Object>::Cast(global->GetPrototype());
- v8::Local<v8::String> key = v8::String::New("Devtools_InjectedScript");
+ v8::Handle<v8::String> key = V8HiddenPropertyName::devtoolsInjectedScript();
v8::Local<v8::Value> val = global->GetHiddenValue(key);
if (!val.IsEmpty() && val->IsObject())
return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
diff --git a/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
index 7733a70..25b9010 100644
--- a/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
@@ -33,6 +33,7 @@
#include "InspectorController.h"
#include "InspectorFrontendHost.h"
+#include "PlatformString.h"
#include "V8Binding.h"
#include "V8MouseEvent.h"
@@ -76,18 +77,26 @@ v8::Handle<v8::Value> V8InspectorFrontendHost::showContextMenuCallback(const v8:
for (size_t i = 0; i < array->Length(); ++i) {
v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(array->Get(v8::Integer::New(i)));
- v8::Local<v8::Value> label = item->Get(v8::String::New("label"));
+ v8::Local<v8::Value> type = item->Get(v8::String::New("type"));
v8::Local<v8::Value> id = item->Get(v8::String::New("id"));
- if (label->IsUndefined() || id->IsUndefined()) {
- items.append(new ContextMenuItem(SeparatorType,
- ContextMenuItemCustomTagNoAction,
- String()));
+ v8::Local<v8::Value> label = item->Get(v8::String::New("label"));
+ v8::Local<v8::Value> enabled = item->Get(v8::String::New("enabled"));
+ v8::Local<v8::Value> checked = item->Get(v8::String::New("checked"));
+ if (!type->IsString())
+ continue;
+ String typeString = toWebCoreStringWithNullCheck(type);
+ if (typeString == "separator") {
+ items.append(new ContextMenuItem(SeparatorType,
+ ContextMenuItemCustomTagNoAction,
+ String()));
} else {
- ContextMenuAction typedId = static_cast<ContextMenuAction>(
- ContextMenuItemBaseCustomTag + id->ToInt32()->Value());
- items.append(new ContextMenuItem(ActionType,
- typedId,
- toWebCoreStringWithNullCheck(label)));
+ ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id->ToInt32()->Value());
+ ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, toWebCoreStringWithNullCheck(label));
+ if (checked->IsBoolean())
+ menuItem->setChecked(checked->ToBoolean()->Value());
+ if (enabled->IsBoolean())
+ menuItem->setEnabled(enabled->ToBoolean()->Value());
+ items.append(menuItem);
}
}
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index fd6e120..9346a05 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -227,6 +227,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const
ExceptionCode ec = 0;
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
Vector<WebGLShader*> shaders;
bool succeed = context->getAttachedShaders(program, shaders, ec);
@@ -319,6 +323,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const
ExceptionCode ec = 0;
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
bool ok;
unsigned pname = toInt32(args[1], ok);
@@ -351,6 +359,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const
ExceptionCode ec = 0;
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
WebGLShader* shader = V8WebGLShader::HasInstance(args[0]) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
bool ok;
unsigned pname = toInt32(args[1], ok);
@@ -383,8 +395,16 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu
ExceptionCode ec = 0;
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
+ if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocation::HasInstance(args[1])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
bool ok = false;
WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok);
@@ -452,8 +472,13 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments&
if (isFunctionToCallForAttribute(functionToCall))
index = toInt32(args[0], ok);
- else
+ else {
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
location = toWebGLUniformLocation(args[0], ok);
+ }
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
@@ -526,6 +551,10 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args,
}
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
bool ok = false;
WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok);
@@ -639,6 +668,10 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args,
WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) {
+ V8Proxy::throwTypeError();
+ return notHandledByInterceptor();
+ }
bool ok = false;
WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok);