| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "bindings/core/v8/V8Window.h" | 39 #include "bindings/core/v8/V8Window.h" |
| 40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 41 #include "core/frame/LocalDOMWindow.h" | 41 #include "core/frame/LocalDOMWindow.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 v8::Local<v8::Object> V8DOMWrapper::CreateWrapper( | 45 v8::Local<v8::Object> V8DOMWrapper::CreateWrapper( |
| 46 v8::Isolate* isolate, | 46 v8::Isolate* isolate, |
| 47 v8::Local<v8::Object> creation_context, | 47 v8::Local<v8::Object> creation_context, |
| 48 const WrapperTypeInfo* type) { | 48 const WrapperTypeInfo* type) { |
| 49 ASSERT(!type->Equals(&V8Window::wrapperTypeInfo)); | 49 DCHECK(!type->Equals(&V8Window::wrapperTypeInfo)); |
| 50 // According to | 50 // According to |
| 51 // https://html.spec.whatwg.org/multipage/browsers.html#security-location, | 51 // https://html.spec.whatwg.org/multipage/browsers.html#security-location, |
| 52 // cross-origin script access to a few properties of Location is allowed. | 52 // cross-origin script access to a few properties of Location is allowed. |
| 53 // Location already implements the necessary security checks. | 53 // Location already implements the necessary security checks. |
| 54 bool with_security_check = !type->Equals(&V8Location::wrapperTypeInfo); | 54 bool with_security_check = !type->Equals(&V8Location::wrapperTypeInfo); |
| 55 V8WrapperInstantiationScope scope(creation_context, isolate, | 55 V8WrapperInstantiationScope scope(creation_context, isolate, |
| 56 with_security_check); | 56 with_security_check); |
| 57 | 57 |
| 58 V8PerContextData* per_context_data = | 58 V8PerContextData* per_context_data = |
| 59 V8PerContextData::From(scope.GetContext()); | 59 V8PerContextData::From(scope.GetContext()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ExceptionState exception_state( | 123 ExceptionState exception_state( |
| 124 isolate, ExceptionState::kConstructionContext, "Location"); | 124 isolate, ExceptionState::kConstructionContext, "Location"); |
| 125 if (BindingSecurity::ShouldAllowAccessToDetachedWindow( | 125 if (BindingSecurity::ShouldAllowAccessToDetachedWindow( |
| 126 calling_window, target_window, exception_state)) | 126 calling_window, target_window, exception_state)) |
| 127 return; | 127 return; |
| 128 | 128 |
| 129 CHECK_EQ(kSecurityError, exception_state.Code()); | 129 CHECK_EQ(kSecurityError, exception_state.Code()); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 const DOMWrapperWorld& current_world = DOMWrapperWorld::World(context_); | 132 const DOMWrapperWorld& current_world = DOMWrapperWorld::World(context_); |
| 133 RELEASE_ASSERT(current_world.GetWorldId() == | 133 CHECK_EQ(current_world.GetWorldId(), |
| 134 DOMWrapperWorld::World(context_for_wrapper).GetWorldId()); | 134 DOMWrapperWorld::World(context_for_wrapper).GetWorldId()); |
| 135 // TODO(jochen): Add the interface name here once this is generalized. | 135 // TODO(jochen): Add the interface name here once this is generalized. |
| 136 ExceptionState exception_state(isolate, ExceptionState::kConstructionContext, | 136 ExceptionState exception_state(isolate, ExceptionState::kConstructionContext, |
| 137 nullptr); | 137 nullptr); |
| 138 if (current_world.IsMainWorld() && | 138 if (current_world.IsMainWorld() && |
| 139 !BindingSecurity::ShouldAllowAccessToFrame(CurrentDOMWindow(isolate), | 139 !BindingSecurity::ShouldAllowAccessToFrame(CurrentDOMWindow(isolate), |
| 140 frame, exception_state)) { | 140 frame, exception_state)) { |
| 141 CHECK_EQ(kSecurityError, exception_state.Code()); | 141 CHECK_EQ(kSecurityError, exception_state.Code()); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 void V8WrapperInstantiationScope::ConvertException() { | 146 void V8WrapperInstantiationScope::ConvertException() { |
| 147 v8::Isolate* isolate = context_->GetIsolate(); | 147 v8::Isolate* isolate = context_->GetIsolate(); |
| 148 // TODO(jochen): Currently, Location is the only object for which we can reach | 148 // TODO(jochen): Currently, Location is the only object for which we can reach |
| 149 // this code path. Should be generalized. | 149 // this code path. Should be generalized. |
| 150 ExceptionState exception_state(isolate, ExceptionState::kConstructionContext, | 150 ExceptionState exception_state(isolate, ExceptionState::kConstructionContext, |
| 151 "Location"); | 151 "Location"); |
| 152 LocalDOMWindow* calling_window = CurrentDOMWindow(isolate); | 152 LocalDOMWindow* calling_window = CurrentDOMWindow(isolate); |
| 153 LocalDOMWindow* target_window = ToLocalDOMWindow(context_); | 153 LocalDOMWindow* target_window = ToLocalDOMWindow(context_); |
| 154 exception_state.ThrowSecurityError( | 154 exception_state.ThrowSecurityError( |
| 155 target_window->SanitizedCrossDomainAccessErrorMessage(calling_window), | 155 target_window->SanitizedCrossDomainAccessErrorMessage(calling_window), |
| 156 target_window->CrossDomainAccessErrorMessage(calling_window)); | 156 target_window->CrossDomainAccessErrorMessage(calling_window)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |