| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // FIXME: There is a lot of duplication with SetTimeoutOrInterval() in V8WorkerG
lobalScopeCustom.cpp. | 72 // FIXME: There is a lot of duplication with SetTimeoutOrInterval() in V8WorkerG
lobalScopeCustom.cpp. |
| 73 // We should refactor this. | 73 // We should refactor this. |
| 74 static void windowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& info
, bool singleShot, ExceptionState& exceptionState) | 74 static void windowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& info
, bool singleShot, ExceptionState& exceptionState) |
| 75 { | 75 { |
| 76 int argumentCount = info.Length(); | 76 int argumentCount = info.Length(); |
| 77 | 77 |
| 78 if (argumentCount < 1) | 78 if (argumentCount < 1) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 LocalDOMWindow* impl = V8Window::toImpl(info.Holder()); | 81 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 82 if (!impl->frame() || !impl->document()) { | 82 if (!impl->frame() || !impl->document()) { |
| 83 exceptionState.throwDOMException(InvalidAccessError, "No script context
is available in which to execute the script."); | 83 exceptionState.throwDOMException(InvalidAccessError, "No script context
is available in which to execute the script."); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | 86 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| 87 v8::Handle<v8::Value> function = info[0]; | 87 v8::Handle<v8::Value> function = info[0]; |
| 88 String functionString; | 88 String functionString; |
| 89 if (!function->IsFunction()) { | 89 if (!function->IsFunction()) { |
| 90 if (function->IsString()) { | 90 if (function->IsString()) { |
| 91 functionString = toCoreString(function.As<v8::String>()); | 91 functionString = toCoreString(function.As<v8::String>()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // FIXME: Crude hack that attempts to pass idle time to V8. This should be | 142 // FIXME: Crude hack that attempts to pass idle time to V8. This should be |
| 143 // done using the scheduler instead. | 143 // done using the scheduler instead. |
| 144 if (timeout >= 0) | 144 if (timeout >= 0) |
| 145 V8GCForContextDispose::instance().notifyIdle(); | 145 V8GCForContextDispose::instance().notifyIdle(); |
| 146 | 146 |
| 147 v8SetReturnValue(info, timerId); | 147 v8SetReturnValue(info, timerId); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Val
ue>& info) | 150 void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Val
ue>& info) |
| 151 { | 151 { |
| 152 LocalFrame* frame = V8Window::toImpl(info.Holder())->frame(); | 152 LocalFrame* frame = toLocalDOMWindow(V8Window::toImpl(info.Holder()))->frame
(); |
| 153 ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Windo
w", info.Holder(), info.GetIsolate()); | 153 ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Windo
w", info.Holder(), info.GetIsolate()); |
| 154 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc
eptionState)) { | 154 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc
eptionState)) { |
| 155 exceptionState.throwIfNeeded(); | 155 exceptionState.throwIfNeeded(); |
| 156 return; | 156 return; |
| 157 } | 157 } |
| 158 | 158 |
| 159 ASSERT(frame); | 159 ASSERT(frame); |
| 160 // This is a fast path to retrieve info.Holder()->CreationContext(). | 160 // This is a fast path to retrieve info.Holder()->CreationContext(). |
| 161 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current
(info.GetIsolate())); | 161 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current
(info.GetIsolate())); |
| 162 if (context.IsEmpty()) | 162 if (context.IsEmpty()) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 v8::Handle<v8::Value> jsEvent = V8HiddenValue::getHiddenValue(info.GetIsolat
e(), context->Global(), V8HiddenValue::event(info.GetIsolate())); | 165 v8::Handle<v8::Value> jsEvent = V8HiddenValue::getHiddenValue(info.GetIsolat
e(), context->Global(), V8HiddenValue::event(info.GetIsolate())); |
| 166 if (jsEvent.IsEmpty()) | 166 if (jsEvent.IsEmpty()) |
| 167 return; | 167 return; |
| 168 v8SetReturnValue(info, jsEvent); | 168 v8SetReturnValue(info, jsEvent); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8::
PropertyCallbackInfo<void>& info) | 171 void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8::
PropertyCallbackInfo<void>& info) |
| 172 { | 172 { |
| 173 LocalFrame* frame = V8Window::toImpl(info.Holder())->frame(); | 173 LocalFrame* frame = toLocalDOMWindow(V8Window::toImpl(info.Holder()))->frame
(); |
| 174 ExceptionState exceptionState(ExceptionState::SetterContext, "event", "Windo
w", info.Holder(), info.GetIsolate()); | 174 ExceptionState exceptionState(ExceptionState::SetterContext, "event", "Windo
w", info.Holder(), info.GetIsolate()); |
| 175 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc
eptionState)) { | 175 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc
eptionState)) { |
| 176 exceptionState.throwIfNeeded(); | 176 exceptionState.throwIfNeeded(); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 | 179 |
| 180 ASSERT(frame); | 180 ASSERT(frame); |
| 181 // This is a fast path to retrieve info.Holder()->CreationContext(). | 181 // This is a fast path to retrieve info.Holder()->CreationContext(). |
| 182 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current
(info.GetIsolate())); | 182 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current
(info.GetIsolate())); |
| 183 if (context.IsEmpty()) | 183 if (context.IsEmpty()) |
| 184 return; | 184 return; |
| 185 | 185 |
| 186 V8HiddenValue::setHiddenValue(info.GetIsolate(), context->Global(), V8Hidden
Value::event(info.GetIsolate()), value); | 186 V8HiddenValue::setHiddenValue(info.GetIsolate(), context->Global(), V8Hidden
Value::event(info.GetIsolate()), value); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<
v8::Value>& info) | 189 void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<
v8::Value>& info) |
| 190 { | 190 { |
| 191 LocalDOMWindow* impl = V8Window::toImpl(info.Holder()); | 191 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 192 ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Windo
w", info.Holder(), info.GetIsolate()); | 192 ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Windo
w", info.Holder(), info.GetIsolate()); |
| 193 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), impl->frame
Element(), exceptionState)) { | 193 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), impl->frame
Element(), exceptionState)) { |
| 194 v8SetReturnValueNull(info); | 194 v8SetReturnValueNull(info); |
| 195 exceptionState.throwIfNeeded(); | 195 exceptionState.throwIfNeeded(); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 // The wrapper for an <iframe> should get its prototype from the context of
the frame it's in, rather than its own frame. | 199 // The wrapper for an <iframe> should get its prototype from the context of
the frame it's in, rather than its own frame. |
| 200 // So, use its containing document as the creation context when wrapping. | 200 // So, use its containing document as the creation context when wrapping. |
| 201 v8::Handle<v8::Value> creationContext = toV8(&impl->frameElement()->document
(), info.Holder(), info.GetIsolate()); | 201 v8::Handle<v8::Value> creationContext = toV8(&impl->frameElement()->document
(), info.Holder(), info.GetIsolate()); |
| 202 RELEASE_ASSERT(!creationContext.IsEmpty()); | 202 RELEASE_ASSERT(!creationContext.IsEmpty()); |
| 203 v8::Handle<v8::Value> wrapper = toV8(impl->frameElement(), v8::Handle<v8::Ob
ject>::Cast(creationContext), info.GetIsolate()); | 203 v8::Handle<v8::Value> wrapper = toV8(impl->frameElement(), v8::Handle<v8::Ob
ject>::Cast(creationContext), info.GetIsolate()); |
| 204 v8SetReturnValue(info, wrapper); | 204 v8SetReturnValue(info, wrapper); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
:PropertyCallbackInfo<void>& info) | 207 void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
:PropertyCallbackInfo<void>& info) |
| 208 { | 208 { |
| 209 LocalDOMWindow* impl = V8Window::toImpl(info.Holder()); | 209 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 210 ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Wind
ow", info.Holder(), info.GetIsolate()); | 210 ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Wind
ow", info.Holder(), info.GetIsolate()); |
| 211 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 211 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
| 212 exceptionState.throwIfNeeded(); | 212 exceptionState.throwIfNeeded(); |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Opener can be shadowed if it is in the same domain. | 216 // Opener can be shadowed if it is in the same domain. |
| 217 // Have a special handling of null value to behave | 217 // Have a special handling of null value to behave |
| 218 // like Firefox. See bug http://b/1224887 & http://b/791706. | 218 // like Firefox. See bug http://b/1224887 & http://b/791706. |
| 219 if (value->IsNull()) { | 219 if (value->IsNull()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 236 if (value->IsString() || value->IsStringObject()) | 236 if (value->IsString() || value->IsStringObject()) |
| 237 return true; | 237 return true; |
| 238 return false; | 238 return false; |
| 239 } | 239 } |
| 240 | 240 |
| 241 | 241 |
| 242 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) | 242 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 243 { | 243 { |
| 244 // None of these need to be RefPtr because info and context are guaranteed | 244 // None of these need to be RefPtr because info and context are guaranteed |
| 245 // to hold on to them. | 245 // to hold on to them. |
| 246 LocalDOMWindow* window = V8Window::toImpl(info.Holder()); | 246 DOMWindow* window = V8Window::toImpl(info.Holder()); |
| 247 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); | 247 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); |
| 248 | 248 |
| 249 ASSERT(window); | 249 ASSERT(window); |
| 250 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame(), UseC
ounter::WindowPostMessage); | 250 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame(), UseC
ounter::WindowPostMessage); |
| 251 | 251 |
| 252 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); | 252 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); |
| 253 | 253 |
| 254 // If called directly by WebCore we don't have a calling context. | 254 // If called directly by WebCore we don't have a calling context. |
| 255 if (!source) { | 255 if (!source) { |
| 256 exceptionState.throwTypeError("No active calling context exists."); | 256 exceptionState.throwTypeError("No active calling context exists."); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return handleScope.Escape(returnValue); | 348 return handleScope.Escape(returnValue); |
| 349 } | 349 } |
| 350 | 350 |
| 351 static void setUpDialog(LocalDOMWindow* dialog, void* handler) | 351 static void setUpDialog(LocalDOMWindow* dialog, void* handler) |
| 352 { | 352 { |
| 353 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); | 353 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 356 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 357 { | 357 { |
| 358 LocalDOMWindow* impl = V8Window::toImpl(info.Holder()); | 358 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 359 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); | 359 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); |
| 360 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 360 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
| 361 exceptionState.throwIfNeeded(); | 361 exceptionState.throwIfNeeded(); |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 | 364 |
| 365 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, urlString
, info[0]); | 365 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, urlString
, info[0]); |
| 366 DialogHandler handler(info[1], ScriptState::current(info.GetIsolate())); | 366 DialogHandler handler(info[1], ScriptState::current(info.GetIsolate())); |
| 367 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, dialogFea
turesString, info[2]); | 367 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, dialogFea
turesString, info[2]); |
| 368 | 368 |
| 369 impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info
.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler); | 369 impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info
.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler); |
| 370 | 370 |
| 371 v8SetReturnValue(info, handler.returnValue()); | 371 v8SetReturnValue(info, handler.returnValue()); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 374 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 375 { | 375 { |
| 376 LocalDOMWindow* impl = V8Window::toImpl(info.Holder()); | 376 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 377 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); | 377 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); |
| 378 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 378 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
| 379 exceptionState.throwIfNeeded(); | 379 exceptionState.throwIfNeeded(); |
| 380 return; | 380 return; |
| 381 } | 381 } |
| 382 | 382 |
| 383 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, urlString
, info[0]); | 383 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, urlString
, info[0]); |
| 384 AtomicString frameName; | 384 AtomicString frameName; |
| 385 if (info[1]->IsUndefined() || info[1]->IsNull()) { | 385 if (info[1]->IsUndefined() || info[1]->IsNull()) { |
| 386 frameName = "_blank"; | 386 frameName = "_blank"; |
| 387 } else { | 387 } else { |
| 388 TOSTRING_VOID(V8StringResource<>, frameNameResource, info[1]); | 388 TOSTRING_VOID(V8StringResource<>, frameNameResource, info[1]); |
| 389 frameName = frameNameResource; | 389 frameName = frameNameResource; |
| 390 } | 390 } |
| 391 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, windowFea
turesString, info[2]); | 391 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, windowFea
turesString, info[2]); |
| 392 | 392 |
| 393 RefPtrWillBeRawPtr<LocalDOMWindow> openedWindow = impl->open(urlString, fram
eName, windowFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWind
ow(info.GetIsolate())); | 393 RefPtrWillBeRawPtr<LocalDOMWindow> openedWindow = impl->open(urlString, fram
eName, windowFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWind
ow(info.GetIsolate())); |
| 394 if (!openedWindow) | 394 if (!openedWindow) |
| 395 return; | 395 return; |
| 396 | 396 |
| 397 v8SetReturnValueFast(info, openedWindow.release(), impl); | 397 v8SetReturnValueFast(info, openedWindow.release(), impl); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Value>& info) | 400 void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Value>& info) |
| 401 { | 401 { |
| 402 | 402 LocalDOMWindow* window = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 403 LocalDOMWindow* window = V8Window::toImpl(info.Holder()); | |
| 404 if (!window) | 403 if (!window) |
| 405 return; | 404 return; |
| 406 | 405 |
| 407 LocalFrame* frame = window->frame(); | 406 LocalFrame* frame = window->frame(); |
| 408 // window is detached from a frame. | 407 // window is detached from a frame. |
| 409 if (!frame) | 408 if (!frame) |
| 410 return; | 409 return; |
| 411 | 410 |
| 412 // Search sub-frames. | 411 // Search sub-frames. |
| 413 AtomicString propName = toCoreAtomicString(name); | 412 AtomicString propName = toCoreAtomicString(name); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 exceptionState.throwIfNeeded(); | 454 exceptionState.throwIfNeeded(); |
| 456 } | 455 } |
| 457 | 456 |
| 458 bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8
::Value> key, v8::AccessType type, v8::Local<v8::Value>) | 457 bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8
::Value> key, v8::AccessType type, v8::Local<v8::Value>) |
| 459 { | 458 { |
| 460 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 459 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 461 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); | 460 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); |
| 462 if (window.IsEmpty()) | 461 if (window.IsEmpty()) |
| 463 return false; // the frame is gone. | 462 return false; // the frame is gone. |
| 464 | 463 |
| 465 LocalDOMWindow* targetWindow = V8Window::toImpl(window); | 464 DOMWindow* targetWindow = V8Window::toImpl(window); |
| 465 ASSERT(targetWindow); |
| 466 if (!targetWindow->isLocalDOMWindow()) |
| 467 return false; |
| 466 | 468 |
| 467 ASSERT(targetWindow); | 469 LocalFrame* target = toLocalDOMWindow(targetWindow)->frame(); |
| 468 | |
| 469 LocalFrame* target = targetWindow->frame(); | |
| 470 if (!target) | 470 if (!target) |
| 471 return false; | 471 return false; |
| 472 | 472 |
| 473 // Notify the loader's client if the initial document has been accessed. | 473 // Notify the loader's client if the initial document has been accessed. |
| 474 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 474 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 475 target->loader().didAccessInitialDocument(); | 475 target->loader().didAccessInitialDocument(); |
| 476 | 476 |
| 477 if (key->IsString()) { | 477 if (key->IsString()) { |
| 478 DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__
", AtomicString::ConstructFromLiteral)); | 478 DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__
", AtomicString::ConstructFromLiteral)); |
| 479 | 479 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 498 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); | 498 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); |
| 499 } | 499 } |
| 500 | 500 |
| 501 bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t i
ndex, v8::AccessType type, v8::Local<v8::Value>) | 501 bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t i
ndex, v8::AccessType type, v8::Local<v8::Value>) |
| 502 { | 502 { |
| 503 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 503 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 504 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); | 504 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); |
| 505 if (window.IsEmpty()) | 505 if (window.IsEmpty()) |
| 506 return false; | 506 return false; |
| 507 | 507 |
| 508 LocalDOMWindow* targetWindow = V8Window::toImpl(window); | 508 DOMWindow* targetWindow = V8Window::toImpl(window); |
| 509 ASSERT(targetWindow); |
| 510 if (!targetWindow->isLocalDOMWindow()) |
| 511 return false; |
| 509 | 512 |
| 510 ASSERT(targetWindow); | 513 LocalFrame* target = toLocalDOMWindow(targetWindow)->frame(); |
| 511 | |
| 512 LocalFrame* target = targetWindow->frame(); | |
| 513 if (!target) | 514 if (!target) |
| 514 return false; | 515 return false; |
| 515 | 516 |
| 516 // Notify the loader's client if the initial document has been accessed. | 517 // Notify the loader's client if the initial document has been accessed. |
| 517 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 518 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 518 target->loader().didAccessInitialDocument(); | 519 target->loader().didAccessInitialDocument(); |
| 519 | 520 |
| 520 Frame* childFrame = target->tree().scopedChild(index); | 521 Frame* childFrame = target->tree().scopedChild(index); |
| 521 | 522 |
| 522 // Notice that we can't call HasRealNamedProperty for ACCESS_HAS | 523 // Notice that we can't call HasRealNamedProperty for ACCESS_HAS |
| 523 // because that would generate infinite recursion. | 524 // because that would generate infinite recursion. |
| 524 if (type == v8::ACCESS_HAS && childFrame) | 525 if (type == v8::ACCESS_HAS && childFrame) |
| 525 return true; | 526 return true; |
| 526 if (type == v8::ACCESS_GET | 527 if (type == v8::ACCESS_GET |
| 527 && childFrame | 528 && childFrame |
| 528 && !host->HasRealIndexedProperty(index) | 529 && !host->HasRealIndexedProperty(index) |
| 529 && !window->HasRealIndexedProperty(index)) | 530 && !window->HasRealIndexedProperty(index)) |
| 530 return true; | 531 return true; |
| 531 | 532 |
| 532 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); | 533 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); |
| 533 } | 534 } |
| 534 | 535 |
| 535 v8::Handle<v8::Value> toV8(LocalDOMWindow* window, v8::Handle<v8::Object> creati
onContext, v8::Isolate* isolate) | 536 v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Handle<v8::Object> creationCon
text, v8::Isolate* isolate) |
| 536 { | 537 { |
| 537 // Notice that we explicitly ignore creationContext because the LocalDOMWind
ow is its own creationContext. | 538 // Notice that we explicitly ignore creationContext because the LocalDOMWind
ow is its own creationContext. |
| 538 | 539 |
| 539 if (!window) | 540 // FIXME: Eventually, this needs to handle RemoteDOMWindows, since this is |
| 541 // on the code path for getting window.self, window.top, etc. |
| 542 if (!window || !window->isLocalDOMWindow()) |
| 540 return v8::Null(isolate); | 543 return v8::Null(isolate); |
| 541 // Initializes environment of a frame, and return the global object | 544 // Initializes environment of a frame, and return the global object |
| 542 // of the frame. | 545 // of the frame. |
| 543 LocalFrame* frame = window->frame(); | 546 LocalFrame* frame = toLocalDOMWindow(window)->frame(); |
| 544 if (!frame) | 547 if (!frame) |
| 545 return v8Undefined(); | 548 return v8Undefined(); |
| 546 | 549 |
| 547 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); | 550 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); |
| 548 if (context.IsEmpty()) | 551 if (context.IsEmpty()) |
| 549 return v8Undefined(); | 552 return v8Undefined(); |
| 550 | 553 |
| 551 v8::Handle<v8::Object> global = context->Global(); | 554 v8::Handle<v8::Object> global = context->Global(); |
| 552 ASSERT(!global.IsEmpty()); | 555 ASSERT(!global.IsEmpty()); |
| 553 return global; | 556 return global; |
| 554 } | 557 } |
| 555 | 558 |
| 556 } // namespace blink | 559 } // namespace blink |
| OLD | NEW |