OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // origins that should only allow access to themselves. In this | 447 // origins that should only allow access to themselves. In this |
448 // case, we use the global object as the security token to avoid | 448 // case, we use the global object as the security token to avoid |
449 // calling canAccess when a script accesses its own objects. | 449 // calling canAccess when a script accesses its own objects. |
450 v8::HandleScope handleScope(m_isolate); | 450 v8::HandleScope handleScope(m_isolate); |
451 v8::Local<v8::Context> context = m_scriptState->context(); | 451 v8::Local<v8::Context> context = m_scriptState->context(); |
452 if (token.isEmpty() || token == "null") { | 452 if (token.isEmpty() || token == "null") { |
453 context->UseDefaultSecurityToken(); | 453 context->UseDefaultSecurityToken(); |
454 return; | 454 return; |
455 } | 455 } |
456 | 456 |
457 if (m_world->isPrivateScriptIsolatedWorld()) | 457 if (m_world->isPrivateScriptIsolatedWorld()) { |
458 token = "private-script://" + token; | 458 token = "private-script://" + token; |
| 459 } else if (m_world->isIsolatedWorld()) { |
| 460 SecurityOrigin* frameSecurityOrigin = m_frame->securityContext()->securi
tyOrigin(); |
| 461 String frameSecurityToken = frameSecurityOrigin->toString(); |
| 462 // We need to check the return value of domainWasSetInDOM() on the |
| 463 // frame's SecurityOrigin because, if that's the case, only |
| 464 // SecurityOrigin::m_domain would have been modified. |
| 465 // m_domain is not used by SecurityOrigin::toString(), so we would end |
| 466 // up generating the same token that was already set. |
| 467 if (frameSecurityOrigin->domainWasSetInDOM() || frameSecurityToken.isEmp
ty() || frameSecurityToken == "null") { |
| 468 context->UseDefaultSecurityToken(); |
| 469 return; |
| 470 } |
| 471 token = frameSecurityToken + token; |
| 472 } |
459 | 473 |
460 CString utf8Token = token.utf8(); | 474 CString utf8Token = token.utf8(); |
461 // NOTE: V8 does identity comparison in fast path, must use a symbol | 475 // NOTE: V8 does identity comparison in fast path, must use a symbol |
462 // as the security token. | 476 // as the security token. |
463 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To
ken.length())); | 477 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To
ken.length())); |
464 } | 478 } |
465 | 479 |
466 void WindowProxy::updateDocument() | 480 void WindowProxy::updateDocument() |
467 { | 481 { |
468 ASSERT(m_world->isMainWorld()); | 482 ASSERT(m_world->isMainWorld()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 555 |
542 ScriptState::Scope scope(m_scriptState.get()); | 556 ScriptState::Scope scope(m_scriptState.get()); |
543 ASSERT(!m_document.isEmpty()); | 557 ASSERT(!m_document.isEmpty()); |
544 v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); | 558 v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); |
545 checkDocumentWrapper(documentHandle, document); | 559 checkDocumentWrapper(documentHandle, document); |
546 documentHandle->Delete(m_isolate->GetCurrentContext(), v8String(m_isolate, n
ame)); | 560 documentHandle->Delete(m_isolate->GetCurrentContext(), v8String(m_isolate, n
ame)); |
547 } | 561 } |
548 | 562 |
549 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) | 563 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) |
550 { | 564 { |
551 ASSERT(m_world->isMainWorld()); | |
552 if (!isContextInitialized()) | 565 if (!isContextInitialized()) |
553 return; | 566 return; |
554 setSecurityToken(origin); | 567 setSecurityToken(origin); |
555 } | 568 } |
556 | 569 |
557 } // namespace blink | 570 } // namespace blink |
OLD | NEW |