Diff
Modified: trunk/Source/WebCore/ChangeLog (144589 => 144590)
--- trunk/Source/WebCore/ChangeLog 2013-03-04 00:11:08 UTC (rev 144589)
+++ trunk/Source/WebCore/ChangeLog 2013-03-04 00:12:06 UTC (rev 144590)
@@ -1,5 +1,27 @@
2013-03-01 Kentaro Hara <[email protected]>
+ [V8] indexedSecurityCheck() and namedSecurityCheck() should be auto-generated
+ https://bugs.webkit.org/show_bug.cgi?id=111225
+
+ Reviewed by Adam Barth.
+
+ indexedSecurityCheck() and namedSecurityCheck() should be auto-generated,
+ except for DOMWindow's ones.
+
+ No tests. No change in behavior.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateHeader):
+ (GenerateImplementation):
+ (GenerateSecurityCheckFunctions):
+ * bindings/v8/custom/V8DOMWindowCustom.cpp:
+ (WebCore::V8DOMWindow::namedSecurityCheckCustom):
+ (WebCore::V8DOMWindow::indexedSecurityCheckCustom):
+ * bindings/v8/custom/V8HistoryCustom.cpp:
+ * bindings/v8/custom/V8LocationCustom.cpp:
+
+2013-03-01 Kentaro Hara <[email protected]>
+
[V8] Rename $implContentDecls to $implContentInternals in CodeGeneratorV8.pm
https://bugs.webkit.org/show_bug.cgi?id=111214
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (144589 => 144590)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2013-03-04 00:11:08 UTC (rev 144589)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2013-03-04 00:12:06 UTC (rev 144590)
@@ -449,10 +449,10 @@
GenerateHeaderCustomCall($interface);
GenerateHeaderCustomInternalFieldIndices($interface);
- if ($interface->extendedAttributes->{"CheckSecurity"}) {
+ if ($interface->name eq "DOMWindow") {
push(@headerContent, <<END);
- static bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
- static bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
+ static bool namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
+ static bool indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data);
END
}
@@ -2781,6 +2781,10 @@
GenerateOpaqueRootForGC($interface);
}
+ if ($interface->extendedAttributes->{"CheckSecurity"} && $interface->name ne "DOMWindow") {
+ GenerateSecurityCheckFunctions($interface);
+ }
+
if ($interface->extendedAttributes->{"TypedArray"}) {
my $viewType = GetTypeNameOfExternalTypedArray($interface);
push(@implContent, <<END);
@@ -2961,8 +2965,8 @@
push(@implContentInternals, "} // namespace ${interfaceName}V8Internal\n\n");
my $access_check = "";
- if ($interface->extendedAttributes->{"CheckSecurity"} && !($interfaceName eq "DOMWindow")) {
- $access_check = "instance->SetAccessCheckCallbacks(${v8InterfaceName}::namedSecurityCheck, ${v8InterfaceName}::indexedSecurityCheck, v8::External::New(&${v8InterfaceName}::info));";
+ if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "DOMWindow") {
+ $access_check = "instance->SetAccessCheckCallbacks(${interfaceName}V8Internal::namedSecurityCheck, ${interfaceName}V8Internal::indexedSecurityCheck, v8::External::New(&${v8InterfaceName}::info));";
}
# For the DOMWindow interface, generate the shadow object template
@@ -2974,7 +2978,7 @@
V8DOMConfiguration::batchConfigureAttributes(templ, v8::Handle<v8::ObjectTemplate>(), shadowAttrs, WTF_ARRAY_LENGTH(shadowAttrs), isolate);
// Install a security handler with V8.
- templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::New(&V8DOMWindow::info));
+ templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8DOMWindow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info));
templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
return templ;
}
@@ -3114,7 +3118,7 @@
// Set access check callbacks, but turned off initially.
// When a context is detached from a frame, turn on the access check.
// Turning on checks also invalidates inline caches of the object.
- instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::New(&V8DOMWindow::info), false);
+ instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheckCustom, V8DOMWindow::indexedSecurityCheckCustom, v8::External::New(&V8DOMWindow::info), false);
END
}
if ($interfaceName eq "HTMLDocument" or $interfaceName eq "DedicatedWorkerContext" or $interfaceName eq "SharedWorkerContext") {
@@ -3585,6 +3589,28 @@
END
}
+sub GenerateSecurityCheckFunctions
+{
+ my $interface = shift;
+ my $interfaceName = $interface->name;
+ my $v8InterfaceName = "V8$interfaceName";
+
+ push(@implContentDecls, <<END);
+bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
+{
+ $interfaceName* imp = ${v8InterfaceName}::toNative(host);
+ return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError);
+}
+
+bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
+{
+ $interfaceName* imp = ${v8InterfaceName}::toNative(host);
+ return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError);
+}
+
+END
+}
+
sub GetNativeTypeForConversions
{
my $interface = shift;
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp (144589 => 144590)
--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp 2013-03-04 00:11:08 UTC (rev 144589)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp 2013-03-04 00:12:06 UTC (rev 144590)
@@ -508,7 +508,7 @@
return WindowSetTimeoutImpl(args, false);
}
-bool V8DOMWindow::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
+bool V8DOMWindow::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate));
@@ -542,7 +542,7 @@
return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), target, DoNotReportSecurityError);
}
-bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
+bool V8DOMWindow::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate));
Modified: trunk/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp (144589 => 144590)
--- trunk/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp 2013-03-04 00:11:08 UTC (rev 144589)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp 2013-03-04 00:12:06 UTC (rev 144590)
@@ -91,16 +91,4 @@
return setDOMException(ec, args.GetIsolate());
}
-bool V8History::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
-{
- History* history = V8History::toNative(host);
- return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), history->frame(), DoNotReportSecurityError);
-}
-
-bool V8History::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
-{
- History* history = V8History::toNative(host);
- return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), history->frame(), DoNotReportSecurityError);
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp (144589 => 144590)
--- trunk/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp 2013-03-04 00:11:08 UTC (rev 144589)
+++ trunk/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp 2013-03-04 00:12:06 UTC (rev 144590)
@@ -244,18 +244,4 @@
return v8String(result, args.GetIsolate());
}
-bool V8Location::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
-{
- // Only allow same origin access
- Location* imp = V8Location::toNative(host);
- return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError);
-}
-
-bool V8Location::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
-{
- // Only allow same origin access
- Location* imp = V8Location::toNative(host);
- return BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError);
-}
-
} // namespace WebCore