<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[193204] branches/safari-601-branch</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/193204">193204</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 10:57:27 -0800 (Thu, 03 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/189415">r189415</a>. rdar://problem/23221163</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsChangeLog">branches/safari-601-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreChangeLog">branches/safari-601-branch/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreinspectorInjectedScriptSourcejs">branches/safari-601-branch/Source/JavaScriptCore/inspector/InjectedScriptSource.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIChangeLog">branches/safari-601-branch/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceProtocolInspectorBackendjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>branches/safari-601-branch/LayoutTests/inspector/runtime/</li>
<li><a href="#branchessafari601branchLayoutTestsinspectorruntimeparsehtml">branches/safari-601-branch/LayoutTests/inspector/runtime/parse.html</a></li>
<li><a href="#branchessafari601branchLayoutTestsinspectorruntimesaveResultexpectedtxt">branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult-expected.txt</a></li>
<li><a href="#branchessafari601branchLayoutTestsinspectorruntimesaveResulthtml">branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193203 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/ChangeLog        2015-12-03 18:57:20 UTC (rev 193203)
+++ branches/safari-601-branch/LayoutTests/ChangeLog        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2015-12-02 Timothy Hatcher <timothy@apple.com>
</span><span class="cx">
</span><ins>+ Merge r189415. rdar://problem/23221163
+
+ 2015-09-04 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Test Runtime.saveResult and $n values
+ https://bugs.webkit.org/show_bug.cgi?id=148837
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/runtime/parse.html: Remove unncessary debug flag.
+ * inspector/runtime/saveResult-expected.txt: Added.
+ * inspector/runtime/saveResult.html: Added.
+
+2015-12-02 Timothy Hatcher <timothy@apple.com>
+
</ins><span class="cx"> Merge r189373. rdar://problem/23221163
</span><span class="cx">
</span><span class="cx"> 2015-09-04 Joseph Pecoraro <pecoraro@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectorruntimeparsehtml"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/runtime/parse.html (0 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/inspector/runtime/parse.html         (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/runtime/parse.html        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -0,0 +1,190 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+ function outputErrorSourceRange(range) {
+ var str = " ".repeat("Source: ".length);
+ str += " ".repeat(range.startOffset);
+ str += "^";
+ str += "~".repeat(range.endOffset - range.startOffset - 1);
+ InspectorTest.log(str);
+ }
+
+ let suite = InspectorTest.createAsyncSuite("Runtime.parse");
+
+ suite.addTestCase({
+ name: "SyntaxErrorType.None",
+ description: "Test source without an issue.",
+ test: (resolve, reject) => {
+ function testSource(source) {
+ RuntimeAgent.parse(source, (error, result, message, range) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(result === RuntimeAgent.SyntaxErrorType.None, "Should be SyntaxErrorType None.");
+ InspectorTest.log("Source: " + source);
+ InspectorTest.assert(!message);
+ InspectorTest.assert(!range);
+ InspectorTest.log("");
+ });
+ }
+
+ // Complete programs without syntax errors (could have runtime errors).
+ testSource("");
+ testSource(";");
+ testSource("myVariable");
+ testSource("var x = 1; x");
+ testSource("[1,2,3]");
+ testSource("({})");
+ testSource("({prop:true}).x.x.x");
+ testSource("if(1)1");
+ InspectorBackend.runAfterPendingDispatches(resolve);
+ }
+ });
+
+ suite.addTestCase({
+ name: "SyntaxErrorType.UnterminatedLiteral",
+ description: "Test source with an unterminated literal.",
+ test: (resolve, reject) => {
+ function testSource(source) {
+ RuntimeAgent.parse(source, (error, result, message, range) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(result === RuntimeAgent.SyntaxErrorType.UnterminatedLiteral, "Should be SyntaxErrorType UnterminatedLiteral.");
+ InspectorTest.log("Source: " + source);
+ outputErrorSourceRange(range);
+ InspectorTest.log("Error Message: " + message);
+ InspectorTest.log("Range: " + JSON.stringify(range));
+ InspectorTest.log("");
+ });
+ }
+
+ // A literal that is not yet complete, but would be a single token.
+ testSource("0b"); // binary
+ testSource("0o"); // octal
+ testSource("0x"); // hex
+ testSource("1e"); // scientific notation number
+ testSource("'"); // string
+ testSource("\""); // string
+ testSource("var \\u007"); // identifier unicode escape
+ // testSource("/r"); // regexp - Not detected by JavaScriptCore.
+ InspectorBackend.runAfterPendingDispatches(resolve);
+ }
+ });
+
+ suite.addTestCase({
+ name: "SyntaxErrorType.Recoverable",
+ description: "Test source with a recoverable error.",
+ test: (resolve, reject) => {
+ function testSource(source) {
+ RuntimeAgent.parse(source, (error, result, message, range) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(result === RuntimeAgent.SyntaxErrorType.Recoverable, "Should be SyntaxErrorType Recoverable.");
+ InspectorTest.log("Source: " + source);
+ outputErrorSourceRange(range);
+ InspectorTest.log("Error Message: " + message);
+ InspectorTest.log("Error Range: " + JSON.stringify(range));
+ InspectorTest.log("");
+ });
+ }
+
+ // Not yet a syntax error, just an incomplete program.
+ testSource("(");
+ testSource("{");
+ testSource("!");
+ testSource("-"); // unary
+ testSource("+"); // unary
+ testSource("~"); // unary
+ testSource("1,");
+ testSource("var");
+ testSource("'use strict'; let"); // When not in strict mode, let is treated as the start of an identifier, not a keyword!
+ testSource("const");
+ testSource("var {x"); // destructuring
+ testSource("var [x"); // destructuring
+ testSource("var x,");
+ testSource("if(1)");
+ testSource("if(1){");
+ testSource("if(1){}else");
+ testSource("if(1){}else{");
+ testSource("while(1)");
+ testSource("while(1){");
+ testSource("for(;;)");
+ testSource("for(;;){");
+ testSource("()=>"); // arrow function
+ testSource("()=>{"); // arrow function
+ testSource("/*"); // comment
+ testSource("`"); // template string
+ testSource("`${1}"); // template string
+ testSource("`${"); // template string
+ testSource("function");
+ testSource("function foo");
+ testSource("function foo(");
+ testSource("function foo(){");
+ testSource("(function() {");
+ testSource("(function() {}");
+ testSource("(function() {})(");
+ testSource("switch(x)");
+ testSource("switch(x){");
+ testSource("switch(x){case");
+ testSource("switch(x){case 1");
+ testSource("switch(x){case 1:");
+ testSource("class");
+ testSource("class Klass");
+ testSource("class Klass {");
+ testSource("var x = {");
+ testSource("var x = {prop");
+ testSource("var x = {prop:");
+ testSource("var x = {prop:123");
+ testSource("var x = {prop:123 ");
+ testSource("var x = {prop:123,");
+ testSource("var x = {prop:123, ");
+ testSource("var x = {prop:123, 'prop2'");
+ testSource("var x = {prop:123, [12");
+ testSource("var x = {prop:123, [12]");
+ testSource("var x = {prop:123, [12]:");
+ testSource("var x = {prop:123, [12]:567");
+ testSource("var x = [");
+ testSource("var x = [1");
+ testSource("var x = [1,");
+ testSource("var x = [1,[]");
+ testSource("var x = [1,{}");
+ InspectorBackend.runAfterPendingDispatches(resolve);
+ }
+ });
+
+ suite.addTestCase({
+ name: "SyntaxErrorType.Irrecoverable",
+ description: "Test source with an irrecoverable issue.",
+ test: (resolve, reject) => {
+ function testSource(source) {
+ RuntimeAgent.parse(source, (error, result, message, range) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(result === RuntimeAgent.SyntaxErrorType.Irrecoverable, "Should be SyntaxErrorType Irrecoverable.");
+ InspectorTest.log("Source: " + source);
+ outputErrorSourceRange(range);
+ InspectorTest.log("Error Message: " + message);
+ InspectorTest.log("Error Range: " + JSON.stringify(range));
+ InspectorTest.log("");
+ });
+ }
+
+ // SyntaxErrors. Any typing after the syntax error is detected does not matter.
+ testSource("1$");
+ testSource("var x = {}}");
+ testSource("({}))");
+ testSource("var x = =");
+ testSource("const x;");
+ testSource("let x = 1; let x = 2;");
+ testSource("if x(1)");
+ InspectorBackend.runAfterPendingDispatches(resolve);
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for the Runtime.parse command.</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectorruntimesaveResultexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult-expected.txt (0 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult-expected.txt         (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult-expected.txt        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+Tests for the Runtime.saveResult command ($n values).
+
+
+== Running test suite: Runtime.saveResult
+-- Running test case: SavePrimitiveValue1
+PASS: Value 123 should become $1.
+
+-- Running test case: SavePrimitiveValue2
+PASS: Value true should become $2.
+
+-- Running test case: RepeatPrimitiveValue1
+PASS: Value 123 should have existed as $1.
+
+-- Running test case: $1MatchesValue1
+PASS: $1 value should be 123.
+
+-- Running test case: SaveObject1
+PASS: New Object {"x":100,"y":200} should become $3.
+
+-- Running test case: SaveObject2
+PASS: New Object {"x":100,"y":200} should become $4.
+
+-- Running test case: RepeatSaveObject1
+PASS: Repeat Object should have existed as $3.
+
+-- Running test case: NoContextWithPrimitiveShouldUseMainContext
+PASS: Value 999 should become $5.
+PASS: Value 999 should have existed as $5.
+
+-- Running test case: ClearConsoleShouldResetValues
+PASS: Value 999 should become $1.
+
+-- Running test case: EvaluateWithSaveIndex
+PASS: Evaluated result 990 should become $2.
+PASS: Evaluated result 999 should match previous value $1.
+
</ins></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectorruntimesaveResulthtml"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult.html (0 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult.html         (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/runtime/saveResult.html        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -0,0 +1,181 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+ function createCallArgumentWithValue(value) {
+ return {value};
+ }
+
+ function createCallArgumentWithRemoteObject(remoteObject) {
+ return {objectId: remoteObject.objectId};
+ }
+
+ function remoteObjectForSimpleObject(simpleObject, callback) {
+ InspectorTest.evaluateInPage("(" + JSON.stringify(simpleObject) + ")", callback);
+ }
+
+ let contextId = WebInspector.frameResourceManager.mainFrame.pageExecutionContext.id;
+ let remoteObject1;
+
+ let suite = InspectorTest.createAsyncSuite("Runtime.saveResult");
+
+ suite.addTestCase({
+ name: "SavePrimitiveValue1",
+ description: "Saving a new value should produce a new $n value.",
+ test: (resolve, reject) => {
+ let value = 123;
+ RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 1, `Value ${value} should become $1.`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SavePrimitiveValue2",
+ description: "Saving a new value should produce a new $n value.",
+ test: (resolve, reject) => {
+ let value = true;
+ RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 2, `Value ${value} should become $2.`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "RepeatPrimitiveValue1",
+ description: "Saving a previously saved value should produce the original $n value.",
+ test: (resolve, reject) => {
+ let value = 123;
+ RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 1, `Value ${value} should have existed as $1.`);
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "$1MatchesValue1",
+ description: "Evaluating $1 should get us the value we saved previously.",
+ test: (resolve, reject) => {
+ RuntimeAgent.evaluate.invoke({expression: "$1", objectGroup: "test", includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
+ InspectorTest.assert(remoteObject.hasValue(), "RemoteObject for $1 should be a value, not an object.");
+ InspectorTest.expectThat(remoteObject.value === 123, "$1 value should be 123.");
+ resolve();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SaveObject1",
+ description: "Saving a new object should produce a new $n value.",
+ test: (resolve, reject) => {
+ let object = {x:100, y:200};
+ remoteObjectForSimpleObject(object, (error, remoteObject) => {
+ remoteObject1 = remoteObject;
+ RuntimeAgent.saveResult(createCallArgumentWithRemoteObject(remoteObject), (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 3, `New Object ${JSON.stringify(object)} should become $3.`);
+ resolve();
+ });
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "SaveObject2",
+ description: "Saving a new object should produce a new $n value.",
+ test: (resolve, reject) => {
+ let object = {x:100, y:200};
+ remoteObjectForSimpleObject(object, (error, remoteObject) => {
+ RuntimeAgent.saveResult(createCallArgumentWithRemoteObject(remoteObject), (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 4, `New Object ${JSON.stringify(object)} should become $4.`);
+ resolve();
+ });
+ });
+ }
+ });
+
+ suite.addTestCase({
+ name: "RepeatSaveObject1",
+ description: "Saving a previously saved value should produce the original $n value.",
+ test: (resolve, reject) => {
+ RuntimeAgent.saveResult(createCallArgumentWithRemoteObject(remoteObject1), (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 3, `Repeat Object should have existed as $3.`);
+ resolve();
+ });
+ }
+ });
+
+ // ------
+
+ suite.addTestCase({
+ name: "NoContextWithPrimitiveShouldUseMainContext",
+ description: "Saving a primitive should specify the context.",
+ test: (resolve, reject) => {
+ let value = 999;
+ RuntimeAgent.saveResult(createCallArgumentWithValue(value), (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 5, `Value ${value} should become $5.`);
+ });
+ RuntimeAgent.saveResult(createCallArgumentWithValue(value), contextId, (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 5, `Value ${value} should have existed as $5.`);
+ resolve();
+ });
+ }
+ });
+
+ // ------
+
+ suite.addTestCase({
+ name: "ClearConsoleShouldResetValues",
+ description: "Clearing the console should reset the $n values.",
+ test: (resolve, reject) => {
+ let value = 999;
+ ConsoleAgent.clearMessages();
+ RuntimeAgent.saveResult(createCallArgumentWithValue(value), (error, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 1, `Value ${value} should become $1.`);
+ resolve();
+ });
+ }
+ });
+
+ // ------
+
+ suite.addTestCase({
+ name: "EvaluateWithSaveIndex",
+ description: "Evalute with the saveIndex option should affect $n.",
+ test: (resolve, reject) => {
+ RuntimeAgent.evaluate.invoke({expression: "900 + 90", objectGroup: "test", includeCommandLineAPI: true, saveResult: true}, (error, remoteObjectPayload, wasThrown, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 2, "Evaluated result 990 should become $2.");
+ });
+ RuntimeAgent.evaluate.invoke({expression: "$2 + 9", objectGroup: "test", includeCommandLineAPI: true, saveResult: true}, (error, remoteObjectPayload, wasThrown, savedResultIndex) => {
+ InspectorTest.assert(!error, "Should not be a protocol error.");
+ InspectorTest.expectThat(savedResultIndex === 1, "Evaluated result 999 should match previous value $1.");
+ resolve();
+ });
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for the Runtime.saveResult command ($n values).</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/ChangeLog (193203 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/ChangeLog        2015-12-03 18:57:20 UTC (rev 193203)
+++ branches/safari-601-branch/Source/JavaScriptCore/ChangeLog        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2015-12-02 Timothy Hatcher <timothy@apple.com>
</span><span class="cx">
</span><ins>+ Merge r189415. rdar://problem/23221163
+
+ 2015-09-04 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Test Runtime.saveResult and $n values
+ https://bugs.webkit.org/show_bug.cgi?id=148837
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/InjectedScriptSource.js:
+ (InjectedScript.prototype._evaluateOn):
+ We don't need to be in the console object group to put the value
+ in the saved results list. That strong reference will ensure $n
+ values are always alive even if other object groups were used
+ when creating and subsequently released.
+
+2015-12-02 Timothy Hatcher <timothy@apple.com>
+
</ins><span class="cx"> Merge r189373. rdar://problem/23221163
</span><span class="cx">
</span><span class="cx"> 2015-09-04 Joseph Pecoraro <pecoraro@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreinspectorInjectedScriptSourcejs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/inspector/InjectedScriptSource.js (193203 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2015-12-03 18:57:20 UTC (rev 193203)
+++ branches/safari-601-branch/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -487,7 +487,7 @@
</span><span class="cx"> var expressionFunction = evalFunction.call(object, boundExpressionFunctionString);
</span><span class="cx"> var result = expressionFunction.apply(null, parameters);
</span><span class="cx">
</span><del>- if (objectGroup === "console" && saveResult)
</del><ins>+ if (saveResult)
</ins><span class="cx"> this._saveResult(result);
</span><span class="cx">
</span><span class="cx"> return result;
</span><span class="lines">@@ -507,7 +507,7 @@
</span><span class="cx">
</span><span class="cx"> var result = evalFunction.call(inspectedGlobalObject, expression);
</span><span class="cx">
</span><del>- if (objectGroup === "console" && saveResult)
</del><ins>+ if (saveResult)
</ins><span class="cx"> this._saveResult(result);
</span><span class="cx">
</span><span class="cx"> return result;
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193203 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 18:57:20 UTC (rev 193203)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -1,5 +1,26 @@
</span><span class="cx"> 2015-12-02 Timothy Hatcher <timothy@apple.com>
</span><span class="cx">
</span><ins>+ Merge r189415. rdar://problem/23221163
+
+ 2015-09-04 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Test Runtime.saveResult and $n values
+ https://bugs.webkit.org/show_bug.cgi?id=148837
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Protocol/InspectorBackend.js:
+ (InspectorBackendClass):
+ Initialize the dump logging function different if we are in tests or not.
+ When in tests, using console.log as well as dumping system activity to
+ the system console results in an infinite loop of logging!
+
+ (InspectorBackendClass.prototype.dispatch):
+ (InspectorBackendClass.prototype._sendCommandToBackendWithCallback):
+ Use the logging function we figured out earlier.
+
+2015-12-02 Timothy Hatcher <timothy@apple.com>
+
</ins><span class="cx"> Merge r189385. rdar://problem/23221163
</span><span class="cx">
</span><span class="cx"> 2015-09-04 Joseph Pecoraro <pecoraro@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceProtocolInspectorBackendjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js (193203 => 193204)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js        2015-12-03 18:57:20 UTC (rev 193203)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js        2015-12-03 18:57:27 UTC (rev 193204)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx"> this.dumpInspectorProtocolMessages = false;
</span><span class="cx"> this.warnForLongMessageHandling = false;
</span><span class="cx"> this.longMessageHandlingThreshold = 10; // milliseconds.
</span><ins>+
+ this._log = window.InspectorTest ? InspectorFrontendHost.unbufferedLog.bind(InspectorFrontendHost) : console.log.bind(console);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Public
</span><span class="lines">@@ -77,7 +79,7 @@
</span><span class="cx"> dispatch(message)
</span><span class="cx"> {
</span><span class="cx"> if (this.dumpInspectorProtocolMessages)
</span><del>- console.log("backend: " + ((typeof message === "string") ? message : JSON.stringify(message)));
</del><ins>+ this._log("backend: " + ((typeof message === "string") ? message : JSON.stringify(message)));
</ins><span class="cx">
</span><span class="cx"> var messageObject = (typeof message === "string") ? JSON.parse(message) : message;
</span><span class="cx">
</span><span class="lines">@@ -173,7 +175,7 @@
</span><span class="cx"> {
</span><span class="cx"> var stringifiedMessage = JSON.stringify(messageObject);
</span><span class="cx"> if (this.dumpInspectorProtocolMessages)
</span><del>- console.log("frontend: " + stringifiedMessage);
</del><ins>+ this._log("frontend: " + stringifiedMessage);
</ins><span class="cx">
</span><span class="cx"> InspectorFrontendHost.sendMessageToBackend(stringifiedMessage);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>