<!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>[225950] trunk</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/225950">225950</a></dd>
<dt>Author</dt> <dd>bburg@apple.com</dd>
<dt>Date</dt> <dd>2017-12-14 17:39:11 -0800 (Thu, 14 Dec 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: InspectorTest.evaluateInPage should unwrap primitive values by default
https://bugs.webkit.org/show_bug.cgi?id=180831

Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

* UserInterface/Test/FrontendTestHarness.js:
(FrontendTestHarness.prototype.evaluateInPage.resultObjectToReturn):
(FrontendTestHarness.prototype.evaluateInPage):
Unwrap the resulting RemoteObject's value if it is a primitive.
Add an `options` dictionary so this behavior can be opted out.

* UserInterface/Test/TestHarness.js:
Add documentation of how evaluateInPage works.

LayoutTests:

* inspector/unit-tests/test-harness-evaluate-in-page-expected.txt: Added.
* inspector/unit-tests/test-harness-evaluate-in-page.html: Added.

Add test coverage for InspectorTest.evaluateInPage. Only the promise-returning
variant is tested here, because the callback variant is well-used in existing
tests and I plan to remove the callback variant entirely in later patches.

* inspector/console/js-isLikelyStackTrace-expected.txt:
* inspector/console/js-isLikelyStackTrace.html:
Fix some bad tests and rebaseline. A bug was filed for the remaining failing assertion.

* http/tests/inspector/dom/shapes-test.js:
(TestPage.registerInitializer.InspectorTest.Shapes.receivedHighlightObject):
(TestPage.registerInitializer.InspectorTest.Shapes.getShapeOutsideInfoForSelector):
* http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html:
* inspector/console/command-line-api-copy.html:
* inspector/console/console-log-proxy.html:
* inspector/debugger/js-stacktrace.html:
* inspector/dom/hideHighlight.html:
* inspector/dom/highlightFrame.html:
* inspector/dom/highlightNode.html:
* inspector/dom/highlightNodeList.html:
* inspector/dom/highlightQuad.html:
* inspector/dom/highlightRect.html:
* inspector/dom/highlightSelector.html:
* inspector/page/setEmulatedMedia.html:
* inspector/runtime/getPreview.html:
Fix existing tests to opt out of unwrapping or use the unwrapped value directly.

* inspector/dom/setEventListenerDisabled-expected.txt:
Rebaseline results. This is caused by an extra promise tick in evaluateInPage.

* inspector/injected-script/observable-expected.txt:
* inspector/injected-script/observable.html:
Fix a typo and rebaseline.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectordomshapestestjs">trunk/LayoutTests/http/tests/inspector/dom/shapes-test.js</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectorpaymentrequestpaymentrequestinternalpropertieshttpshtml">trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html</a></li>
<li><a href="#trunkLayoutTestsinspectorconsolecommandlineapicopyhtml">trunk/LayoutTests/inspector/console/command-line-api-copy.html</a></li>
<li><a href="#trunkLayoutTestsinspectorconsoleconsolelogproxyhtml">trunk/LayoutTests/inspector/console/console-log-proxy.html</a></li>
<li><a href="#trunkLayoutTestsinspectorconsolejsisLikelyStackTraceexpectedtxt">trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorconsolejsisLikelyStackTracehtml">trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggerjsstacktracehtml">trunk/LayoutTests/inspector/debugger/js-stacktrace.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhideHighlighthtml">trunk/LayoutTests/inspector/dom/hideHighlight.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhighlightFramehtml">trunk/LayoutTests/inspector/dom/highlightFrame.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhighlightNodehtml">trunk/LayoutTests/inspector/dom/highlightNode.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhighlightNodeListhtml">trunk/LayoutTests/inspector/dom/highlightNodeList.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhighlightQuadhtml">trunk/LayoutTests/inspector/dom/highlightQuad.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhighlightRecthtml">trunk/LayoutTests/inspector/dom/highlightRect.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomhighlightSelectorhtml">trunk/LayoutTests/inspector/dom/highlightSelector.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomsetEventListenerDisabledexpectedtxt">trunk/LayoutTests/inspector/dom/setEventListenerDisabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorinjectedscriptobservableexpectedtxt">trunk/LayoutTests/inspector/injected-script/observable-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorinjectedscriptobservablehtml">trunk/LayoutTests/inspector/injected-script/observable.html</a></li>
<li><a href="#trunkLayoutTestsinspectorpagesetEmulatedMediahtml">trunk/LayoutTests/inspector/page/setEmulatedMedia.html</a></li>
<li><a href="#trunkLayoutTestsinspectorruntimegetPreviewhtml">trunk/LayoutTests/inspector/runtime/getPreview.html</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTestFrontendTestHarnessjs">trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTestTestHarnessjs">trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorunitteststestharnessevaluateinpageexpectedtxt">trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorunitteststestharnessevaluateinpagehtml">trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/ChangeLog 2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2017-12-14  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: InspectorTest.evaluateInPage should unwrap primitive values by default
+        https://bugs.webkit.org/show_bug.cgi?id=180831
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/unit-tests/test-harness-evaluate-in-page-expected.txt: Added.
+        * inspector/unit-tests/test-harness-evaluate-in-page.html: Added.
+
+        Add test coverage for InspectorTest.evaluateInPage. Only the promise-returning
+        variant is tested here, because the callback variant is well-used in existing
+        tests and I plan to remove the callback variant entirely in later patches.
+
+        * inspector/console/js-isLikelyStackTrace-expected.txt:
+        * inspector/console/js-isLikelyStackTrace.html:
+        Fix some bad tests and rebaseline. A bug was filed for the remaining failing assertion.
+
+        * http/tests/inspector/dom/shapes-test.js:
+        (TestPage.registerInitializer.InspectorTest.Shapes.receivedHighlightObject):
+        (TestPage.registerInitializer.InspectorTest.Shapes.getShapeOutsideInfoForSelector):
+        * http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html:
+        * inspector/console/command-line-api-copy.html:
+        * inspector/console/console-log-proxy.html:
+        * inspector/debugger/js-stacktrace.html:
+        * inspector/dom/hideHighlight.html:
+        * inspector/dom/highlightFrame.html:
+        * inspector/dom/highlightNode.html:
+        * inspector/dom/highlightNodeList.html:
+        * inspector/dom/highlightQuad.html:
+        * inspector/dom/highlightRect.html:
+        * inspector/dom/highlightSelector.html:
+        * inspector/page/setEmulatedMedia.html:
+        * inspector/runtime/getPreview.html:
+        Fix existing tests to opt out of unwrapping or use the unwrapped value directly.
+
+        * inspector/dom/setEventListenerDisabled-expected.txt:
+        Rebaseline results. This is caused by an extra promise tick in evaluateInPage.
+
+        * inspector/injected-script/observable-expected.txt:
+        * inspector/injected-script/observable.html:
+        Fix a typo and rebaseline.
+
+
</ins><span class="cx"> 2017-12-14  Ryan Haddad  <ryanhaddad@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rebaseline compositing/repaint/iframes/composited-iframe-with-fixed-background-doc-repaint.html after r225897.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectordomshapestestjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/inspector/dom/shapes-test.js (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/dom/shapes-test.js        2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/http/tests/inspector/dom/shapes-test.js   2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -30,11 +30,11 @@
</span><span class="cx">             InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", receivedHighlightObject);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function receivedHighlightObject(error, payload, wasThrown) {
</del><ins>+        function receivedHighlightObject(error, value, wasThrown) {
</ins><span class="cx">             InspectorTest.assert(!error, "When evaluating code, received unexpected error:" + error);
</span><span class="cx">             InspectorTest.assert(!error, "When evaluating code, an exception was thrown:" + wasThrown);
</span><span class="cx"> 
</span><del>-            var data = JSON.parse(payload.value);
</del><ins>+            var data = JSON.parse(value);
</ins><span class="cx">             callback(data[0].elementData.shapeOutsideData);
</span><span class="cx">         }
</span><span class="cx">     },
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectorpaymentrequestpaymentrequestinternalpropertieshttpshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html     2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html        2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -133,11 +133,10 @@
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name, description,
</span><span class="cx">             async test() {
</span><del>-                let [result] = await Promise.all([
-                    InspectorTest.evaluateInPage(expression),
</del><ins>+                let [remoteObject, _] = await Promise.all([
+                    InspectorTest.evaluateInPage(expression, null, {remoteObjectOnly: true}),
</ins><span class="cx">                     InspectorTest.awaitEvent("Continue"),
</span><span class="cx">                 ]);
</span><del>-                let remoteObject = WI.RemoteObject.fromPayload(result.result);
</del><span class="cx">                 let [propertyDescriptors] = await promisify((cb) => { remoteObject.getAllPropertyDescriptors(cb); });
</span><span class="cx">                 for (let propertyDescriptor of propertyDescriptors.reverse()) {
</span><span class="cx">                     if (propertyDescriptor.isInternalProperty) {
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorconsolecommandlineapicopyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/console/command-line-api-copy.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/console/command-line-api-copy.html   2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/console/command-line-api-copy.html      2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -24,10 +24,9 @@
</span><span class="cx">     function commandLineAPICopyAndPaste(expression, callback) {
</span><span class="cx">         InspectorTest.assert(typeof expression === "string", "Test requires string expression to evaluate on the page.");
</span><span class="cx">         WI.runtimeManager.evaluateInInspectedWindow(`copy(${expression})`, {objectGroup: "test", includeCommandLineAPI: true}, () => {
</span><del>-            InspectorTest.evaluateInPage("pasteAndReturnString()", (error, remoteObjectPayload) => {
-                let remoteObject = WI.RemoteObject.fromPayload(remoteObjectPayload);
-                InspectorTest.assert(remoteObject.type === "string", "RemoteObject from pasteAndReturnString should return a string.");
-                callback(remoteObject.value);
</del><ins>+            InspectorTest.evaluateInPage(`pasteAndReturnString()`, (error, result) => {
+                InspectorTest.assert(typeof result === "string", "Result from pasteAndReturnString should be a string.")
+                callback(result);
</ins><span class="cx">             });
</span><span class="cx">         });
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorconsoleconsolelogproxyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/console/console-log-proxy.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/console/console-log-proxy.html       2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/console/console-log-proxy.html  2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -42,8 +42,7 @@
</span><span class="cx">         test(resolve, reject) {
</span><span class="cx">             InspectorTest.evaluateInPage("triggerProxyConsoleLog()", () => {
</span><span class="cx">                 InspectorTest.evaluateInPage("window.accessedHandlerGet", (error, result) => {
</span><del>-                    let value = WI.RemoteObject.fromPayload(result).value;
-                    InspectorTest.expectEqual(value, false, "Logging Proxy objects should not have triggered get trap.");
</del><ins>+                    InspectorTest.expectFalse(result, "Logging Proxy objects should not have triggered get trap.");
</ins><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><span class="cx">             });
</span><span class="lines">@@ -56,8 +55,7 @@
</span><span class="cx">         test(resolve, reject) {
</span><span class="cx">             InspectorTest.evaluateInPage("triggerProxyAndPrimitiveConsoleLog()", () => {
</span><span class="cx">                 InspectorTest.evaluateInPage("window.accessedHandlerGet", (error, result) => {
</span><del>-                    let value = WI.RemoteObject.fromPayload(result).value;
-                    InspectorTest.expectEqual(value, false, "Logging Proxy objects and primitives should not have triggered get trap.");
</del><ins>+                    InspectorTest.expectFalse(result, "Logging Proxy objects and primitives should not have triggered get trap.");
</ins><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><span class="cx">             });
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorconsolejsisLikelyStackTraceexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt   2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt      2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -2,14 +2,18 @@
</span><span class="cx"> 
</span><span class="cx"> == Running test suite: WI.StackTrace.isLikelyStackTrace
</span><span class="cx"> -- Running test case: notStacktrace
</span><del>-ASSERT: Should NOT be a stacktrace.
</del><ins>+PASS: Should NOT be a stacktrace.
</ins><span class="cx"> 
</span><span class="cx"> -- Running test case: typeErrorWrap
</span><del>-ASSERT: Should be a stacktrace.
</del><ins>+FAIL: Should be a stacktrace.
+    Expected: truthy
+    Actual: false
</ins><span class="cx"> 
</span><span class="cx"> -- Running test case: getAnonymousFunctionError
</span><del>-ASSERT: Should be a stacktrace.
</del><ins>+PASS: Should be a stacktrace.
</ins><span class="cx"> 
</span><span class="cx"> -- Running test case: testWithNativeCallInBetween
</span><del>-ASSERT: Should be a stacktrace.
</del><ins>+FAIL: Should be a stacktrace.
+    Expected: truthy
+    Actual: false
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorconsolejsisLikelyStackTracehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html   2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html      2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -46,8 +46,8 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: "notStacktrace",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            var result = WI.StackTrace.isLikelyStackTrace("Messages:42\nUnread:16");
-            InspectorTest.assert(result, "Should NOT be a stacktrace.");
</del><ins>+            let result = WI.StackTrace.isLikelyStackTrace("Messages:42\nUnread:16");
+            InspectorTest.expectFalse(result, "Should NOT be a stacktrace.");
</ins><span class="cx">             resolve();
</span><span class="cx">         }
</span><span class="cx">     });
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx">                 if (error)
</span><span class="cx">                     reject(error);
</span><span class="cx"> 
</span><del>-                InspectorTest.assert(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
</del><ins>+                InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
</ins><span class="cx"> 
</span><span class="cx">                 resolve();
</span><span class="cx">             });
</span><span class="lines">@@ -73,7 +73,8 @@
</span><span class="cx">                 if (error)
</span><span class="cx">                     reject(error);
</span><span class="cx"> 
</span><del>-                InspectorTest.assert(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
</del><ins>+                // FIXME: this test case fails. <https://bugs.webkit.org/show_bug.cgi?id=180664>
+                InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
</ins><span class="cx"> 
</span><span class="cx">                 resolve();
</span><span class="cx">             });
</span><span class="lines">@@ -87,7 +88,7 @@
</span><span class="cx">                 if (error)
</span><span class="cx">                     reject(error);
</span><span class="cx"> 
</span><del>-                InspectorTest.assert(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
</del><ins>+                InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
</ins><span class="cx"> 
</span><span class="cx">                 resolve();
</span><span class="cx">             });
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerjsstacktracehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/js-stacktrace.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/js-stacktrace.html  2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/debugger/js-stacktrace.html     2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">                 InspectorTest.evaluateInPage(expression, (error, result) => {
</span><span class="cx">                     InspectorTest.assert(!error, error);
</span><span class="cx">                     InspectorTest.log("\nError object:");
</span><del>-                    let stackTrace = stripFilePaths(stripPayloadAfterGlobalCode(WI.StackTrace._parseStackTrace(result.value)));
</del><ins>+                    let stackTrace = stripFilePaths(stripPayloadAfterGlobalCode(WI.StackTrace._parseStackTrace(result)));
</ins><span class="cx">                     InspectorTest.log(JSON.stringify(stackTrace, null, 4));
</span><span class="cx">                     resolve();
</span><span class="cx">                 });
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhideHighlighthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/hideHighlight.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/hideHighlight.html       2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/hideHighlight.html  2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -9,10 +9,10 @@
</span><span class="cx">     const outlineColor = undefined;
</span><span class="cx"> 
</span><span class="cx">     function getHighlightRects(callback) {
</span><del>-        InspectorTest.evaluateInPage("JSON.stringify(Array.from(window.internals.inspectorHighlightRects()))", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("JSON.stringify(Array.from(window.internals.inspectorHighlightRects()))", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -25,10 +25,10 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function getHighlight(callback) {
</span><del>-        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhighlightFramehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/highlightFrame.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/highlightFrame.html      2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/highlightFrame.html 2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -12,10 +12,10 @@
</span><span class="cx">     InspectorTest.expectEqual(childFrames.length, 2, "Page should have subframes.");
</span><span class="cx"> 
</span><span class="cx">     function getHighlight(callback) {
</span><del>-        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhighlightNodehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/highlightNode.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/highlightNode.html       2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/highlightNode.html  2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -20,10 +20,10 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     function getHighlight(callback) {
</span><del>-        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhighlightNodeListhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/highlightNodeList.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/highlightNodeList.html   2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/highlightNodeList.html      2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -20,10 +20,10 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     function getHighlight(callback) {
</span><del>-        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhighlightQuadhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/highlightQuad.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/highlightQuad.html       2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/highlightQuad.html  2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -11,10 +11,10 @@
</span><span class="cx">     const usePageCoordinates = true;
</span><span class="cx"> 
</span><span class="cx">     function getHighlightRects(callback) {
</span><del>-        InspectorTest.evaluateInPage("JSON.stringify(Array.from(window.internals.inspectorHighlightRects()))", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("JSON.stringify(Array.from(window.internals.inspectorHighlightRects()))", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhighlightRecthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/highlightRect.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/highlightRect.html       2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/highlightRect.html  2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -11,10 +11,10 @@
</span><span class="cx">     const usePageCoordinates = true;
</span><span class="cx"> 
</span><span class="cx">     function getHighlightRects(callback) {
</span><del>-        InspectorTest.evaluateInPage("JSON.stringify(Array.from(window.internals.inspectorHighlightRects()))", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("JSON.stringify(Array.from(window.internals.inspectorHighlightRects()))", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomhighlightSelectorhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/highlightSelector.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/highlightSelector.html   2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/highlightSelector.html      2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -101,10 +101,10 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function getHighlight(callback) {
</span><del>-        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, payload, wasThrown) => {
</del><ins>+        InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, value, wasThrown) => {
</ins><span class="cx">             InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
</span><span class="cx">             InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight.");
</span><del>-            callback(JSON.parse(payload.value));
</del><ins>+            callback(JSON.parse(value));
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomsetEventListenerDisabledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/dom/setEventListenerDisabled-expected.txt (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/setEventListenerDisabled-expected.txt    2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/dom/setEventListenerDisabled-expected.txt       2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -5,15 +5,15 @@
</span><span class="cx"> -- Running test case: DOM.setEventListenerDisabled.DisabledClickEvent
</span><span class="cx"> Click event listener is enabled.
</span><span class="cx"> Disabling event listener...
</span><ins>+PASS: Click event listener did not fire.
</ins><span class="cx"> <body> clicked.
</span><del>-PASS: Click event listener did not fire.
</del><span class="cx"> Click event listener is disabled.
</span><span class="cx"> 
</span><span class="cx"> -- Running test case: DOM.setEventListenerDisabled.ReenabledClickEvent
</span><span class="cx"> Click event listener is disabled.
</span><span class="cx"> Enabling event listener...
</span><ins>+PASS: Click event listener fired.
</ins><span class="cx"> <body> clicked.
</span><del>-PASS: Click event listener fired.
</del><span class="cx"> Click event listener is enabled.
</span><span class="cx"> 
</span><span class="cx"> -- Running test case: DOM.setEventListenerDisabled.Invalid
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorinjectedscriptobservableexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/injected-script/observable-expected.txt (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/injected-script/observable-expected.txt      2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/injected-script/observable-expected.txt 2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -6,5 +6,5 @@
</span><span class="cx"> -- Running test case: InjectedScript.Observable:Array.prototype[Symbol.iterator]
</span><span class="cx"> PASS: Paused.
</span><span class="cx"> PASS: Resumed.
</span><del>-PASS: 1
</del><ins>+PASS: Array.prototype[Symbol.iterator] call count should be 1.
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorinjectedscriptobservablehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/injected-script/observable.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/injected-script/observable.html      2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/injected-script/observable.html 2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx">         description: "Array iteration in Injected Script should not be observable",
</span><span class="cx">         test(resolve, reject) {
</span><span class="cx">             InspectorTest.evaluateInPage(`triggerIteration()`, (error, result) => {
</span><del>-                InspectorTest.expectThat(result.value, 1, "Array.prototype[Symbol.iterator] call count should be 1.");
</del><ins>+                InspectorTest.expectEqual(result, 1, "Array.prototype[Symbol.iterator] call count should be 1.");
</ins><span class="cx">                 resolve();
</span><span class="cx">             });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorpagesetEmulatedMediahtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/page/setEmulatedMedia.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/page/setEmulatedMedia.html   2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/page/setEmulatedMedia.html      2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -23,10 +23,10 @@
</span><span class="cx">         description: "Initial media type should match screen.",
</span><span class="cx">         test(resolve, reject) {
</span><span class="cx">             InspectorTest.evaluateInPage("mediaQueryList.matches", (error, result) => {
</span><del>-                InspectorTest.expectEqual(result.value, false, "Page should not match print media.");
</del><ins>+                InspectorTest.expectEqual(result, false, "Page should not match print media.");
</ins><span class="cx">             });
</span><span class="cx">             InspectorTest.evaluateInPage("getComputedStyle(document.body).color", (error, result) => {
</span><del>-                InspectorTest.expectEqual(result.value, "rgb(0, 0, 255)", "Body color should be blue.");
</del><ins>+                InspectorTest.expectEqual(result, "rgb(0, 0, 255)", "Body color should be blue.");
</ins><span class="cx">                 resolve();
</span><span class="cx">             });
</span><span class="cx">         }
</span><span class="lines">@@ -38,10 +38,10 @@
</span><span class="cx">         test(resolve, reject) {
</span><span class="cx">             PageAgent.setEmulatedMedia("print", (error) => {
</span><span class="cx">                 InspectorTest.evaluateInPage("mediaQueryList.matches", (error, result) => {
</span><del>-                    InspectorTest.expectEqual(result.value, true, "Page should now match print media.");
</del><ins>+                    InspectorTest.expectEqual(result, true, "Page should now match print media.");
</ins><span class="cx">                 });
</span><span class="cx">                 InspectorTest.evaluateInPage("getComputedStyle(document.body).color", (error, result) => {
</span><del>-                    InspectorTest.expectEqual(result.value, "rgb(0, 128, 0)", "Body color should be green.");
</del><ins>+                    InspectorTest.expectEqual(result, "rgb(0, 128, 0)", "Body color should be green.");
</ins><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><span class="cx">             });
</span><span class="lines">@@ -54,10 +54,10 @@
</span><span class="cx">         test(resolve, reject) {
</span><span class="cx">             PageAgent.setEmulatedMedia("", (error) => {
</span><span class="cx">                 InspectorTest.evaluateInPage("mediaQueryList.matches", (error, result) => {
</span><del>-                    InspectorTest.expectEqual(result.value, false, "Page should now not match print media.");
</del><ins>+                    InspectorTest.expectEqual(result, false, "Page should now not match print media.");
</ins><span class="cx">                 });
</span><span class="cx">                 InspectorTest.evaluateInPage("getComputedStyle(document.body).color", (error, result) => {
</span><del>-                    InspectorTest.expectEqual(result.value, "rgb(0, 0, 255)", "Page should now match print media.");
</del><ins>+                    InspectorTest.expectEqual(result, "rgb(0, 0, 255)", "Page should now match print media.");
</ins><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><span class="cx">             });
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorruntimegetPreviewhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/runtime/getPreview.html (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/runtime/getPreview.html      2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/LayoutTests/inspector/runtime/getPreview.html 2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -74,8 +74,7 @@
</span><span class="cx">         name: "RemoteObject.updatePreview.Symbol",
</span><span class="cx">         description: "Non-object RemoteObjects should not request a preview.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            InspectorTest.evaluateInPage(`Symbol.iterator`, (error, remoteObjectPayload) => {
-                let remoteObject = WI.RemoteObject.fromPayload(remoteObjectPayload);
</del><ins>+            InspectorTest.evaluateInPage(`Symbol.iterator`, (error, remoteObject) => {
</ins><span class="cx">                 InspectorTest.expectThat(!remoteObject.canLoadPreview(), `Should not be able to load a preview for a ${remoteObject.type} RemoteObject.`);
</span><span class="cx">                 remoteObject.updatePreview((preview) => {
</span><span class="cx">                     InspectorTest.expectNull(preview, `RemoteObject.updatePreview should return null for a ${remoteObject.type} RemoteObject.`);
</span><span class="lines">@@ -89,8 +88,7 @@
</span><span class="cx">         name: "RemoteObject.updatePreview.Function",
</span><span class="cx">         description: "Non-object RemoteObjects should not request a preview.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            InspectorTest.evaluateInPage(`function f() {}; f`, (error, remoteObjectPayload) => {
-                let remoteObject = WI.RemoteObject.fromPayload(remoteObjectPayload);
</del><ins>+            InspectorTest.evaluateInPage(`function f() {}; f`, (error, remoteObject) => {
</ins><span class="cx">                 InspectorTest.expectThat(!remoteObject.canLoadPreview(), `Should not be able to load a preview for a ${remoteObject.type} RemoteObject.`);
</span><span class="cx">                 remoteObject.updatePreview((preview) => {
</span><span class="cx">                     InspectorTest.expectNull(preview, `RemoteObject.updatePreview should return null for a ${remoteObject.type} RemoteObject.`);
</span><span class="lines">@@ -104,14 +102,13 @@
</span><span class="cx">         name: "RemoteObject.updatePreview.Null",
</span><span class="cx">         description: "Non-object RemoteObjects should not request a preview.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            InspectorTest.evaluateInPage(`null`, (error, remoteObjectPayload) => {
-                let remoteObject = WI.RemoteObject.fromPayload(remoteObjectPayload);
</del><ins>+            InspectorTest.evaluateInPage(`null`, (error, remoteObject) => {
</ins><span class="cx">                 InspectorTest.expectThat(!remoteObject.canLoadPreview(), `Should not be able to load a preview for a ${remoteObject.subtype} RemoteObject.`);
</span><span class="cx">                 remoteObject.updatePreview((preview) => {
</span><span class="cx">                     InspectorTest.expectNull(preview, `RemoteObject.updatePreview should return null for a ${remoteObject.subtype} RemoteObject.`);
</span><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><del>-            });
</del><ins>+            }, {remoteObjectOnly: true});
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -121,8 +118,7 @@
</span><span class="cx">         name: "Runtime.getPreview.Symbol",
</span><span class="cx">         description: "Runtime.getPreview should return an empty preview for non-objects.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            InspectorTest.evaluateInPage(`Symbol.iterator`, (error, remoteObjectPayload) => {
-                let remoteObject = WI.RemoteObject.fromPayload(remoteObjectPayload);
</del><ins>+            InspectorTest.evaluateInPage(`Symbol.iterator`, (error, remoteObject) => {
</ins><span class="cx">                 RuntimeAgent.getPreview(remoteObject.objectId, (error, result) => {
</span><span class="cx">                     InspectorTest.log(JSON.stringify(result));
</span><span class="cx">                     resolve();
</span><span class="lines">@@ -135,8 +131,7 @@
</span><span class="cx">         name: "Runtime.getPreview.Function",
</span><span class="cx">         description: "Runtime.getPreview should return an empty preview for non-objects.",
</span><span class="cx">         test(resolve, reject) {
</span><del>-            InspectorTest.evaluateInPage(`function f() {}; f`, (error, remoteObjectPayload) => {
-                let remoteObject = WI.RemoteObject.fromPayload(remoteObjectPayload);
</del><ins>+            InspectorTest.evaluateInPage(`function f() {}; f`, (error, remoteObject) => {
</ins><span class="cx">                 RuntimeAgent.getPreview(remoteObject.objectId, (error, result) => {
</span><span class="cx">                     InspectorTest.log(JSON.stringify(result));
</span><span class="cx">                     resolve();
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorunitteststestharnessevaluateinpageexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page-expected.txt (0 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page-expected.txt   2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -0,0 +1,150 @@
</span><ins>+Testing the InspectorTest.evaluateInPage function.
+
+
+== Running test suite: InspectorTest.evaluateInPage
+-- Running test case: evaluateInPage.Primitives
+Checking result of evaluating string: -42
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+Checking result of evaluating string: 42
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+Checking result of evaluating string: 0
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+Checking result of evaluating string: "String"
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+Checking result of evaluating string: false
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+Checking result of evaluating string: true
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+Checking result of evaluating string: null
+PASS: Expected and actual evaluation result should be equal.
+PASS: Should not be returned as a WI.RemoteObject.
+
+
+-- Running test case: evaluateInPage.PrimitivesWithoutUnwrapping
+Checking result of evaluating string without unwrapping: -42
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'number'.
+
+Checking result of evaluating string without unwrapping: 42
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'number'.
+
+Checking result of evaluating string without unwrapping: 0
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'number'.
+
+Checking result of evaluating string without unwrapping: "String"
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'string'.
+
+Checking result of evaluating string without unwrapping: false
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'boolean'.
+
+Checking result of evaluating string without unwrapping: true
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'boolean'.
+
+Checking result of evaluating string without unwrapping: null
+PASS: Should be returned as a WI.RemoteObject.
+PASS: Type of evaluation result should be 'object'.
+
+
+-- Running test case: evaluateInPage.RemoteObjects
+Checking result of evaluating string: ({a:42})
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: [42, 43, 44]
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'array'.
+
+Checking result of evaluating string: new Number(42)
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: function foo() { return 42; }; foo
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'function'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: Array.prototype.splice
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'function'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: async function foo() { return 42; } foo
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'function'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: () => { return 42; }
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'function'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: async () => { return 42; }
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'function'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: window.document
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'node'.
+
+Checking result of evaluating string: Symbol.iterator
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'symbol'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: [].entries()
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'iterator'.
+
+Checking result of evaluating string: Promise.resolve()
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'undefined'.
+
+Checking result of evaluating string: new Error(42)
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'error'.
+
+Checking result of evaluating string: throw new Error(42)
+PASS: Returned result should be a WI.RemoteObject.
+PASS: Non-primitive evaluation results should not have a marshalled value.
+PASS: Type of evaluation result should be 'object'.
+PASS: Subtype of evaluation result should be 'error'.
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorunitteststestharnessevaluateinpagehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page.html (0 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page.html                                (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/test-harness-evaluate-in-page.html   2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -0,0 +1,160 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    let primitiveCases = [
+        {
+            input: `-42`,
+            type: "number",
+            value: -42,
+        },
+        {
+            input: `42`,
+            type: "number",
+            value: 42,
+        },
+        {
+            input: `0`,
+            type: "number",
+            value: 0,
+        },
+        {
+            input: `"String"`,
+            type: "string",
+            value: "String",
+        },
+        {
+            input: `false`,
+            type: "boolean",
+            value: false,
+        },
+        {
+            input: `true`,
+            type: "boolean",
+            value: true,
+        },
+        {
+            input: `null`,
+            type: "object",
+            value: null,
+        },
+    ];
+
+    let complexCases = [
+        { // Plain object.
+            input: `({a:42})`,
+            type: "object",
+        },
+        { // Plain array.
+            input: `[42, 43, 44]`,
+            type: "object",
+            subtype: "array",
+        },
+        { // JS builtin object.
+            input: `new Number(42)`,
+            type: "object",
+        },
+        { // JS function.
+            input: `function foo() { return 42; }; foo`,
+            type: "function",
+        },
+        { // Native function.
+            input: `Array.prototype.splice`,
+            type: "function",
+        },
+        { // Async function.
+            input: `async function foo() { return 42; } foo`,
+            type: "function",
+        },
+        { // Arrow function.
+            input: `() => { return 42; }`,
+            type: "function",
+        },
+        { // Async arrow function.
+            input: `async () => { return 42; }`,
+            type: "function",
+        },
+        { // DOM object.
+            input: `window.document`,
+            type: "object",
+            subtype: "node",
+        },
+        { // Symbol.
+            input: `Symbol.iterator`,
+            type: "symbol",
+        },
+        { // Iterator.
+            input: `[].entries()`,
+            type: "object",
+            subtype: "iterator",
+        },
+        { // Promise.
+            input: `Promise.resolve()`,
+            type: "object",
+        },
+        { // Error (returned).
+            input: `new Error(42)`,
+            type: "object",
+            subtype: "error",
+        },
+        { // Error (thrown).
+            input: `throw new Error(42)`,
+            type: "object",
+            subtype: "error",
+        },
+    ];
+
+    let suite = InspectorTest.createAsyncSuite("InspectorTest.evaluateInPage");
+
+    suite.addTestCase({
+        name: "evaluateInPage.Primitives",
+        async test() {
+            for (let {input, value} of primitiveCases) {
+                let result = await InspectorTest.evaluateInPage(input);
+                InspectorTest.log(`Checking result of evaluating string: ${input}`);
+                InspectorTest.expectEqual(result, value, "Expected and actual evaluation result should be equal.");
+                InspectorTest.expectFalse(result instanceof WI.RemoteObject, "Should not be returned as a WI.RemoteObject.");
+                InspectorTest.log("");
+            }
+        }
+    });
+
+    suite.addTestCase({
+        name: "evaluateInPage.PrimitivesWithoutUnwrapping",
+        async test() {
+            for (let {input, type, value} of primitiveCases) {
+                let result = await InspectorTest.evaluateInPage(input, null, {remoteObjectOnly: true});
+                InspectorTest.log(`Checking result of evaluating string without unwrapping: ${input}`);
+                InspectorTest.expectThat(result instanceof WI.RemoteObject, "Should be returned as a WI.RemoteObject.");
+                InspectorTest.expectEqual(result.type, type, `Type of evaluation result should be '${type}'.`);
+                InspectorTest.log("");
+            }
+        }
+    });
+
+    suite.addTestCase({
+        name: "evaluateInPage.RemoteObjects",
+        async test() {
+            for (let {input, type, subtype, thrown} of complexCases) {
+                let result = await InspectorTest.evaluateInPage(input);
+                InspectorTest.log(`Checking result of evaluating string: ${input}`);
+                InspectorTest.expectThat(result instanceof WI.RemoteObject, "Returned result should be a WI.RemoteObject.");
+                InspectorTest.expectFalse(result.hasValue(), "Non-primitive evaluation results should not have a marshalled value.");
+                InspectorTest.expectEqual(result.type, type, `Type of evaluation result should be '${type}'.`);
+                InspectorTest.expectEqual(result.subtype, subtype, `Subtype of evaluation result should be '${subtype}'.`);
+                InspectorTest.log("");
+            }
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+    <p>Testing the InspectorTest.evaluateInPage function.</p>
+</body>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/Source/WebInspectorUI/ChangeLog       2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-12-14  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: InspectorTest.evaluateInPage should unwrap primitive values by default
+        https://bugs.webkit.org/show_bug.cgi?id=180831
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Test/FrontendTestHarness.js:
+        (FrontendTestHarness.prototype.evaluateInPage.resultObjectToReturn):
+        (FrontendTestHarness.prototype.evaluateInPage):
+        Unwrap the resulting RemoteObject's value if it is a primitive.
+        Add an `options` dictionary so this behavior can be opted out.
+
+        * UserInterface/Test/TestHarness.js:
+        Add documentation of how evaluateInPage works.
+
</ins><span class="cx"> 2017-12-14  Nikita Vasilyev  <nvasilyev@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Styles Redesign: selecting text should not add new properties
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTestFrontendTestHarnessjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js    2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js       2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -77,8 +77,10 @@
</span><span class="cx">         this.evaluateInPage(`TestPage.debugLog(unescape("${escape(stringifiedMessage)}"));`);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    evaluateInPage(expression, callback)
</del><ins>+    evaluateInPage(expression, callback, options={})
</ins><span class="cx">     {
</span><ins>+        let remoteObjectOnly = !!options.remoteObjectOnly;
+
</ins><span class="cx">         // If we load this page outside of the inspector, or hit an early error when loading
</span><span class="cx">         // the test frontend, then defer evaluating the commands (indefinitely in the former case).
</span><span class="cx">         if (this._originalConsole && !window.RuntimeAgent) {
</span><span class="lines">@@ -86,10 +88,18 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (typeof callback === "function")
-            RuntimeAgent.evaluate.invoke({expression, objectGroup: "test", includeCommandLineAPI: false}, callback);
-        else
-            return RuntimeAgent.evaluate.invoke({expression, objectGroup: "test", includeCommandLineAPI: false});
</del><ins>+        // Return primitive values directly, otherwise return a WI.RemoteObject instance.
+        function resultObjectToReturn(result) {
+            let remoteObject = WI.RemoteObject.fromPayload(result);
+            return (!remoteObjectOnly && remoteObject.hasValue()) ? remoteObject.value : remoteObject;
+        }
+
+        let response = RuntimeAgent.evaluate.invoke({expression, objectGroup: "test", includeCommandLineAPI: false})
+        if (callback && typeof callback === "function") {
+            response = response.then(({result, wasThrown}) => callback(null, resultObjectToReturn(result), wasThrown));
+            response = response.catch((error) => callback(error, null, false));
+        } else
+            return response.then(({result}) => resultObjectToReturn(result));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     debug()
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTestTestHarnessjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js (225949 => 225950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js    2017-12-15 01:29:31 UTC (rev 225949)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js       2017-12-15 01:39:11 UTC (rev 225950)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -55,7 +55,14 @@
</span><span class="cx">         throw new Error("Must be implemented by subclasses.");
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    evaluateInPage(string, callback)
</del><ins>+    // If 'callback' is a function, it will be with the arguments
+    // callback(error, result, wasThrown). Otherwise, a promise is
+    // returned that resolves with 'result' or rejects with 'error'.
+
+    // The options object accepts the following keys and values:
+    // 'remoteObjectOnly': if true, do not unwrap the result payload to a
+    // primitive value even if possible. Useful if testing WI.RemoteObject directly.
+    evaluateInPage(string, callback, options={})
</ins><span class="cx">     {
</span><span class="cx">         throw new Error("Must be implemented by subclasses.");
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>