Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: Source/bindings/core/v8/ScriptController.cpp

Issue 388913004: evaluateScriptInMainWorld() should check if the target context exists before evaluating a script (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 576
577 v8::Local<v8::Value> ScriptController::evaluateScriptInMainWorld(const ScriptSou rceCode& sourceCode, AccessControlStatus corsStatus, ExecuteScriptPolicy policy) 577 v8::Local<v8::Value> ScriptController::evaluateScriptInMainWorld(const ScriptSou rceCode& sourceCode, AccessControlStatus corsStatus, ExecuteScriptPolicy policy)
578 { 578 {
579 if (policy == DoNotExecuteScriptWhenScriptsDisabled && !canExecuteScripts(Ab outToExecuteScript)) 579 if (policy == DoNotExecuteScriptWhenScriptsDisabled && !canExecuteScripts(Ab outToExecuteScript))
580 return v8::Local<v8::Value>(); 580 return v8::Local<v8::Value>();
581 581
582 String sourceURL = sourceCode.url(); 582 String sourceURL = sourceCode.url();
583 const String* savedSourceURL = m_sourceURL; 583 const String* savedSourceURL = m_sourceURL;
584 m_sourceURL = &sourceURL; 584 m_sourceURL = &sourceURL;
585 585
586 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); 586 v8::EscapableHandleScope handleScope(m_isolate);
587 if (scriptState->contextIsEmpty()) 587 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main World());
588 if (context.IsEmpty())
588 return v8::Local<v8::Value>(); 589 return v8::Local<v8::Value>();
589 590
590 v8::EscapableHandleScope handleScope(scriptState->isolate()); 591 ScriptState* scriptState = ScriptState::from(context);
591 ScriptState::Scope scope(scriptState); 592 ScriptState::Scope scope(scriptState);
592 593
593 RefPtr<LocalFrame> protect(m_frame); 594 RefPtr<LocalFrame> protect(m_frame);
594 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) 595 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument())
595 m_frame->loader().didAccessInitialDocument(); 596 m_frame->loader().didAccessInitialDocument();
596 597
597 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio n::preprocess(m_frame, sourceCode); 598 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio n::preprocess(m_frame, sourceCode);
598 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma ybeProcessedSourceCode : sourceCode; 599 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma ybeProcessedSourceCode : sourceCode;
599 600
600 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCodeToCompile, corsStatus); 601 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCodeToCompile, corsStatus);
(...skipping 26 matching lines...) Expand all
627 resultArray->Set(i, evaluationResult); 628 resultArray->Set(i, evaluationResult);
628 } 629 }
629 630
630 if (results) { 631 if (results) {
631 for (size_t i = 0; i < resultArray->Length(); ++i) 632 for (size_t i = 0; i < resultArray->Length(); ++i)
632 results->append(handleScope.Escape(resultArray->Get(i))); 633 results->append(handleScope.Escape(resultArray->Get(i)));
633 } 634 }
634 } 635 }
635 636
636 } // namespace WebCore 637 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698