Diff
Modified: trunk/LayoutTests/ChangeLog (180714 => 180715)
--- trunk/LayoutTests/ChangeLog 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/LayoutTests/ChangeLog 2015-02-27 01:15:23 UTC (rev 180715)
@@ -1,3 +1,17 @@
+2015-02-26 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Save Console Evaluations into Command Line variables $1-$99 ($n)
+ https://bugs.webkit.org/show_bug.cgi?id=142061
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/debugger/command-line-api-exception-nested-catch.html:
+ * inspector/debugger/command-line-api-exception.html:
+ * inspector/model/remote-object-get-properties.html:
+ * inspector/model/remote-object-weak-collection.html:
+ * inspector/model/remote-object.html:
+ Update evaluateInInspectedWindow call sites for new parameter.
+
2015-02-26 Brent Fulgham <bfulg...@apple.com>
[Win] More Debug assertion updates.
Modified: trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html (180714 => 180715)
--- trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html 2015-02-27 01:15:23 UTC (rev 180715)
@@ -16,13 +16,13 @@
WebInspector.debuggerManager.allExceptionsBreakpoint.disabled = false;
function dumpCommandLineAPIValue(prefix) {
- WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", "test", true, true, false, false, function(result, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", "test", true, true, false, false, false, function(result, wasThrown) {
InspectorTest.log(prefix + ": $exception => " + result.description);
});
}
function checkIfExceptionValueMatchesVariable(varName) {
- WebInspector.runtimeManager.evaluateInInspectedWindow("$exception === " + varName, "test", true, true, false, false, function(result, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow("$exception === " + varName, "test", true, true, false, false, false, function(result, wasThrown) {
InspectorTest.log(" CATCH: $exception === " + varName + " ? " + result.description);
});
}
Modified: trunk/LayoutTests/inspector/debugger/command-line-api-exception.html (180714 => 180715)
--- trunk/LayoutTests/inspector/debugger/command-line-api-exception.html 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/LayoutTests/inspector/debugger/command-line-api-exception.html 2015-02-27 01:15:23 UTC (rev 180715)
@@ -40,13 +40,13 @@
}
function dumpCommandLineAPIValue(prefix) {
- WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", "test", true, true, false, false, function(result, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", "test", true, true, false, false, false, function(result, wasThrown) {
InspectorTest.log(prefix + ": $exception => " + result.description);
});
}
function checkIfExceptionValueMatchesCatchVariable() {
- WebInspector.runtimeManager.evaluateInInspectedWindow("$exception === e", "test", true, true, false, false, function(result, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow("$exception === e", "test", true, true, false, false, false, function(result, wasThrown) {
InspectorTest.log("STEPPED OUT TO CATCH BLOCK: $exception === e ? " + result.description);
});
}
Modified: trunk/LayoutTests/inspector/model/remote-object-get-properties.html (180714 => 180715)
--- trunk/LayoutTests/inspector/model/remote-object-get-properties.html 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/LayoutTests/inspector/model/remote-object-get-properties.html 2015-02-27 01:15:23 UTC (rev 180715)
@@ -73,7 +73,7 @@
InspectorTest.log("-----------------------------------------------------");
InspectorTest.log("_expression_: " + step._expression_);
- WebInspector.runtimeManager.evaluateInInspectedWindow(step._expression_, "test", false, true, false, false, function(remoteObject, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow(step._expression_, "test", false, true, false, false, false, function(remoteObject, wasThrown) {
InspectorTest.assert(remoteObject instanceof WebInspector.RemoteObject);
InspectorTest.log("type: " + remoteObject.type);
if (remoteObject.subtype)
Modified: trunk/LayoutTests/inspector/model/remote-object-weak-collection.html (180714 => 180715)
--- trunk/LayoutTests/inspector/model/remote-object-weak-collection.html 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/LayoutTests/inspector/model/remote-object-weak-collection.html 2015-02-27 01:15:23 UTC (rev 180715)
@@ -53,8 +53,8 @@
// Run the _expression_, and then run a garbage collection on a different
// event loop so no objects are kept alive by the stack.
- WebInspector.runtimeManager.evaluateInInspectedWindow(step._expression_, "test", false, true, false, true, function(remoteObject, wasThrown) {
- WebInspector.runtimeManager.evaluateInInspectedWindow("GCController.collect()", "test", false, true, false, false, function() {
+ WebInspector.runtimeManager.evaluateInInspectedWindow(step._expression_, "test", false, true, false, true, false, function(remoteObject, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow("GCController.collect()", "test", false, true, false, false, false, function() {
InspectorTest.assert(remoteObject instanceof WebInspector.RemoteObject);
remoteObject.getCollectionEntries(0, 100, function(entries) {
InspectorTest.log("ENTRIES:");
Modified: trunk/LayoutTests/inspector/model/remote-object.html (180714 => 180715)
--- trunk/LayoutTests/inspector/model/remote-object.html 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/LayoutTests/inspector/model/remote-object.html 2015-02-27 01:15:23 UTC (rev 180715)
@@ -176,7 +176,7 @@
InspectorTest.log("-----------------------------------------------------");
InspectorTest.log("_expression_: " + step._expression_);
- WebInspector.runtimeManager.evaluateInInspectedWindow(step._expression_, "test", false, true, false, true, function(remoteObject, wasThrown) {
+ WebInspector.runtimeManager.evaluateInInspectedWindow(step._expression_, "test", false, true, false, true, false, function(remoteObject, wasThrown) {
InspectorTest.assert(remoteObject instanceof WebInspector.RemoteObject);
InspectorTest.log(JSON.stringify(remoteObject, remoteObjectJSONFilter, " "));
runNextStep();
Modified: trunk/Source/_javascript_Core/ChangeLog (180714 => 180715)
--- trunk/Source/_javascript_Core/ChangeLog 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-02-27 01:15:23 UTC (rev 180715)
@@ -1,3 +1,36 @@
+2015-02-26 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Save Console Evaluations into Command Line variables $1-$99 ($n)
+ https://bugs.webkit.org/show_bug.cgi?id=142061
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/protocol/Debugger.json:
+ * inspector/protocol/Runtime.json:
+ Input flag "saveResult" on whether we should try to save a result.
+ Output int "savedResultIndex" to tell the frontend the saved state.
+
+ * inspector/InjectedScriptSource.js:
+ Handle saving and clearing $1-$99 values.
+ Include in BasicCommandLineAPI for JSContext inspection.
+
+ * inspector/InjectedScriptBase.cpp:
+ (Inspector::InjectedScriptBase::makeEvalCall):
+ * inspector/InjectedScriptBase.h:
+ Allow an optional "savedResultIndex" out value on evals.
+
+ * inspector/InjectedScript.cpp:
+ (Inspector::InjectedScript::evaluate):
+ (Inspector::InjectedScript::evaluateOnCallFrame):
+ * inspector/InjectedScript.h:
+ * inspector/agents/InspectorDebuggerAgent.cpp:
+ (Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
+ * inspector/agents/InspectorDebuggerAgent.h:
+ * inspector/agents/InspectorRuntimeAgent.cpp:
+ (Inspector::InspectorRuntimeAgent::evaluate):
+ * inspector/agents/InspectorRuntimeAgent.h:
+ Plumbing for new in and out parameters.
+
2015-02-26 Filip Pizlo <fpi...@apple.com>
The bool returning form of BytecodeGenerator::addVar() can be removed
Modified: trunk/Source/_javascript_Core/inspector/InjectedScript.cpp (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/InjectedScript.cpp 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/InjectedScript.cpp 2015-02-27 01:15:23 UTC (rev 180715)
@@ -56,7 +56,7 @@
{
}
-void InjectedScript::evaluate(ErrorString& errorString, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InjectedScript::evaluate(ErrorString& errorString, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluate"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(_expression_);
@@ -64,7 +64,8 @@
function.appendArgument(includeCommandLineAPI);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- makeEvalCall(errorString, function, result, wasThrown);
+ function.appendArgument(saveResult);
+ makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
}
void InjectedScript::callFunctionOn(ErrorString& errorString, const String& objectId, const String& _expression_, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown)
@@ -78,7 +79,7 @@
makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InjectedScript::evaluateOnCallFrame(ErrorString& errorString, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>* result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("evaluateOnCallFrame"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callFrames);
@@ -88,7 +89,8 @@
function.appendArgument(includeCommandLineAPI);
function.appendArgument(returnByValue);
function.appendArgument(generatePreview);
- makeEvalCall(errorString, function, result, wasThrown);
+ function.appendArgument(saveResult);
+ makeEvalCall(errorString, function, result, wasThrown, savedResultIndex);
}
void InjectedScript::getFunctionDetails(ErrorString& errorString, const String& functionId, RefPtr<Inspector::Protocol::Debugger::FunctionDetails>* result)
Modified: trunk/Source/_javascript_Core/inspector/InjectedScript.h (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/InjectedScript.h 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/InjectedScript.h 2015-02-27 01:15:23 UTC (rev 180715)
@@ -52,9 +52,9 @@
InjectedScript(Deprecated::ScriptObject, InspectorEnvironment*);
virtual ~InjectedScript();
- void evaluate(ErrorString&, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
+ void evaluate(ErrorString&, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex);
void callFunctionOn(ErrorString&, const String& objectId, const String& _expression_, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
- void evaluateOnCallFrame(ErrorString&, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
+ void evaluateOnCallFrame(ErrorString&, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex);
void getFunctionDetails(ErrorString&, const String& functionId, RefPtr<Protocol::Debugger::FunctionDetails>* result);
void getProperties(ErrorString&, const String& objectId, bool ownProperties, bool generatePreview, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
void getDisplayableProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp 2015-02-27 01:15:23 UTC (rev 180715)
@@ -112,7 +112,7 @@
*result = InspectorString::create("Exception while making a call.");
}
-void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>* objectResult, Protocol::OptOutput<bool>* wasThrown)
+void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>* objectResult, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResultIndex)
{
RefPtr<InspectorValue> result;
makeCall(function, &result);
@@ -127,26 +127,32 @@
return;
}
- RefPtr<InspectorObject> resultPair;
- if (!result->asObject(resultPair)) {
+ RefPtr<InspectorObject> resultTuple;
+ if (!result->asObject(resultTuple)) {
errorString = ASCIILiteral("Internal error: result is not an Object");
return;
}
RefPtr<InspectorObject> resultObject;
- if (!resultPair->getObject(ASCIILiteral("result"), resultObject)) {
+ if (!resultTuple->getObject(ASCIILiteral("result"), resultObject)) {
errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
return;
}
bool wasThrownValue = false;
- if (!resultPair->getBoolean(ASCIILiteral("wasThrown"), wasThrownValue)) {
+ if (!resultTuple->getBoolean(ASCIILiteral("wasThrown"), wasThrownValue)) {
errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
return;
}
*objectResult = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
*wasThrown = wasThrownValue;
+
+ if (savedResultIndex) {
+ int savedIndex = 0;
+ if (resultTuple->getInteger(ASCIILiteral("savedResultIndex"), savedIndex))
+ *savedResultIndex = savedIndex;
+ }
}
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptBase.h (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptBase.h 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptBase.h 2015-02-27 01:15:23 UTC (rev 180715)
@@ -66,7 +66,7 @@
const Deprecated::ScriptObject& injectedScriptObject() const;
Deprecated::ScriptValue callFunctionWithEvalEnabled(Deprecated::ScriptFunctionCall&, bool& hadException) const;
void makeCall(Deprecated::ScriptFunctionCall&, RefPtr<InspectorValue>* result);
- void makeEvalCall(ErrorString&, Deprecated::ScriptFunctionCall&, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
+ void makeEvalCall(ErrorString&, Deprecated::ScriptFunctionCall&, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResult = nullptr);
private:
String m_name;
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -58,6 +58,8 @@
this._idToObjectGroupName = {};
this._objectGroups = {};
this._modules = {};
+ this._nextSavedResultIndex = 1;
+ this._savedResults = [];
}
InjectedScript.primitiveTypes = {
@@ -174,13 +176,19 @@
releaseObjectGroup: function(objectGroupName)
{
- if (objectGroupName === "console")
+ if (objectGroupName === "console") {
delete this._lastResult;
+ this._nextSavedResultIndex = 1;
+ this._savedResults = [];
+ }
+
var group = this._objectGroups[objectGroupName];
if (!group)
return;
+
for (var i = 0; i < group.length; i++)
this._releaseObject(group[i]);
+
delete this._objectGroups[objectGroupName];
},
@@ -320,9 +328,9 @@
delete this._idToObjectGroupName[id];
},
- evaluate: function(_expression_, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
+ evaluate: function(_expression_, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, saveResult)
{
- return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, _expression_, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview);
+ return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, _expression_, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview, saveResult);
},
callFunctionOn: function(objectId, _expression_, args, returnByValue, generatePreview)
@@ -376,13 +384,20 @@
return undefined;
},
- _evaluateAndWrap: function(evalFunction, object, _expression_, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview)
+ _evaluateAndWrap: function(evalFunction, object, _expression_, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, saveResult)
{
try {
- return {
+ this._savedResultIndex = undefined;
+
+ var returnObject = {
wasThrown: false,
- result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue, generatePreview)
+ result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI, saveResult), objectGroup, returnByValue, generatePreview)
};
+
+ if (saveResult && this._savedResultIndex)
+ returnObject.savedResultIndex = this._savedResultIndex;
+
+ return returnObject;
} catch (e) {
return this._createThrownValue(e, objectGroup);
}
@@ -400,7 +415,7 @@
};
},
- _evaluateOn: function(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI)
+ _evaluateOn: function(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI, saveResult)
{
var commandLineAPI = null;
if (injectCommandLineAPI) {
@@ -445,8 +460,8 @@
var expressionFunction = evalFunction.call(object, boundExpressionFunctionString);
var result = expressionFunction.apply(null, parameters);
- if (objectGroup === "console")
- this._lastResult = result;
+ if (objectGroup === "console" && saveResult)
+ this._saveResult(result);
return result;
}
@@ -465,8 +480,8 @@
var result = evalFunction.call(inspectedGlobalObject, _expression_);
- if (objectGroup === "console")
- this._lastResult = result;
+ if (objectGroup === "console" && saveResult)
+ this._saveResult(result);
return result;
} finally {
@@ -493,12 +508,12 @@
return result;
},
- evaluateOnCallFrame: function(topCallFrame, callFrameId, _expression_, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
+ evaluateOnCallFrame: function(topCallFrame, callFrameId, _expression_, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, saveResult)
{
var callFrame = this._callFrameForId(topCallFrame, callFrameId);
if (!callFrame)
return "Could not find call frame with given id";
- return this._evaluateAndWrap(callFrame.evaluate, callFrame, _expression_, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview);
+ return this._evaluateAndWrap(callFrame.evaluate, callFrame, _expression_, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview, saveResult);
},
_callFrameForId: function(topCallFrame, callFrameId)
@@ -809,6 +824,32 @@
return this._getWeakMapEntries(object, numberToFetch);
throw "unexpected type";
+ },
+
+ _saveResult: function(result)
+ {
+ this._lastResult = result;
+
+ if (result === undefined || result === null)
+ return;
+
+ var existingIndex = this._savedResults.indexOf(result);
+ if (existingIndex !== -1) {
+ this._savedResultIndex = existingIndex;
+ return;
+ }
+
+ this._savedResultIndex = this._nextSavedResultIndex;
+ this._savedResults[this._nextSavedResultIndex++] = result;
+
+ // $n is limited from $1-$99. $0 is special.
+ if (this._nextSavedResultIndex >= 100)
+ this._nextSavedResultIndex = 1;
+ },
+
+ _savedResult: function(index)
+ {
+ return this._savedResults[index];
}
}
@@ -1117,10 +1158,35 @@
};
}
+
+function slice(array, index)
+{
+ var result = [];
+ for (var i = index || 0; i < array.length; ++i)
+ result.push(array[i]);
+ return result;
+}
+
+function bind(func, thisObject, var_args)
+{
+ var args = slice(arguments, 2);
+ return function(var_args) {
+ return func.apply(thisObject, args.concat(slice(arguments)));
+ }
+}
+
function BasicCommandLineAPI()
{
this.$_ = injectedScript._lastResult;
this.$exception = injectedScript._exceptionValue;
+
+ // $1-$99
+ for (var i = 1; i <= injectedScript._savedResults.length; ++i) {
+ var member = "$" + i;
+ if (member in inspectedGlobalObject)
+ continue;
+ this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i));
+ }
}
return injectedScript;
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2015-02-27 01:15:23 UTC (rev 180715)
@@ -551,7 +551,7 @@
errorString = ASCIILiteral("Internal error. Could not change pause on exceptions state");
}
-void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId);
if (injectedScript.hasNoValue()) {
@@ -566,7 +566,7 @@
muteConsole();
}
- injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, _expression_, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, &result, wasThrown);
+ injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, _expression_, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePreview ? *generatePreview : false, saveResult ? *saveResult : false, &result, wasThrown, savedResultIndex);
if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) {
unmuteConsole();
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h 2015-02-27 01:15:23 UTC (rev 180715)
@@ -84,7 +84,7 @@
virtual void stepInto(ErrorString&) override;
virtual void stepOut(ErrorString&) override;
virtual void setPauseOnExceptions(ErrorString&, const String& pauseState) override;
- virtual void evaluateOnCallFrame(ErrorString&, const String& callFrameId, const String& _expression_, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown) override;
+ virtual void evaluateOnCallFrame(ErrorString&, const String& callFrameId, const String& _expression_, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex) override;
virtual void setOverlayMessage(ErrorString&, const String*) override;
bool isPaused();
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2015-02-27 01:15:23 UTC (rev 180715)
@@ -114,7 +114,7 @@
}
}
-void InspectorRuntimeAgent::evaluate(ErrorString& errorString, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown)
+void InspectorRuntimeAgent::evaluate(ErrorString& errorString, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* const returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
{
InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
if (injectedScript.hasNoValue())
@@ -126,7 +126,7 @@
if (asBool(doNotPauseOnExceptionsAndMuteConsole))
muteConsole();
- injectedScript.evaluate(errorString, _expression_, objectGroup ? *objectGroup : String(), asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), &result, wasThrown);
+ injectedScript.evaluate(errorString, _expression_, objectGroup ? *objectGroup : String(), asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePreview), asBool(saveResult), &result, wasThrown, savedResultIndex);
if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
unmuteConsole();
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.h (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.h 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.h 2015-02-27 01:15:23 UTC (rev 180715)
@@ -60,7 +60,7 @@
virtual void enable(ErrorString&) override { m_enabled = true; }
virtual void disable(ErrorString&) override { m_enabled = false; }
virtual void parse(ErrorString&, const String& _expression_, Inspector::Protocol::Runtime::SyntaxErrorType* result, Inspector::Protocol::OptOutput<String>* message, RefPtr<Inspector::Protocol::Runtime::ErrorRange>&) override final;
- virtual void evaluate(ErrorString&, const String& _expression_, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown) override final;
+ virtual void evaluate(ErrorString&, const String& _expression_, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex) override final;
virtual void callFunctionOn(ErrorString&, const String& objectId, const String& _expression_, const RefPtr<Inspector::InspectorArray>&& optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown) override final;
virtual void releaseObject(ErrorString&, const ErrorString& objectId) override final;
virtual void getProperties(ErrorString&, const String& objectId, const bool* ownProperties, const bool* generatePreview, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
Modified: trunk/Source/_javascript_Core/inspector/protocol/Debugger.json (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/protocol/Debugger.json 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/protocol/Debugger.json 2015-02-27 01:15:23 UTC (rev 180715)
@@ -248,11 +248,13 @@
{ "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated _expression_, defaults to false." },
{ "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state." },
{ "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." },
- { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." }
+ { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." },
+ { "name": "saveResult", "type": "boolean", "optional": true, "description": "Whether the resulting value should be considered for saving in the $n history." }
],
"returns": [
{ "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." },
- { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }
+ { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." },
+ { "name": "savedResultIndex", "type": "integer", "optional": true, "description": "If the result was saved, this is the $n index that can be used to access the value." }
],
"description": "Evaluates _expression_ on a given call frame."
},
Modified: trunk/Source/_javascript_Core/inspector/protocol/Runtime.json (180714 => 180715)
--- trunk/Source/_javascript_Core/inspector/protocol/Runtime.json 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/_javascript_Core/inspector/protocol/Runtime.json 2015-02-27 01:15:23 UTC (rev 180715)
@@ -209,11 +209,13 @@
{ "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state." },
{ "name": "contextId", "$ref": "Runtime.ExecutionContextId", "optional": true, "description": "Specifies in which isolated context to perform evaluation. Each content script lives in an isolated context and this parameter may be used to specify one of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page." },
{ "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." },
- { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." }
+ { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." },
+ { "name": "saveResult", "type": "boolean", "optional": true, "description": "Whether the resulting value should be considered for saving in the $n history." }
],
"returns": [
{ "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },
- { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }
+ { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." },
+ { "name": "savedResultIndex", "type": "integer", "optional": true, "description": "If the result was saved, this is the $n index that can be used to access the value." }
],
"description": "Evaluates _expression_ on global object."
},
Modified: trunk/Source/WebCore/ChangeLog (180714 => 180715)
--- trunk/Source/WebCore/ChangeLog 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebCore/ChangeLog 2015-02-27 01:15:23 UTC (rev 180715)
@@ -1,3 +1,26 @@
+2015-02-26 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Save Console Evaluations into Command Line variables $1-$99 ($n)
+ https://bugs.webkit.org/show_bug.cgi?id=142061
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/CommandLineAPIModuleSource.js:
+ Replace $1-$4 "inspected objects" with $1-$99 "saved results".
+
+ * bindings/js/JSCommandLineAPIHostCustom.cpp:
+ (WebCore::JSCommandLineAPIHost::inspectedObject):
+ * inspector/CommandLineAPIHost.cpp:
+ (WebCore::CommandLineAPIHost::CommandLineAPIHost):
+ (WebCore::CommandLineAPIHost::InspectableObject::get):
+ (WebCore::CommandLineAPIHost::addInspectedObject):
+ (WebCore::CommandLineAPIHost::inspectedObject):
+ (WebCore::CommandLineAPIHost::clearInspectedObjects): Deleted.
+ * inspector/CommandLineAPIHost.h:
+ * inspector/CommandLineAPIHost.idl:
+ Since we now just save the single $0 inspected object, eliminate
+ keeping track of a list of 5 values.
+
2015-02-26 Gyuyoung Kim <gyuyoung....@samsung.com>
Remove unnecessary create() factory functions in CDMFoo, NamedNodeMap
Modified: trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp (180714 => 180715)
--- trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp 2015-02-27 01:15:23 UTC (rev 180715)
@@ -57,10 +57,7 @@
JSValue JSCommandLineAPIHost::inspectedObject(ExecState* exec)
{
- if (exec->argumentCount() < 1)
- return jsUndefined();
-
- CommandLineAPIHost::InspectableObject* object = impl().inspectedObject(exec->uncheckedArgument(0).toInt32(exec));
+ CommandLineAPIHost::InspectableObject* object = impl().inspectedObject();
if (!object)
return jsUndefined();
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (180714 => 180715)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2015-02-27 01:15:23 UTC (rev 180715)
@@ -67,7 +67,7 @@
, m_domStorageAgent(nullptr)
, m_databaseAgent(nullptr)
{
- m_defaultInspectableObject = std::make_unique<InspectableObject>();
+ m_inspectedObject = std::make_unique<InspectableObject>();
}
CommandLineAPIHost::~CommandLineAPIHost()
@@ -118,28 +118,18 @@
Deprecated::ScriptValue CommandLineAPIHost::InspectableObject::get(JSC::ExecState*)
{
return Deprecated::ScriptValue();
-};
+}
void CommandLineAPIHost::addInspectedObject(std::unique_ptr<CommandLineAPIHost::InspectableObject> object)
{
- m_inspectedObjects.insert(0, WTF::move(object));
- while (m_inspectedObjects.size() > 5)
- m_inspectedObjects.removeLast();
+ m_inspectedObject = WTF::move(object);
}
-void CommandLineAPIHost::clearInspectedObjects()
+CommandLineAPIHost::InspectableObject* CommandLineAPIHost::inspectedObject()
{
- m_inspectedObjects.clear();
+ return m_inspectedObject.get();
}
-CommandLineAPIHost::InspectableObject* CommandLineAPIHost::inspectedObject(unsigned index)
-{
- if (index >= m_inspectedObjects.size())
- return m_defaultInspectableObject.get();
-
- return m_inspectedObjects[index].get();
-}
-
String CommandLineAPIHost::databaseIdImpl(Database* database)
{
if (m_databaseAgent)
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.h (180714 => 180715)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2015-02-27 01:15:23 UTC (rev 180715)
@@ -89,8 +89,7 @@
virtual ~InspectableObject() { }
};
void addInspectedObject(std::unique_ptr<InspectableObject>);
- void clearInspectedObjects();
- InspectableObject* inspectedObject(unsigned index);
+ InspectableObject* inspectedObject();
void inspectImpl(RefPtr<Inspector::InspectorValue>&& objectToInspect, RefPtr<Inspector::InspectorValue>&& hints);
void getEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray);
@@ -107,8 +106,7 @@
InspectorDOMStorageAgent* m_domStorageAgent;
InspectorDatabaseAgent* m_databaseAgent;
- Vector<std::unique_ptr<InspectableObject>> m_inspectedObjects;
- std::unique_ptr<InspectableObject> m_defaultInspectableObject;
+ std::unique_ptr<InspectableObject> m_inspectedObject; // $0
};
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.idl (180714 => 180715)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.idl 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.idl 2015-02-27 01:15:23 UTC (rev 180715)
@@ -37,7 +37,7 @@
void clearConsoleMessages();
void copyText(DOMString text);
[Custom] void inspect(any objectId, any hints);
- [Custom] any inspectedObject(int num);
+ [Custom] any inspectedObject();
[Custom] Array getEventListeners(Node node);
[Custom] DOMString databaseId(any database);
[Custom] DOMString storageId(any storage);
Modified: trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js (180714 => 180715)
--- trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -115,12 +115,16 @@
this[member].toString = customToStringMethod(member);
}
- for (var i = 0; i < 5; ++i) {
+ // $0
+ this.__defineGetter__("$0", bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl));
+
+ // $1-$99
+ for (var i = 1; i <= injectedScript._savedResults.length; ++i) {
var member = "$" + i;
if (member in inspectedWindow || inScopeVariables(member))
continue;
- this.__defineGetter__("$" + i, bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i));
+ this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i));
}
this.$_ = injectedScript._lastResult;
@@ -305,12 +309,9 @@
return CommandLineAPIHost.getEventListeners(node);
},
- /**
- * @param {number} num
- */
- _inspectedObject: function(num)
+ _inspectedObject: function()
{
- return CommandLineAPIHost.inspectedObject(num);
+ return CommandLineAPIHost.inspectedObject();
},
/**
Modified: trunk/Source/WebInspectorUI/ChangeLog (180714 => 180715)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-02-27 01:15:23 UTC (rev 180715)
@@ -1,5 +1,50 @@
2015-02-26 Joseph Pecoraro <pecor...@apple.com>
+ Web Inspector: Save Console Evaluations into Command Line variables $1-$99 ($n)
+ https://bugs.webkit.org/show_bug.cgi?id=142061
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Controllers/RuntimeManager.js:
+ (WebInspector.RuntimeManager.prototype.evalCallback):
+ (WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow):
+ Add a saveResult parameter for the new protocol command in parameter.
+
+ * UserInterface/Views/ConsoleMessageImpl.js:
+ (WebInspector.ConsoleMessageImpl.prototype._formatMessage):
+ (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsObject):
+ (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsArray):
+ (WebInspector.ConsoleMessageImpl.prototype._rootPropertyPathForObject):
+ * UserInterface/Views/ObjectTreeView.js:
+ (WebInspector.ObjectTreeView.prototype.appendTitleSuffix):
+ For console evaluation results, show a "= $n" when the evaluation was
+ given a saved result index.
+
+ * UserInterface/Views/LogContentView.css:
+ (.console-saved-variable):
+ * UserInterface/Views/ObjectPreviewView.css:
+ (.object-preview-name):
+ Make $n and class names in previews always non-italics.
+
+ * UserInterface/Controllers/_javascript_LogViewController.js:
+ (WebInspector._javascript_LogViewController.prototype.printResult):
+ (WebInspector._javascript_LogViewController.prototype.consolePromptTextCommitted):
+ * UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js:
+ (get WebInspector._javascript_RuntimeCompletionProvider.prototype.):
+ * UserInterface/Controllers/LogManager.js:
+ (WebInspector.LogManager.prototype.messagesCleared):
+ (WebInspector.LogManager.prototype._mainResourceDidChange):
+ Try to provide better autocompletion for $n, by populating autocompletion menus
+ from $1-$n where n is the maximum saved result index seen. Clear the maximum
+ when we clear the console.
+
+ * UserInterface/Views/ConsoleCommandResult.js:
+ (WebInspector.ConsoleCommandResult):
+ (WebInspector.ConsoleCommandResult.clearMaximumSavedResultIndex):
+ Keep track of the maximum savedResultIndex for console evaluation results.
+
+2015-02-26 Joseph Pecoraro <pecor...@apple.com>
+
Web Inspector: Set/Map appear as lossless when they have lossy entries
https://bugs.webkit.org/show_bug.cgi?id=142050
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_LogViewController.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_LogViewController.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_LogViewController.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -222,17 +222,17 @@
var commandMessage = new WebInspector.ConsoleCommand(text);
this._appendConsoleMessage(commandMessage, true);
- function printResult(result, wasThrown)
+ function printResult(result, wasThrown, savedResultIndex)
{
if (!result || this._cleared)
return;
- this._appendConsoleMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, commandMessage), true);
+ this._appendConsoleMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, commandMessage, savedResultIndex), true);
}
text += "\n//# sourceURL=__WebInspectorConsole__\n";
- WebInspector.runtimeManager.evaluateInInspectedWindow(text, "console", true, false, false, true, printResult.bind(this));
+ WebInspector.runtimeManager.evaluateInInspectedWindow(text, "console", true, false, false, true, true, printResult.bind(this));
},
// Private
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -104,7 +104,7 @@
if (!base && activeCallFrame && !this._alwaysEvaluateInWindowContext)
activeCallFrame.collectScopeChainVariableNames(receivedPropertyNames.bind(this));
else
- WebInspector.runtimeManager.evaluateInInspectedWindow(base, "completion", true, true, false, false, evaluated.bind(this));
+ WebInspector.runtimeManager.evaluateInInspectedWindow(base, "completion", true, true, false, false, false, evaluated.bind(this));
function updateLastPropertyNames(propertyNames)
{
@@ -155,7 +155,7 @@
if (result.type === "object" || result.type === "function")
result.callFunctionJSON(getCompletions, undefined, receivedPropertyNames.bind(this));
else if (result.type === "string" || result.type === "number" || result.type === "boolean")
- WebInspector.runtimeManager.evaluateInInspectedWindow("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, false, receivedPropertyNamesFromEvaluate.bind(this));
+ WebInspector.runtimeManager.evaluateInInspectedWindow("(" + getCompletions + ")(\"" + result.type + "\")", "completion", false, true, true, false, false, receivedPropertyNamesFromEvaluate.bind(this));
else
console.error("Unknown result type: " + result.type);
}
@@ -174,11 +174,15 @@
RuntimeAgent.releaseObjectGroup("completion");
if (!base) {
- var commandLineAPI = ["$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventListeners", "$0", "$1", "$2", "$3", "$4", "$_"];
+ var commandLineAPI = ["$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventListeners", "$0", "$_"];
if (WebInspector.debuggerManager.paused && WebInspector.debuggerManager.pauseReason === WebInspector.DebuggerManager.PauseReason.Exception)
commandLineAPI.push("$exception");
for (var i = 0; i < commandLineAPI.length; ++i)
propertyNames[commandLineAPI[i]] = true;
+
+ // FIXME: Due to caching, sometimes old $n values show up as completion results even though they are not available. We should clear that proactively.
+ for (var i = 1; i <= WebInspector.ConsoleCommandResult.maximumSavedResultIndex; ++i)
+ propertyNames["$" + i] = true;
}
propertyNames = Object.keys(propertyNames);
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/LogManager.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/LogManager.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/LogManager.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -59,6 +59,8 @@
{
// Called from WebInspector.ConsoleObserver.
+ WebInspector.ConsoleCommandResult.clearMaximumSavedResultIndex();
+
// We don't want to clear messages on reloads. We can't determine that easily right now.
// FIXME: <rdar://problem/13767079> Console.messagesCleared should include a reason
this._shouldClearMessages = true;
@@ -97,6 +99,8 @@
else
this.dispatchEventToListeners(WebInspector.LogManager.Event.SessionStarted);
+ WebInspector.ConsoleCommandResult.clearMaximumSavedResultIndex();
+
delete this._shouldClearMessages;
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -41,14 +41,14 @@
// Public
- evaluateInInspectedWindow: function(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, callback)
+ evaluateInInspectedWindow: function(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult, callback)
{
if (!_expression_) {
// There is no _expression_, so the completion should happen against global properties.
_expression_ = "this";
}
- function evalCallback(error, result, wasThrown)
+ function evalCallback(error, result, wasThrown, savedResultIndex)
{
this.dispatchEventToListeners(WebInspector.RuntimeManager.Event.DidEvaluate);
@@ -59,22 +59,24 @@
}
if (returnByValue)
- callback(null, wasThrown, wasThrown ? null : result);
+ callback(null, wasThrown, wasThrown ? null : result, savedResultIndex);
else
- callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
+ callback(WebInspector.RemoteObject.fromPayload(result), wasThrown, savedResultIndex);
}
if (WebInspector.debuggerManager.activeCallFrame) {
// COMPATIBILITY (iOS 6): "generatePreview" did not exist.
- DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WebInspector.debuggerManager.activeCallFrame.id, _expression_: _expression_, objectGroup: objectGroup, includeCommandLineAPI: includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole: doNotPauseOnExceptionsAndMuteConsole, returnByValue: returnByValue, generatePreview: generatePreview}, evalCallback.bind(this));
+ // COMPATIBILITY (iOS 8): "saveResult" did not exist.
+ DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WebInspector.debuggerManager.activeCallFrame.id, _expression_: _expression_, objectGroup: objectGroup, includeCommandLineAPI: includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole: doNotPauseOnExceptionsAndMuteConsole, returnByValue: returnByValue, generatePreview: generatePreview, saveResult: saveResult}, evalCallback.bind(this));
return;
}
// COMPATIBILITY (iOS 6): Execution context identifiers (contextId) did not exist
// in iOS 6. Fallback to including the frame identifier (frameId).
// COMPATIBILITY (iOS 6): "generatePreview" did not exist.
+ // COMPATIBILITY (iOS 8): "saveResult" did not exist.
var contextId = WebInspector.quickConsole.executionContextIdentifier;
- RuntimeAgent.evaluate.invoke({_expression_: _expression_, objectGroup: objectGroup, includeCommandLineAPI: includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole: doNotPauseOnExceptionsAndMuteConsole, contextId: contextId, frameId: contextId, returnByValue: returnByValue, generatePreview: generatePreview}, evalCallback.bind(this));
+ RuntimeAgent.evaluate.invoke({_expression_: _expression_, objectGroup: objectGroup, includeCommandLineAPI: includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole: doNotPauseOnExceptionsAndMuteConsole, contextId: contextId, frameId: contextId, returnByValue: returnByValue, generatePreview: generatePreview, saveResult: saveResult}, evalCallback.bind(this));
},
getPropertiesForRemoteObject: function(objectId, callback)
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2015-02-27 01:15:23 UTC (rev 180715)
@@ -27,7 +27,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--
- These resouces should match the order and groups used in Main.html.
+ These resources should match the order and groups used in Main.html.
-->
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandResult.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandResult.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleCommandResult.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -27,14 +27,25 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingCommand)
+WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingCommand, savedResultIndex)
{
var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
this.originatingCommand = originatingCommand;
+ this.savedResultIndex = savedResultIndex;
+ if (this.savedResultIndex && this.savedResultIndex > WebInspector.ConsoleCommandResult.maximumSavedResultIndex)
+ WebInspector.ConsoleCommandResult.maximumSavedResultIndex = this.savedResultIndex;
+
WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.MessageSource.JS, level, "", null, WebInspector.ConsoleMessage.MessageType.Result, undefined, undefined, undefined, undefined, [result]);
};
+WebInspector.ConsoleCommandResult.maximumSavedResultIndex = 0;
+
+WebInspector.ConsoleCommandResult.clearMaximumSavedResultIndex = function()
+{
+ WebInspector.ConsoleCommandResult.maximumSavedResultIndex = 0;
+}
+
WebInspector.ConsoleCommandResult.prototype = {
constructor: WebInspector.ConsoleCommandResult,
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -125,6 +125,16 @@
this._formattedMessage.appendChild(messageText);
+ if (this.savedResultIndex) {
+ var savedVariableElement = document.createElement("span");
+ savedVariableElement.className = "console-saved-variable";
+ savedVariableElement.textContent = " = $" + this.savedResultIndex;
+ if (this._objectTree)
+ this._objectTree.appendTitleSuffix(savedVariableElement);
+ else
+ this._formattedMessage.appendChild(savedVariableElement);
+ }
+
if (this._shouldDumpStackTrace()) {
var ol = document.createElement("ol");
ol.className = "outline-disclosure";
@@ -296,9 +306,8 @@
_formatParameterAsObject: function(obj, elem, forceExpansion)
{
- // FIXME: Intialize component with "$n" instead of "obj". Or, an existing property path.
- var objectTree = new WebInspector.ObjectTreeView(obj, WebInspector.ObjectTreeView.Mode.Properties, null, forceExpansion);
- elem.appendChild(objectTree.element);
+ this._objectTree = new WebInspector.ObjectTreeView(obj, WebInspector.ObjectTreeView.Mode.Properties, this._rootPropertyPathForObject(obj), forceExpansion);
+ elem.appendChild(this._objectTree.element);
},
_formatParameterAsString: function(output, elem)
@@ -315,11 +324,18 @@
_formatParameterAsArray: function(arr, elem)
{
- // FIXME: Intialize component with "$n" instead of "obj". Or, an existing property path.
- var objectTree = new WebInspector.ObjectTreeView(arr, WebInspector.ObjectTreeView.Mode.Properties);
- elem.appendChild(objectTree.element);
+ this._objectTree = new WebInspector.ObjectTreeView(arr, WebInspector.ObjectTreeView.Mode.Properties, this._rootPropertyPathForObject(arr));
+ elem.appendChild(this._objectTree.element);
},
+ _rootPropertyPathForObject: function(object)
+ {
+ if (!this.savedResultIndex)
+ return null;
+
+ return new WebInspector.PropertyPath(object, "$" + this.savedResultIndex);
+ },
+
_userProvidedColumnNames: function(columnNamesArgument)
{
if (!columnNamesArgument)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css 2015-02-27 01:15:23 UTC (rev 180715)
@@ -223,6 +223,11 @@
color: rgb(0, 128, 255);
}
+.console-saved-variable {
+ font-style: normal;
+ color: hsl(0, 0%, 67%);
+}
+
.console-messages a {
color: rgb(33%, 33%, 33%);
cursor: pointer;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.css (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.css 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.css 2015-02-27 01:15:23 UTC (rev 180715)
@@ -29,6 +29,7 @@
font-size: 11px;
}
+.object-preview-name,
.object-preview.lossless {
font-style: normal;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js (180714 => 180715)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js 2015-02-27 01:15:17 UTC (rev 180714)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js 2015-02-27 01:15:23 UTC (rev 180715)
@@ -32,7 +32,7 @@
this._object = object;
this._mode = mode || WebInspector.ObjectTreeView.Mode.Properties;
- this._propertyPath = propertyPath || new WebInspector.PropertyPath(this._object, "obj");
+ this._propertyPath = propertyPath || new WebInspector.PropertyPath(this._object, "this");
this._expanded = false;
this._hasLosslessPreview = false;
@@ -186,6 +186,14 @@
this._untrackWeakEntries();
},
+ appendTitleSuffix: function(suffixElement)
+ {
+ if (this._previewView)
+ this._previewView.element.appendChild(suffixElement);
+ else
+ this._titleElement.appendChild(suffixElement);
+ },
+
// Protected
update: function()