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

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

Issue 1855393003: [DevTools] Fix custom formatters (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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return; 100 return;
101 101
102 v8::HandleScope scope(injectedScript->isolate()); 102 v8::HandleScope scope(injectedScript->isolate());
103 v8::Context::Scope contextScope(injectedScript->context()->context()); 103 v8::Context::Scope contextScope(injectedScript->context()->context());
104 104
105 if (!injectedScript->canAccessInspectedWindow()) { 105 if (!injectedScript->canAccessInspectedWindow()) {
106 *errorString = "Can not access given context"; 106 *errorString = "Can not access given context";
107 return; 107 return;
108 } 108 }
109 109
110 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole.fromMaybe(false) ? m_debugger : nullptr);
111 MuteConsoleScope muteConsoleScope(doNotPauseOnExceptionsAndMuteConsole.fromM aybe(false) ? m_debugger : nullptr);
112 v8::TryCatch tryCatch(injectedScript->isolate());
113
110 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe( false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object >(); 114 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe( false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object >();
111 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty()) 115 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty())
112 return; 116 return;
117 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, c ommandLineAPI);
113 118
114 v8::TryCatch tryCatch(injectedScript->isolate()); 119 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->compileAndRunIntern alScript(injectedScript->context()->context(), toV8String(injectedScript->isolat e(), expression));
115 MuteConsoleScope muteConsoleScope(doNotPauseOnExceptionsAndMuteConsole.fromM aybe(false) ? m_debugger : nullptr);
116 v8::MaybeLocal<v8::Value> maybeResultValue = evaluateInternal(injectedScript , doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false), expression, commandLine API);
117
118 // InjectedScript may be gone after any evaluate call - find it again. 120 // InjectedScript may be gone after any evaluate call - find it again.
119 injectedScript = m_connection->findInjectedScript(errorString, executionCont extId.fromJust()); 121 injectedScript = m_connection->findInjectedScript(errorString, executionCont extId.fromJust());
120 if (!injectedScript) 122 if (!injectedScript)
121 return; 123 return;
122 124
123 injectedScript->wrapEvaluateResult(errorString, 125 injectedScript->wrapEvaluateResult(errorString,
124 maybeResultValue, 126 maybeResultValue,
125 tryCatch, 127 tryCatch,
126 objectGroup.fromMaybe(""), 128 objectGroup.fromMaybe(""),
127 returnByValue.fromMaybe(false), 129 returnByValue.fromMaybe(false),
128 generatePreview.fromMaybe(false), 130 generatePreview.fromMaybe(false),
129 result, 131 result,
130 wasThrown, 132 wasThrown,
131 exceptionDetails); 133 exceptionDetails);
132 } 134 }
133 135
134 v8::MaybeLocal<v8::Value> V8RuntimeAgentImpl::evaluateInternal(InjectedScript* i njectedScript, bool doNotPauseOnExceptionsAndMuteConsole, const String& expressi on, v8::MaybeLocal<v8::Object> extension)
135 {
136 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, e xtension);
137 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole ? m_debugger : nullptr);
138 return m_debugger->compileAndRunInternalScript(injectedScript->context()->co ntext(), toV8String(injectedScript->isolate(), expression));
139 }
140
141 void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, 136 void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString,
142 const String16& objectId, 137 const String16& objectId,
143 const String16& expression, 138 const String16& expression,
144 const Maybe<protocol::Array<protocol::Runtime::CallArgument>>& optionalArgum ents, 139 const Maybe<protocol::Array<protocol::Runtime::CallArgument>>& optionalArgum ents,
145 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, 140 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole,
146 const Maybe<bool>& returnByValue, 141 const Maybe<bool>& returnByValue,
147 const Maybe<bool>& generatePreview, 142 const Maybe<bool>& generatePreview,
148 const Maybe<bool>& userGesture, 143 const Maybe<bool>& userGesture,
149 OwnPtr<RemoteObject>* result, 144 OwnPtr<RemoteObject>* result,
150 Maybe<bool>* wasThrown) 145 Maybe<bool>* wasThrown)
(...skipping 27 matching lines...) Expand all
178 v8::Local<v8::Value> argumentValue; 173 v8::Local<v8::Value> argumentValue;
179 if (!injectedScript->resolveCallArgument(errorString, arguments->get (i)).ToLocal(&argumentValue)) 174 if (!injectedScript->resolveCallArgument(errorString, arguments->get (i)).ToLocal(&argumentValue))
180 return; 175 return;
181 argv[i] = argumentValue; 176 argv[i] = argumentValue;
182 } 177 }
183 } 178 }
184 179
185 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole.fromMaybe(false) ? m_debugger : nullptr); 180 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole.fromMaybe(false) ? m_debugger : nullptr);
186 MuteConsoleScope muteConsoleScope(doNotPauseOnExceptionsAndMuteConsole.fromM aybe(false) ? m_debugger : nullptr); 181 MuteConsoleScope muteConsoleScope(doNotPauseOnExceptionsAndMuteConsole.fromM aybe(false) ? m_debugger : nullptr);
187 182
188 v8::MaybeLocal<v8::Object> remoteObjectAPI = injectedScript->remoteObjectAPI (errorString, objectGroupName); 183 v8::TryCatch tryCatch(injectedScript->isolate());
189 if (remoteObjectAPI.IsEmpty())
190 return;
191 184
192 v8::TryCatch tryCatch(injectedScript->isolate()); 185 v8::MaybeLocal<v8::Value> maybeFunctionValue = m_debugger->compileAndRunInte rnalScript(injectedScript->context()->context(), toV8String(injectedScript->isol ate(), "(" + expression + ")"));
193 v8::MaybeLocal<v8::Value> maybeFunctionValue = evaluateInternal(injectedScri pt, doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false), "(" + expression + ") ", remoteObjectAPI);
194 // InjectedScript may be gone after any evaluate call - find it again. 186 // InjectedScript may be gone after any evaluate call - find it again.
195 injectedScript = m_connection->findInjectedScript(errorString, remoteId.get( )); 187 injectedScript = m_connection->findInjectedScript(errorString, remoteId.get( ));
196 if (!injectedScript) 188 if (!injectedScript)
197 return; 189 return;
198 190
199 if (tryCatch.HasCaught()) { 191 if (tryCatch.HasCaught()) {
200 injectedScript->wrapEvaluateResult(errorString, maybeFunctionValue, tryC atch, objectGroupName, false, false, result, wasThrown, nullptr); 192 injectedScript->wrapEvaluateResult(errorString, maybeFunctionValue, tryC atch, objectGroupName, false, false, result, wasThrown, nullptr);
201 return; 193 return;
202 } 194 }
203 195
204 v8::Local<v8::Value> functionValue; 196 v8::Local<v8::Value> functionValue;
205 if (!maybeFunctionValue.ToLocal(&functionValue) || !functionValue->IsFunctio n()) { 197 if (!maybeFunctionValue.ToLocal(&functionValue) || !functionValue->IsFunctio n()) {
206 *errorString = "Given expression does not evaluate to a function"; 198 *errorString = "Given expression does not evaluate to a function";
207 return; 199 return;
208 } 200 }
209 201
202 v8::MaybeLocal<v8::Object> remoteObjectAPI = injectedScript->remoteObjectAPI (errorString, objectGroupName);
203 if (remoteObjectAPI.IsEmpty())
204 return;
205 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, r emoteObjectAPI);
206
210 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->callFunction(functi onValue.As<v8::Function>(), injectedScript->context()->context(), object, argc, argv.get()); 207 v8::MaybeLocal<v8::Value> maybeResultValue = m_debugger->callFunction(functi onValue.As<v8::Function>(), injectedScript->context()->context(), object, argc, argv.get());
211 // InjectedScript may be gone after any evaluate call - find it again. 208 // InjectedScript may be gone after any evaluate call - find it again.
212 injectedScript = m_connection->findInjectedScript(errorString, remoteId.get( )); 209 injectedScript = m_connection->findInjectedScript(errorString, remoteId.get( ));
213 if (!injectedScript) 210 if (!injectedScript)
214 return; 211 return;
215 212
216 injectedScript->wrapEvaluateResult(errorString, maybeResultValue, tryCatch, objectGroupName, returnByValue.fromMaybe(false), generatePreview.fromMaybe(false ), result, wasThrown, nullptr); 213 injectedScript->wrapEvaluateResult(errorString, maybeResultValue, tryCatch, objectGroupName, returnByValue.fromMaybe(false), generatePreview.fromMaybe(false ), result, wasThrown, nullptr);
217 } 214 }
218 215
219 void V8RuntimeAgentImpl::getProperties( 216 void V8RuntimeAgentImpl::getProperties(
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 533
537 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* conte xt) 534 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* conte xt)
538 { 535 {
539 if (m_enabled && context->isReported()) { 536 if (m_enabled && context->isReported()) {
540 context->setReported(false); 537 context->setReported(false);
541 m_frontend->executionContextDestroyed(context->contextId()); 538 m_frontend->executionContextDestroyed(context->contextId());
542 } 539 }
543 } 540 }
544 541
545 } // namespace blink 542 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698