Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1237)

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 187313004: Merge 166999 "Add cross-origin BindingsSecurity checks to 'Event..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1750/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/security/cross-frame-access-dispatchEvent-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 2355
2356 my $conditionalString = GenerateConditionalString($function); 2356 my $conditionalString = GenerateConditionalString($function);
2357 my $code = ""; 2357 my $code = "";
2358 $code .= "#if ${conditionalString}\n" if $conditionalString; 2358 $code .= "#if ${conditionalString}\n" if $conditionalString;
2359 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& info)\n"; 2359 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& info)\n";
2360 $code .= "{\n"; 2360 $code .= "{\n";
2361 2361
2362 # We throw exceptions using 'ExceptionState' if the function explicitly clai ms that exceptions 2362 # We throw exceptions using 'ExceptionState' if the function explicitly clai ms that exceptions
2363 # may be raised, or for event listeners, or for security-checking, and for w eird SVG stuff. 2363 # may be raised, or for event listeners, or for security-checking, and for w eird SVG stuff.
2364 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi stener"; 2364 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi stener";
2365 my $isEventDispatcher = $name eq "dispatchEvent";
2365 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"}; 2366 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"};
2366 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; 2367 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"};
2367 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); 2368 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName);
2368 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/); 2369 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/);
2369 2370
2370 my $hasExceptionState = 0; 2371 my $hasExceptionState = 0;
2371 if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $i sNonListSVGType) { 2372 if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $i sNonListSVGType) {
2372 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol ate());\n"; 2373 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol ate());\n";
2373 $hasExceptionState = 1; 2374 $hasExceptionState = 1;
2374 } 2375 }
2375 2376
2376 if ($isEventListener) { 2377 if ($isEventListener || $isEventDispatcher) {
2377 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only";
2378 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()";
2379 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove";
2380
2381 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2378 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2382 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 2379 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
2383 AddToImplIncludes("core/frame/DOMWindow.h"); 2380 AddToImplIncludes("core/frame/DOMWindow.h");
2384 $code .= <<END; 2381 $code .= <<END;
2385 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); 2382 EventTarget* impl = ${v8ClassName}::toNative(info.Holder());
2386 if (DOMWindow* window = impl->toDOMWindow()) { 2383 if (DOMWindow* window = impl->toDOMWindow()) {
2387 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio nState)) { 2384 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio nState)) {
2388 exceptionState.throwIfNeeded(); 2385 exceptionState.throwIfNeeded();
2389 return; 2386 return;
2390 } 2387 }
2391 if (!window->document()) 2388 if (!window->document())
2392 return; 2389 return;
2393 } 2390 }
2391 END
2392 }
2393 if ($isEventListener) {
2394 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only";
2395 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()";
2396 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove";
2397
2398 $code .= <<END;
2394 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType}); 2399 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType});
2395 if (listener) { 2400 if (listener) {
2396 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev entName, info[0]); 2401 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev entName, info[0]);
2397 impl->${implName}(eventName, listener${passRefPtrHandling}, info[2]->Boo leanValue()); 2402 impl->${implName}(eventName, listener${passRefPtrHandling}, info[2]->Boo leanValue());
2398 if (!impl->toNode()) 2403 if (!impl->toNode())
2399 ${hiddenDependencyAction}HiddenDependency(info.Holder(), info[1], ${ v8ClassName}::eventListenerCacheIndex, info.GetIsolate()); 2404 ${hiddenDependencyAction}HiddenDependency(info.Holder(), info[1], ${ v8ClassName}::eventListenerCacheIndex, info.GetIsolate());
2400 } 2405 }
2401 } 2406 }
2402 END 2407 END
2403 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 2408 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
(...skipping 3933 matching lines...) Expand 10 before | Expand all | Expand 10 after
6337 6342
6338 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "ToV8"); 6343 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "ToV8");
6339 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "Wrap"); 6344 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "Wrap");
6340 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6345 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6341 return 1 if InheritsInterface($interface, "Document"); 6346 return 1 if InheritsInterface($interface, "Document");
6342 6347
6343 return 0; 6348 return 0;
6344 } 6349 }
6345 6350
6346 1; 6351 1;
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/security/cross-frame-access-dispatchEvent-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698