OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 namespace InspectorRuntimeAgentState { | 45 namespace InspectorRuntimeAgentState { |
46 static const char runtimeEnabled[] = "runtimeEnabled"; | 46 static const char runtimeEnabled[] = "runtimeEnabled"; |
47 }; | 47 }; |
48 | 48 |
49 static bool asBool(const bool* const b) | 49 static bool asBool(const bool* const b) |
50 { | 50 { |
51 return b ? *b : false; | 51 return b ? *b : false; |
52 } | 52 } |
53 | 53 |
54 InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScri
ptManager, ScriptDebugServer* scriptDebugServer) | 54 InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScri
ptManager, ScriptDebugServerBase* scriptDebugServer) |
55 : InspectorBaseAgent<InspectorRuntimeAgent>("Runtime") | 55 : InspectorBaseAgent<InspectorRuntimeAgent>("Runtime") |
56 , m_enabled(false) | 56 , m_enabled(false) |
57 , m_frontend(0) | 57 , m_frontend(0) |
58 , m_injectedScriptManager(injectedScriptManager) | 58 , m_injectedScriptManager(injectedScriptManager) |
59 , m_scriptDebugServer(scriptDebugServer) | 59 , m_scriptDebugServer(scriptDebugServer) |
60 { | 60 { |
61 } | 61 } |
62 | 62 |
63 InspectorRuntimeAgent::~InspectorRuntimeAgent() | 63 InspectorRuntimeAgent::~InspectorRuntimeAgent() |
64 { | 64 { |
65 } | 65 } |
66 | 66 |
67 static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(Scrip
tDebugServer* scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState newSt
ate) | 67 static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(Scrip
tDebugServerBase* scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState n
ewState) |
68 { | 68 { |
69 ASSERT(scriptDebugServer); | 69 ASSERT(scriptDebugServer); |
70 ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer->
pauseOnExceptionsState(); | 70 ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer->
pauseOnExceptionsState(); |
71 if (presentState != newState) | 71 if (presentState != newState) |
72 scriptDebugServer->setPauseOnExceptionsState(newState); | 72 scriptDebugServer->setPauseOnExceptionsState(newState); |
73 return presentState; | 73 return presentState; |
74 } | 74 } |
75 | 75 |
76 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp
ression, const String* const objectGroup, const bool* const includeCommandLineAP
I, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionC
ontextId, const bool* const returnByValue, const bool* generatePreview, RefPtr<T
ypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThr
own) | 76 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp
ression, const String* const objectGroup, const bool* const includeCommandLineAP
I, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionC
ontextId, const bool* const returnByValue, const bool* generatePreview, RefPtr<T
ypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThr
own) |
77 { | 77 { |
78 InjectedScript injectedScript = injectedScriptForEval(errorString, execution
ContextId); | 78 InjectedScript& injectedScript = injectedScriptForEval(errorString, executio
nContextId); |
79 if (injectedScript.isEmpty()) | 79 if (injectedScript.isEmpty()) |
80 return; | 80 return; |
81 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = S
criptDebugServer::DontPauseOnExceptions; | 81 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = S
criptDebugServer::DontPauseOnExceptions; |
82 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 82 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
83 previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebug
Server, ScriptDebugServer::DontPauseOnExceptions); | 83 previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebug
Server, ScriptDebugServer::DontPauseOnExceptions); |
84 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 84 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
85 muteConsole(); | 85 muteConsole(); |
86 | 86 |
87 injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup
: "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePrevi
ew), &result, wasThrown); | 87 injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup
: "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePrevi
ew), &result, wasThrown); |
88 | 88 |
89 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { | 89 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { |
90 unmuteConsole(); | 90 unmuteConsole(); |
91 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptions
State); | 91 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptions
State); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const Strin
g& objectId, const String& expression, const RefPtr<JSONArray>* const optionalAr
guments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* con
st returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::Remo
teObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) | 95 void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const Strin
g& objectId, const String& expression, const RefPtr<JSONArray>* const optionalAr
guments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* con
st returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::Remo
teObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) |
96 { | 96 { |
97 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); | 97 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptForO
bjectId(objectId); |
98 if (injectedScript.isEmpty()) { | 98 if (injectedScript.isEmpty()) { |
99 *errorString = "Inspected frame has gone"; | 99 *errorString = "Inspected frame has gone"; |
100 return; | 100 return; |
101 } | 101 } |
102 String arguments; | 102 String arguments; |
103 if (optionalArguments) | 103 if (optionalArguments) |
104 arguments = (*optionalArguments)->toJSONString(); | 104 arguments = (*optionalArguments)->toJSONString(); |
105 | 105 |
106 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = S
criptDebugServer::DontPauseOnExceptions; | 106 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = S
criptDebugServer::DontPauseOnExceptions; |
107 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 107 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
108 previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebug
Server, ScriptDebugServer::DontPauseOnExceptions); | 108 previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebug
Server, ScriptDebugServer::DontPauseOnExceptions); |
109 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 109 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) |
110 muteConsole(); | 110 muteConsole(); |
111 | 111 |
112 injectedScript.callFunctionOn(errorString, objectId, expression, arguments,
asBool(returnByValue), asBool(generatePreview), &result, wasThrown); | 112 injectedScript.callFunctionOn(errorString, objectId, expression, arguments,
asBool(returnByValue), asBool(generatePreview), &result, wasThrown); |
113 | 113 |
114 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { | 114 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { |
115 unmuteConsole(); | 115 unmuteConsole(); |
116 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptions
State); | 116 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptions
State); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
| 120 void InspectorRuntimeAgent::getCompletions(ErrorString* errorString, const Strin
g& expression, const int* executionContextId, RefPtr<TypeBuilder::Array<String>
>& result) |
| 121 { |
| 122 InjectedScript& injectedScript = injectedScriptForEval(errorString, executio
nContextId); |
| 123 if (injectedScript.isEmpty()) |
| 124 return; |
| 125 |
| 126 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExce
ptions); |
| 127 muteConsole(); |
| 128 |
| 129 injectedScript.getCompletions(errorString, expression, &result); |
| 130 |
| 131 unmuteConsole(); |
| 132 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat
e); |
| 133 } |
| 134 |
120 void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String
& objectId, const bool* ownProperties, const bool* accessorPropertiesOnly, RefPt
r<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, RefPtr
<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& interna
lProperties) | 135 void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String
& objectId, const bool* ownProperties, const bool* accessorPropertiesOnly, RefPt
r<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, RefPtr
<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& interna
lProperties) |
121 { | 136 { |
122 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); | 137 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptForO
bjectId(objectId); |
123 if (injectedScript.isEmpty()) { | 138 if (injectedScript.isEmpty()) { |
124 *errorString = "Inspected frame has gone"; | 139 *errorString = "Inspected frame has gone"; |
125 return; | 140 return; |
126 } | 141 } |
127 | 142 |
128 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExce
ptions); | 143 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExce
ptions); |
129 muteConsole(); | 144 muteConsole(); |
130 | 145 |
131 bool accessorPropertiesOnlyValue = accessorPropertiesOnly && *accessorProper
tiesOnly; | 146 bool accessorPropertiesOnlyValue = accessorPropertiesOnly && *accessorProper
tiesOnly; |
132 injectedScript.getProperties(errorString, objectId, ownProperties && *ownPro
perties, accessorPropertiesOnlyValue, &result); | 147 injectedScript.getProperties(errorString, objectId, ownProperties && *ownPro
perties, accessorPropertiesOnlyValue, &result); |
133 | 148 |
134 if (!accessorPropertiesOnlyValue) | 149 if (!accessorPropertiesOnlyValue) |
135 injectedScript.getInternalProperties(errorString, objectId, &internalPro
perties); | 150 injectedScript.getInternalProperties(errorString, objectId, &internalPro
perties); |
136 | 151 |
137 unmuteConsole(); | 152 unmuteConsole(); |
138 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat
e); | 153 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat
e); |
139 } | 154 } |
140 | 155 |
| 156 void InspectorRuntimeAgent::getProperty(ErrorString* errorString, const String&
objectId, const RefPtr<JSONArray>& propertyPath, RefPtr<TypeBuilder::Runtime::Re
moteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) |
| 157 { |
| 158 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptForO
bjectId(objectId); |
| 159 if (injectedScript.isEmpty()) { |
| 160 *errorString = "Inspected frame has gone"; |
| 161 return; |
| 162 } |
| 163 |
| 164 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExce
ptions); |
| 165 muteConsole(); |
| 166 |
| 167 injectedScript.getProperty(errorString, objectId, propertyPath, &result, was
Thrown); |
| 168 |
| 169 unmuteConsole(); |
| 170 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat
e); |
| 171 } |
| 172 |
141 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) | 173 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) |
142 { | 174 { |
143 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); | 175 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptForO
bjectId(objectId); |
144 if (!injectedScript.isEmpty()) | 176 if (!injectedScript.isEmpty()) |
145 injectedScript.releaseObject(objectId); | 177 injectedScript.releaseObject(objectId); |
146 } | 178 } |
147 | 179 |
148 void InspectorRuntimeAgent::releaseObjectGroup(ErrorString*, const String& objec
tGroup) | 180 void InspectorRuntimeAgent::releaseObjectGroup(ErrorString*, const String& objec
tGroup) |
149 { | 181 { |
150 m_injectedScriptManager->releaseObjectGroup(objectGroup); | 182 m_injectedScriptManager->releaseObjectGroup(objectGroup); |
151 } | 183 } |
152 | 184 |
153 void InspectorRuntimeAgent::run(ErrorString*) | 185 void InspectorRuntimeAgent::run(ErrorString*) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 .setIsPageContext(isPageContext) | 236 .setIsPageContext(isPageContext) |
205 .setName(name) | 237 .setName(name) |
206 .setFrameId(frameId) | 238 .setFrameId(frameId) |
207 .setLanguage(scriptState->isJavaScript() ? "JavaScript" : "Dart") | 239 .setLanguage(scriptState->isJavaScript() ? "JavaScript" : "Dart") |
208 .setLibraryId(scriptState->libraryId()) | 240 .setLibraryId(scriptState->libraryId()) |
209 .release()); | 241 .release()); |
210 } | 242 } |
211 | 243 |
212 } // namespace WebCore | 244 } // namespace WebCore |
213 | 245 |
OLD | NEW |