OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 450 matching lines...) Loading... |
461 if (frame()->document() && frame()->document()->isSandboxed(SandboxScripts))
{ | 461 if (frame()->document() && frame()->document()->isSandboxed(SandboxScripts))
{ |
462 if (isInPrivateScriptIsolateWorld(isolate())) | 462 if (isInPrivateScriptIsolateWorld(isolate())) |
463 return true; | 463 return true; |
464 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 464 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
465 if (reason == AboutToExecuteScript) | 465 if (reason == AboutToExecuteScript) |
466 frame()->document()->addConsoleMessage(ConsoleMessage::create(Securi
tyMessageSource, ErrorMessageLevel, "Blocked script execution in '" + frame()->d
ocument()->url().elidedString() + "' because the document's frame is sandboxed a
nd the 'allow-scripts' permission is not set.")); | 466 frame()->document()->addConsoleMessage(ConsoleMessage::create(Securi
tyMessageSource, ErrorMessageLevel, "Blocked script execution in '" + frame()->d
ocument()->url().elidedString() + "' because the document's frame is sandboxed a
nd the 'allow-scripts' permission is not set.")); |
467 return false; | 467 return false; |
468 } | 468 } |
469 | 469 |
470 if (frame()->document() && frame()->document()->isViewSource()) { | 470 if (frame()->document() && frame()->document()->isViewSource()) { |
471 ASSERT(frame()->document()->securityOrigin()->isUnique()); | 471 ASSERT(frame()->document()->getSecurityOrigin()->isUnique()); |
472 return true; | 472 return true; |
473 } | 473 } |
474 | 474 |
475 FrameLoaderClient* client = frame()->loader().client(); | 475 FrameLoaderClient* client = frame()->loader().client(); |
476 if (!client) | 476 if (!client) |
477 return false; | 477 return false; |
478 Settings* settings = frame()->settings(); | 478 Settings* settings = frame()->settings(); |
479 const bool allowed = client->allowScript(settings && settings->scriptEnabled
()) | 479 const bool allowed = client->allowScript(settings && settings->scriptEnabled
()) |
480 || isInPrivateScriptIsolateWorld(isolate()); | 480 || isInPrivateScriptIsolateWorld(isolate()); |
481 if (!allowed && reason == AboutToExecuteScript) | 481 if (!allowed && reason == AboutToExecuteScript) |
(...skipping 96 matching lines...) Loading... |
578 | 578 |
579 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea
pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val
ue>>* results) | 579 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea
pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val
ue>>* results) |
580 { | 580 { |
581 ASSERT(worldID > 0); | 581 ASSERT(worldID > 0); |
582 | 582 |
583 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate
(), worldID, extensionGroup); | 583 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate
(), worldID, extensionGroup); |
584 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); | 584 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); |
585 if (!isolatedWorldWindowProxy->isContextInitialized()) | 585 if (!isolatedWorldWindowProxy->isContextInitialized()) |
586 return; | 586 return; |
587 | 587 |
588 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); | 588 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); |
589 v8::Context::Scope scope(scriptState->context()); | 589 v8::Context::Scope scope(scriptState->context()); |
590 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size())
; | 590 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size())
; |
591 | 591 |
592 for (size_t i = 0; i < sources.size(); ++i) { | 592 for (size_t i = 0; i < sources.size(); ++i) { |
593 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri
ptState->context(), sources[i]); | 593 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri
ptState->context(), sources[i]); |
594 if (evaluationResult.IsEmpty()) | 594 if (evaluationResult.IsEmpty()) |
595 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine
d(isolate())); | 595 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine
d(isolate())); |
596 if (!v8CallBoolean(resultArray->Set(scriptState->context(), v8::Integer:
:New(scriptState->isolate(), i), evaluationResult))) | 596 if (!v8CallBoolean(resultArray->Set(scriptState->context(), v8::Integer:
:New(scriptState->isolate(), i), evaluationResult))) |
597 return; | 597 return; |
598 } | 598 } |
599 | 599 |
600 if (results) { | 600 if (results) { |
601 for (size_t i = 0; i < resultArray->Length(); ++i) { | 601 for (size_t i = 0; i < resultArray->Length(); ++i) { |
602 v8::Local<v8::Value> value; | 602 v8::Local<v8::Value> value; |
603 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 603 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
604 return; | 604 return; |
605 results->append(value); | 605 results->append(value); |
606 } | 606 } |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 } // namespace blink | 610 } // namespace blink |
OLD | NEW |