| Index: Source/bindings/core/v8/V8DOMWrapper.h
|
| ===================================================================
|
| --- Source/bindings/core/v8/V8DOMWrapper.h (revision 202325)
|
| +++ Source/bindings/core/v8/V8DOMWrapper.h (working copy)
|
| @@ -113,6 +113,8 @@
|
| V8WrapperInstantiationScope(v8::Local<v8::Object> creationContext, v8::Isolate* isolate, bool withSecurityCheck = true)
|
| : m_didEnterContext(false)
|
| , m_context(isolate->GetCurrentContext())
|
| + , m_tryCatch(isolate)
|
| + , m_convertExceptions(false)
|
| {
|
| // creationContext should not be empty. Because if we have an
|
| // empty creationContext, we will end up creating
|
| @@ -119,12 +121,16 @@
|
| // a new object in the context currently entered. This is wrong.
|
| RELEASE_ASSERT(!creationContext.IsEmpty());
|
| v8::Local<v8::Context> contextForWrapper = creationContext->CreationContext();
|
| +
|
| // For performance, we enter the context only if the currently running context
|
| // is different from the context that we are about to enter.
|
| if (contextForWrapper == m_context)
|
| return;
|
| - if (withSecurityCheck)
|
| + if (withSecurityCheck) {
|
| securityCheck(isolate, contextForWrapper);
|
| + } else {
|
| + m_convertExceptions = true;
|
| + }
|
| m_context = v8::Local<v8::Context>::New(isolate, contextForWrapper);
|
| m_didEnterContext = true;
|
| m_context->Enter();
|
| @@ -132,9 +138,19 @@
|
|
|
| ~V8WrapperInstantiationScope()
|
| {
|
| - if (!m_didEnterContext)
|
| + if (!m_didEnterContext) {
|
| + m_tryCatch.ReThrow();
|
| return;
|
| + }
|
| m_context->Exit();
|
| + // Rethrow any cross-context exceptions as security error.
|
| + if (m_tryCatch.HasCaught()) {
|
| + if (m_convertExceptions) {
|
| + m_tryCatch.Reset();
|
| + convertException();
|
| + }
|
| + m_tryCatch.ReThrow();
|
| + }
|
| }
|
|
|
| v8::Local<v8::Context> context() const { return m_context; }
|
| @@ -141,9 +157,12 @@
|
|
|
| private:
|
| void securityCheck(v8::Isolate*, v8::Local<v8::Context> contextForWrapper);
|
| + void convertException();
|
|
|
| bool m_didEnterContext;
|
| v8::Local<v8::Context> m_context;
|
| + v8::TryCatch m_tryCatch;
|
| + bool m_convertExceptions;
|
| };
|
|
|
| } // namespace blink
|
|
|