| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const v8::PropertyCallbackInfo<v8::Value>& info) { | 118 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 119 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); | 119 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); |
| 120 | 120 |
| 121 if (!BindingSecurity::shouldAllowAccessTo( | 121 if (!BindingSecurity::shouldAllowAccessTo( |
| 122 currentDOMWindow(info.GetIsolate()), impl->frameElement(), | 122 currentDOMWindow(info.GetIsolate()), impl->frameElement(), |
| 123 BindingSecurity::ErrorReportOption::DoNotReport)) { | 123 BindingSecurity::ErrorReportOption::DoNotReport)) { |
| 124 v8SetReturnValueNull(info); | 124 v8SetReturnValueNull(info); |
| 125 return; | 125 return; |
| 126 } | 126 } |
| 127 | 127 |
| 128 // The wrapper for an <iframe> should get its prototype from the context of th
e frame it's in, rather than its own frame. | 128 // The wrapper for an <iframe> should get its prototype from the context of |
| 129 // the frame it's in, rather than its own frame. |
| 129 // So, use its containing document as the creation context when wrapping. | 130 // So, use its containing document as the creation context when wrapping. |
| 130 v8::Local<v8::Value> creationContext = | 131 v8::Local<v8::Value> creationContext = |
| 131 toV8(&impl->frameElement()->document(), info.Holder(), info.GetIsolate()); | 132 toV8(&impl->frameElement()->document(), info.Holder(), info.GetIsolate()); |
| 132 RELEASE_ASSERT(!creationContext.IsEmpty()); | 133 RELEASE_ASSERT(!creationContext.IsEmpty()); |
| 133 v8::Local<v8::Value> wrapper = | 134 v8::Local<v8::Value> wrapper = |
| 134 toV8(impl->frameElement(), v8::Local<v8::Object>::Cast(creationContext), | 135 toV8(impl->frameElement(), v8::Local<v8::Object>::Cast(creationContext), |
| 135 info.GetIsolate()); | 136 info.GetIsolate()); |
| 136 v8SetReturnValue(info, wrapper); | 137 v8SetReturnValue(info, wrapper); |
| 137 } | 138 } |
| 138 | 139 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 const v8::PropertyCallbackInfo<v8::Value>& info) { | 270 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 270 DOMWindow* window = V8Window::toImpl(info.Holder()); | 271 DOMWindow* window = V8Window::toImpl(info.Holder()); |
| 271 if (!window) | 272 if (!window) |
| 272 return; | 273 return; |
| 273 | 274 |
| 274 Frame* frame = window->frame(); | 275 Frame* frame = window->frame(); |
| 275 // window is detached from a frame. | 276 // window is detached from a frame. |
| 276 if (!frame) | 277 if (!frame) |
| 277 return; | 278 return; |
| 278 | 279 |
| 279 // Note that the spec doesn't allow any cross-origin named access to the windo
w object. However, | 280 // Note that the spec doesn't allow any cross-origin named access to the |
| 280 // UAs have traditionally allowed named access to named child browsing context
s, even across | 281 // window object. However, UAs have traditionally allowed named access to |
| 281 // origins. So first, search child frames for a frame with a matching name. | 282 // named child browsing contexts, even across origins. So first, search child |
| 283 // frames for a frame with a matching name. |
| 282 Frame* child = frame->tree().scopedChild(name); | 284 Frame* child = frame->tree().scopedChild(name); |
| 283 if (child) { | 285 if (child) { |
| 284 v8SetReturnValueFast(info, child->domWindow(), window); | 286 v8SetReturnValueFast(info, child->domWindow(), window); |
| 285 return; | 287 return; |
| 286 } | 288 } |
| 287 | 289 |
| 288 // If the frame is remote, the caller will never be able to access further nam
ed results. | 290 // If the frame is remote, the caller will never be able to access further |
| 291 // named results. |
| 289 if (!frame->isLocalFrame()) | 292 if (!frame->isLocalFrame()) |
| 290 return; | 293 return; |
| 291 | 294 |
| 292 // Search named items in the document. | 295 // Search named items in the document. |
| 293 Document* doc = toLocalFrame(frame)->document(); | 296 Document* doc = toLocalFrame(frame)->document(); |
| 294 if (!doc || !doc->isHTMLDocument()) | 297 if (!doc || !doc->isHTMLDocument()) |
| 295 return; | 298 return; |
| 296 | 299 |
| 297 // This is an AllCanRead interceptor. Check that the caller has access to the
named results. | 300 // This is an AllCanRead interceptor. Check that the caller has access to the |
| 301 // named results. |
| 298 if (!BindingSecurity::shouldAllowAccessTo( | 302 if (!BindingSecurity::shouldAllowAccessTo( |
| 299 currentDOMWindow(info.GetIsolate()), window, | 303 currentDOMWindow(info.GetIsolate()), window, |
| 300 BindingSecurity::ErrorReportOption::DoNotReport)) | 304 BindingSecurity::ErrorReportOption::DoNotReport)) |
| 301 return; | 305 return; |
| 302 | 306 |
| 303 bool hasNamedItem = toHTMLDocument(doc)->hasNamedItem(name); | 307 bool hasNamedItem = toHTMLDocument(doc)->hasNamedItem(name); |
| 304 bool hasIdItem = doc->hasElementWithId(name); | 308 bool hasIdItem = doc->hasElementWithId(name); |
| 305 | 309 |
| 306 if (!hasNamedItem && !hasIdItem) | 310 if (!hasNamedItem && !hasIdItem) |
| 307 return; | 311 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 320 if (items->hasExactlyOneItem()) { | 324 if (items->hasExactlyOneItem()) { |
| 321 v8SetReturnValueFast(info, items->item(0), window); | 325 v8SetReturnValueFast(info, items->item(0), window); |
| 322 return; | 326 return; |
| 323 } | 327 } |
| 324 v8SetReturnValueFast(info, items, window); | 328 v8SetReturnValueFast(info, items, window); |
| 325 return; | 329 return; |
| 326 } | 330 } |
| 327 } | 331 } |
| 328 | 332 |
| 329 } // namespace blink | 333 } // namespace blink |
| OLD | NEW |