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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp

Issue 1863363003: [DevTools] Bring back bypassing CSP for eval in Runtime.evaluate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return; 109 return;
110 } 110 }
111 contextId = mainInGroup->contextId(); 111 contextId = mainInGroup->contextId();
112 } 112 }
113 113
114 InjectedScript* injectedScript = m_connection->findInjectedScript(errorStrin g, contextId); 114 InjectedScript* injectedScript = m_connection->findInjectedScript(errorStrin g, contextId);
115 if (!injectedScript) 115 if (!injectedScript)
116 return; 116 return;
117 117
118 v8::HandleScope scope(injectedScript->isolate()); 118 v8::HandleScope scope(injectedScript->isolate());
119 v8::Context::Scope contextScope(injectedScript->context()->context()); 119 v8::Local<v8::Context> context = injectedScript->context()->context();
120 v8::Context::Scope contextScope(context);
120 121
121 if (!injectedScript->canAccessInspectedWindow()) { 122 if (!injectedScript->canAccessInspectedWindow()) {
122 *errorString = "Can not access given context"; 123 *errorString = "Can not access given context";
123 return; 124 return;
124 } 125 }
125 126
126 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole.fromMaybe(false) ? m_debugger : nullptr); 127 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole.fromMaybe(false) ? m_debugger : nullptr);
127 MuteConsoleScope muteConsoleScope(doNotPauseOnExceptionsAndMuteConsole.fromM aybe(false) ? m_debugger : nullptr); 128 MuteConsoleScope muteConsoleScope(doNotPauseOnExceptionsAndMuteConsole.fromM aybe(false) ? m_debugger : nullptr);
128 v8::TryCatch tryCatch(injectedScript->isolate()); 129 v8::TryCatch tryCatch(injectedScript->isolate());
129 130
130 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe( false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object >(); 131 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe( false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object >();
131 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty()) 132 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty())
132 return; 133 return;
133 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, c ommandLineAPI); 134 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, c ommandLineAPI);
134 135
136 bool evalIsDisabled = !context->IsCodeGenerationFromStringsAllowed();
137 // Temporarily enable allow evals for inspector.
138 if (evalIsDisabled)
139 context->AllowCodeGenerationFromStrings(true);
135 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->compileAndRunIntern alScript(injectedScript->context()->context(), toV8String(injectedScript->isolat e(), expression)); 140 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->compileAndRunIntern alScript(injectedScript->context()->context(), toV8String(injectedScript->isolat e(), expression));
141 if (evalIsDisabled)
142 context->AllowCodeGenerationFromStrings(false);
136 // InjectedScript may be gone after any evaluate call - find it again. 143 // InjectedScript may be gone after any evaluate call - find it again.
137 injectedScript = m_connection->findInjectedScript(errorString, contextId); 144 injectedScript = m_connection->findInjectedScript(errorString, contextId);
138 if (!injectedScript) 145 if (!injectedScript)
139 return; 146 return;
140 147
141 injectedScript->wrapEvaluateResult(errorString, 148 injectedScript->wrapEvaluateResult(errorString,
142 maybeResultValue, 149 maybeResultValue,
143 tryCatch, 150 tryCatch,
144 objectGroup.fromMaybe(""), 151 objectGroup.fromMaybe(""),
145 returnByValue.fromMaybe(false), 152 returnByValue.fromMaybe(false),
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 556
550 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* conte xt) 557 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* conte xt)
551 { 558 {
552 if (m_enabled && context->isReported()) { 559 if (m_enabled && context->isReported()) {
553 context->setReported(false); 560 context->setReported(false);
554 m_frontend->executionContextDestroyed(context->contextId()); 561 m_frontend->executionContextDestroyed(context->contextId());
555 } 562 }
556 } 563 }
557 564
558 } // namespace blink 565 } // namespace blink
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