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

Unified Diff: Source/bindings/core/v8/V8ThrowException.cpp

Issue 894193002: Use correct context when throwing an exception (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2214
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8ThrowException.cpp
diff --git a/Source/bindings/core/v8/V8ThrowException.cpp b/Source/bindings/core/v8/V8ThrowException.cpp
index 060ab6b784f6121f0c58c296cd40913009f77dc3..9a0d4365ca1f5831a6ad90b4685dccc88a959027 100644
--- a/Source/bindings/core/v8/V8ThrowException.cpp
+++ b/Source/bindings/core/v8/V8ThrowException.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "bindings/core/v8/V8ThrowException.h"
+#include "bindings/core/v8/BindingSecurity.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8DOMException.h"
#include "core/dom/DOMException.h"
@@ -62,8 +63,16 @@ v8::Handle<v8::Value> V8ThrowException::createDOMException(v8::Isolate* isolate,
if (ec == V8ReferenceError)
return V8ThrowException::createReferenceError(isolate, sanitizedMessage);
+ v8::Handle<v8::Object> sanitizedCreationContext = creationContext;
+
+ // FIXME: Is the current context always the right choice?
+ Frame* frame = toFrameIfNotDetached(creationContext->CreationContext());
+ if (!frame || !BindingSecurity::shouldAllowAccessToFrame(isolate, frame, DoNotReportSecurityError))
+ sanitizedCreationContext = isolate->GetCurrentContext()->Global();
+
+
RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, sanitizedMessage, unsanitizedMessage);
- v8::Handle<v8::Value> exception = toV8(domException, creationContext, isolate);
+ v8::Handle<v8::Value> exception = toV8(domException, sanitizedCreationContext, isolate);
if (exception.IsEmpty())
return v8Undefined();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698