- Revision
- 255794
- Author
- [email protected]
- Date
- 2020-02-05 02:50:02 -0800 (Wed, 05 Feb 2020)
Log Message
Merge r255675 - Web Inspector: REGRESSION(r248287): Console: function objects saved to a $n will be invoked instead of just referenced when evaluating in the Console
https://bugs.webkit.org/show_bug.cgi?id=207180
<rdar://problem/58860268>
Reviewed by Joseph Pecoraro.
Source/_javascript_Core:
* inspector/InjectedScriptSource.js:
(CommandLineAPI):
Instead of deciding whether to wrap the value given for a `$n` getter based on if the value
is already a function, always wrap getter values in a function so that if the value being
stored in the getter is already a function, it isn't used as the callback for the getter and
therefore invoked when the getter is referenced.
LayoutTests:
* inspector/runtime/saveResult.html:
* inspector/runtime/saveResult-expected.txt:
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.28/LayoutTests/ChangeLog (255793 => 255794)
--- releases/WebKitGTK/webkit-2.28/LayoutTests/ChangeLog 2020-02-05 10:49:57 UTC (rev 255793)
+++ releases/WebKitGTK/webkit-2.28/LayoutTests/ChangeLog 2020-02-05 10:50:02 UTC (rev 255794)
@@ -1,3 +1,14 @@
+2020-02-04 Devin Rousso <[email protected]>
+
+ Web Inspector: REGRESSION(r248287): Console: function objects saved to a $n will be invoked instead of just referenced when evaluating in the Console
+ https://bugs.webkit.org/show_bug.cgi?id=207180
+ <rdar://problem/58860268>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/runtime/saveResult.html:
+ * inspector/runtime/saveResult-expected.txt:
+
2020-02-04 Antti Koivisto <[email protected]>
CSS Rules with the same selector from several large stylesheets are applied in the wrong order
Modified: releases/WebKitGTK/webkit-2.28/LayoutTests/inspector/runtime/saveResult-expected.txt (255793 => 255794)
--- releases/WebKitGTK/webkit-2.28/LayoutTests/inspector/runtime/saveResult-expected.txt 2020-02-05 10:49:57 UTC (rev 255793)
+++ releases/WebKitGTK/webkit-2.28/LayoutTests/inspector/runtime/saveResult-expected.txt 2020-02-05 10:50:02 UTC (rev 255794)
@@ -34,3 +34,10 @@
PASS: Evaluated result 990 should become $2.
PASS: Evaluated result 999 should match previous value $1.
+-- Running test case: SaveFunctionValue
+PASS: Function should become $3.
+PASS: Saved value should match previous value $3.
+PASS: Evaluated function should match previous value $3.
+PASS: Calling saved function should become $4.
+PASS: Calling saved function should return expected value.
+
Modified: releases/WebKitGTK/webkit-2.28/LayoutTests/inspector/runtime/saveResult.html (255793 => 255794)
--- releases/WebKitGTK/webkit-2.28/LayoutTests/inspector/runtime/saveResult.html 2020-02-05 10:49:57 UTC (rev 255793)
+++ releases/WebKitGTK/webkit-2.28/LayoutTests/inspector/runtime/saveResult.html 2020-02-05 10:50:02 UTC (rev 255794)
@@ -171,6 +171,31 @@
}
});
+ // ------
+
+ suite.addTestCase({
+ name: "SaveFunctionValue",
+ description: "Ensure that saving a function object doesn't evaluate the function object when fetching it via a $n getter.",
+ async test() {
+ const functionName = "testSaveFunctionValue";
+ const functionReturn = "testSaveFunctionValue Return Value";
+
+ let createFunctionEvaluateResult = await RuntimeAgent.evaluate.invoke({_expression_: `function ${functionName}() { return "${functionReturn}"; } ${functionName}`, objectGroup: "test", includeCommandLineAPI: true, saveResult: true});
+ InspectorTest.assert(!createFunctionEvaluateResult.error, "Should not be a protocol error.");
+ InspectorTest.expectEqual(createFunctionEvaluateResult.savedResultIndex, 3, "Function should become $3.");
+
+ let getSavedValueEvaluateResult = await RuntimeAgent.evaluate.invoke({_expression_: `$3`, objectGroup: "test", includeCommandLineAPI: true, saveResult: true});
+ InspectorTest.assert(!getSavedValueEvaluateResult.error, "Should not be a protocol error.");
+ InspectorTest.expectEqual(getSavedValueEvaluateResult.savedResultIndex, 3, "Saved value should match previous value $3.");
+ InspectorTest.expectEqual(createFunctionEvaluateResult.result.description, getSavedValueEvaluateResult.result.description, "Evaluated function should match previous value $3.");
+
+ let callFunctionEvaluateResult = await RuntimeAgent.evaluate.invoke({_expression_: functionName + "()", objectGroup: "test", includeCommandLineAPI: true, saveResult: true});
+ InspectorTest.assert(!callFunctionEvaluateResult.error, "Should not be a protocol error.");
+ InspectorTest.expectEqual(callFunctionEvaluateResult.savedResultIndex, 4, "Calling saved function should become $4.");
+ InspectorTest.expectEqual(callFunctionEvaluateResult.result.value, functionReturn, "Calling saved function should return expected value.");
+ }
+ });
+
suite.runTestCasesAndFinish();
}
</script>
Modified: releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/ChangeLog (255793 => 255794)
--- releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/ChangeLog 2020-02-05 10:49:57 UTC (rev 255793)
+++ releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/ChangeLog 2020-02-05 10:50:02 UTC (rev 255794)
@@ -1,3 +1,18 @@
+2020-02-04 Devin Rousso <[email protected]>
+
+ Web Inspector: REGRESSION(r248287): Console: function objects saved to a $n will be invoked instead of just referenced when evaluating in the Console
+ https://bugs.webkit.org/show_bug.cgi?id=207180
+ <rdar://problem/58860268>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/InjectedScriptSource.js:
+ (CommandLineAPI):
+ Instead of deciding whether to wrap the value given for a `$n` getter based on if the value
+ is already a function, always wrap getter values in a function so that if the value being
+ stored in the getter is already a function, it isn't used as the callback for the getter and
+ therefore invoked when the getter is referenced.
+
2020-02-03 Yusuke Suzuki <[email protected]>
[JSC] Use PackedPtr for VariableEnvironment
Modified: releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/inspector/InjectedScriptSource.js (255793 => 255794)
--- releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/inspector/InjectedScriptSource.js 2020-02-05 10:49:57 UTC (rev 255793)
+++ releases/WebKitGTK/webkit-2.28/Source/_javascript_Core/inspector/InjectedScriptSource.js 2020-02-05 10:50:02 UTC (rev 255794)
@@ -1466,8 +1466,8 @@
{
let savedResultAlias = InjectedScriptHost.savedResultAlias;
- let defineGetter = (key, value) => {
- if (typeof value !== "function") {
+ let defineGetter = (key, value, wrap) => {
+ if (wrap) {
let originalValue = value;
value = function() { return originalValue; };
}
@@ -1478,17 +1478,17 @@
};
if ("_lastResult" in injectedScript)
- defineGetter("_", injectedScript._lastResult);
+ defineGetter("_", injectedScript._lastResult, true);
if ("_exceptionValue" in injectedScript)
- defineGetter("exception", injectedScript._exceptionValue);
+ defineGetter("exception", injectedScript._exceptionValue, true);
if ("_eventValue" in injectedScript)
- defineGetter("event", injectedScript._eventValue);
+ defineGetter("event", injectedScript._eventValue, true);
// $1-$99
for (let i = 1; i < injectedScript._savedResults.length; ++i)
- defineGetter(i, injectedScript._savedResults[i]);
+ defineGetter(i, injectedScript._savedResults[i], true);
for (let name in CommandLineAPI.getters)
defineGetter(name, CommandLineAPI.getters[name]);