<!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>[202784] 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/202784">202784</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-02 20:33:34 -0700 (Sat, 02 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>inspector/debugger/command-line-api-exception.html flakily times out on mac
https://bugs.webkit.org/show_bug.cgi?id=152029
&lt;rdar://problem/23813812&gt;

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2016-07-02
Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

* UserInterface/Base/Object.js:
(WebInspector.Object.addEventListener):
Return the listener, this makes it cleaner to write tests.

LayoutTests:

* inspector/debugger/command-line-api-exception-expected.txt:
* inspector/debugger/command-line-api-exception-nested-catch-expected.txt:
* inspector/debugger/command-line-api-exception-nested-catch.html:
* inspector/debugger/command-line-api-exception.html:
* platform/mac/TestExpectations:
Rewrite these tests to use the new test harness.
This also is more careful about Pause/Resume timing differences
between Release and Debug builds.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggercommandlineapiexceptionexpectedtxt">trunk/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggercommandlineapiexceptionnestedcatchexpectedtxt">trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggercommandlineapiexceptionnestedcatchhtml">trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggercommandlineapiexceptionhtml">trunk/LayoutTests/inspector/debugger/command-line-api-exception.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseObjectjs">trunk/Source/WebInspectorUI/UserInterface/Base/Object.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/LayoutTests/ChangeLog        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2016-07-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        inspector/debugger/command-line-api-exception.html flakily times out on mac
+        https://bugs.webkit.org/show_bug.cgi?id=152029
+        &lt;rdar://problem/23813812&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/debugger/command-line-api-exception-expected.txt:
+        * inspector/debugger/command-line-api-exception-nested-catch-expected.txt:
+        * inspector/debugger/command-line-api-exception-nested-catch.html:
+        * inspector/debugger/command-line-api-exception.html:
+        * platform/mac/TestExpectations:
+        Rewrite these tests to use the new test harness.
+        This also is more careful about Pause/Resume timing differences
+        between Release and Debug builds.
+
+2016-07-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Fix inspector/debugger/pause-reason.html
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=159325
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggercommandlineapiexceptionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -12,21 +12,53 @@
</span><span class="cx"> CONSOLE MESSAGE: line 55: CATCHER: [object Object]
</span><span class="cx"> Checks that $exception is available and accurate in evaluations when paused on an exception.
</span><span class="cx"> 
</span><del>-BEFORE: $exception =&gt; undefined
-PAUSE #1: $exception =&gt; TypeError: undefined is not an object (evaluating '[].x.x')
-PAUSE #2: $exception =&gt; ReferenceError: Can't find variable: variableThatDoesNotExist
-PAUSE #3: $exception =&gt; SyntaxError: Unexpected token ')'
-PAUSE #4: $exception =&gt; Error: IndexSizeError: DOM Exception 1
-PAUSE #5: $exception =&gt; thrown string
-PAUSE #6: $exception =&gt; 123.456
-PAUSE #7: $exception =&gt; null
-PAUSE #8: $exception =&gt; Object
-PAUSE #9: $exception =&gt; &lt;body&gt;
-PAUSE #10: $exception =&gt; TypeError: undefined is not an object (evaluating '[].x.x')
-STEPPED OUT TO CATCH BLOCK: $exception === e ? true
-PAUSE #11: $exception =&gt; thrown string
-STEPPED OUT TO CATCH BLOCK: $exception === e ? true
-PAUSE #12: $exception =&gt; Object
-STEPPED OUT TO CATCH BLOCK: $exception === e ? true
-AFTER: $exception =&gt; undefined
</del><span class="cx"> 
</span><ins>+== Running test suite: CommandLineAPI.$exception
+-- Running test case: BeforeExceptions
+PASS: $exception should be undefined if there is no exception.
+
+-- Running test case: UncaughtTypeException
+$exception =&gt; TypeError: undefined is not an object (evaluating '[].x.x')
+
+-- Running test case: UncaughtReferenceException
+$exception =&gt; ReferenceError: Can't find variable: variableThatDoesNotExist
+
+-- Running test case: UncaughtSyntaxException
+$exception =&gt; SyntaxError: Unexpected token ')'
+
+-- Running test case: UncaughtDOMException
+$exception =&gt; Error: IndexSizeError: DOM Exception 1
+
+-- Running test case: UncaughtString
+$exception =&gt; thrown string
+
+-- Running test case: UncaughtNumber
+$exception =&gt; 123.456
+
+-- Running test case: UncaughtNull
+$exception =&gt; null
+
+-- Running test case: UncaughtObject
+$exception =&gt; Object
+
+-- Running test case: UncaughtNode
+$exception =&gt; &lt;body&gt;
+
+-- Running test case: CatchTypeException
+PASS: Paused, stepping out to catch block...
+PASS: `$exception` should be equal to `e`.
+$exception =&gt; TypeError: undefined is not an object (evaluating '[].x.x')
+
+-- Running test case: CatchThrownString
+PASS: Paused, stepping out to catch block...
+PASS: `$exception` should be equal to `e`.
+$exception =&gt; thrown string
+
+-- Running test case: CatchThrownObject
+PASS: Paused, stepping out to catch block...
+PASS: `$exception` should be equal to `e`.
+$exception =&gt; Object
+
+-- Running test case: AfterExceptions
+PASS: $exception should be undefined if there is no exception.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggercommandlineapiexceptionnestedcatchexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -2,7 +2,12 @@
</span><span class="cx"> CONSOLE MESSAGE: line 69: outer exception
</span><span class="cx"> Checks that $exception is the value of the current exception, even in nested catch blocks.
</span><span class="cx"> 
</span><del>-BEFORE : $exception =&gt; undefined
</del><ins>+
+== Running test suite: CommandLineAPI.$exception
+-- Running test case: EmptyBefore
+PASS: $exception should be undefined if there is no exception.
+
+-- Running test case: CheckExceptionInsideNestedCatchBlocks
</ins><span class="cx"> OUTER 1: $exception =&gt; outer exception
</span><span class="cx"> INNER 1: $exception =&gt; inner exception
</span><span class="cx"> INNER 2: $exception =&gt; inner exception
</span><span class="lines">@@ -9,5 +14,7 @@
</span><span class="cx">   CATCH: $exception === e2 ? true
</span><span class="cx"> OUTER 2: $exception =&gt; outer exception
</span><span class="cx">   CATCH: $exception === e1 ? true
</span><del>-AFTER  : $exception =&gt; undefined
</del><span class="cx"> 
</span><ins>+-- Running test case: EmptyAfter
+PASS: $exception should be undefined if there is no exception.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggercommandlineapiexceptionnestedcatchhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -1,15 +1,10 @@
</span><del>-&lt;!doctype html&gt;
</del><ins>+&lt;!DOCTYPE html&gt;
</ins><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;head&gt;
</span><del>-&lt;script type=&quot;text/javascript&quot; src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
-&lt;script type=&quot;text/javascript&quot; src=&quot;./resources/exceptions.js&quot;&gt;&lt;/script&gt;
</del><ins>+&lt;script src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/exceptions.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx"> &lt;script&gt;
</span><del>-function triggerException()
-{
-    // We expect uncaught exceptions, so avoid logs for them.
-    window.onerror = function(){};
-    setTimeout(nestedCatchBlocks, 0);
-}
</del><ins>+window.onerror = function(){};
</ins><span class="cx"> 
</span><span class="cx"> function test()
</span><span class="cx"> {
</span><span class="lines">@@ -27,58 +22,85 @@
</span><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    var done = false;
-    var phase = 0;
</del><span class="cx"> 
</span><del>-    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, function(event) {
-        if (done)
-            return;
</del><ins>+    let suite = InspectorTest.createAsyncSuite(&quot;CommandLineAPI.$exception&quot;);
</ins><span class="cx"> 
</span><del>-        phase++;
-
-        // Skip past the first pause to the second pause.
-        if (phase === 1) {
-            dumpCommandLineAPIValue(&quot;OUTER 1&quot;);
-            WebInspector.debuggerManager.resume();
-            return;
</del><ins>+    suite.addTestCase({
+        name: &quot;EmptyBefore&quot;,
+        description: &quot;Without exceptions, $exception should be undefined&quot;,
+        test: (resolve, reject) =&gt; {
+            WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) =&gt; {
+                InspectorTest.expectThat(result.description === &quot;undefined&quot;, &quot;$exception should be undefined if there is no exception.&quot;);
+                resolve();
+            });
</ins><span class="cx">         }
</span><ins>+    });
</ins><span class="cx"> 
</span><del>-        // Paused on the exception in the inner try, step over to get into the inner catch.
-        if (phase === 2) {
-            dumpCommandLineAPIValue(&quot;INNER 1&quot;);
-            WebInspector.debuggerManager.stepOver();
-            return;
-        }
</del><ins>+    suite.addTestCase({
+        name: &quot;CheckExceptionInsideNestedCatchBlocks&quot;,
+        description: &quot;Check $exception is always the current exception object when stepping through catch blocks.&quot;,
+        test: (resolve, reject) =&gt; {
+            InspectorTest.evaluateInPage(&quot;setTimeout(nestedCatchBlocks, 0)&quot;);
</ins><span class="cx"> 
</span><del>-        // Paused in the inner catch, verify $exception is &quot;inner exception&quot;.
-        if (phase === 3) {
-            dumpCommandLineAPIValue(&quot;INNER 2&quot;);
-            checkIfExceptionValueMatchesVariable(&quot;e2&quot;);
-            WebInspector.debuggerManager.stepOver();
-            return;
-        }
</del><ins>+            let phase = 0;
+            let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) =&gt; {
+                if (!WebInspector.debuggerManager.activeCallFrame)
+                    return;
+
+                phase++;
+
+                // Skip past the first pause to the second pause.
+                if (phase === 1) {
+                    dumpCommandLineAPIValue(&quot;OUTER 1&quot;);
+                    WebInspector.debuggerManager.resume();
+                    return;
+                }
+
+                // Paused on the exception in the inner try, step over to get into the inner catch.
+                if (phase === 2) {
+                    dumpCommandLineAPIValue(&quot;INNER 1&quot;);
+                    WebInspector.debuggerManager.stepOver();
+                    return;
+                }
+
+                // Paused in the inner catch, verify $exception is &quot;inner exception&quot;.
+                if (phase === 3) {
+                    dumpCommandLineAPIValue(&quot;INNER 2&quot;);
+                    checkIfExceptionValueMatchesVariable(&quot;e2&quot;);
+                    WebInspector.debuggerManager.stepOver();
+                    return;
+                }
</ins><span class="cx">         
</span><del>-        // Stepped into the outer catch, verify $exception is &quot;outer exception&quot;.
-        if (phase === 4) {
-            dumpCommandLineAPIValue(&quot;OUTER 2&quot;);
-            checkIfExceptionValueMatchesVariable(&quot;e1&quot;);
-            WebInspector.debuggerManager.resume();
-            return;
</del><ins>+                // Stepped into the outer catch, verify $exception is &quot;outer exception&quot;.
+                if (phase === 4) {
+                    dumpCommandLineAPIValue(&quot;OUTER 2&quot;);
+                    checkIfExceptionValueMatchesVariable(&quot;e1&quot;);
+                    WebInspector.debuggerManager.resume().then(() =&gt; {
+                        WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, listener);
+                        resolve();
+                    }, reject);
+                    return;
+                }
+            });
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, function(event) {
-        done = true;
-        dumpCommandLineAPIValue(&quot;AFTER  &quot;);
-        InspectorTest.completeTest();
</del><ins>+    suite.addTestCase({
+        name: &quot;EmptyAfter&quot;,
+        description: &quot;Without exceptions, $exception should be undefined&quot;,
+        test: (resolve, reject) =&gt; {
+            WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) =&gt; {
+                InspectorTest.expectThat(result.description === &quot;undefined&quot;, &quot;$exception should be undefined if there is no exception.&quot;);
+                resolve();
+            });
+        }
</ins><span class="cx">     });
</span><span class="cx"> 
</span><del>-    dumpCommandLineAPIValue(&quot;BEFORE &quot;);
-    InspectorTest.evaluateInPage(&quot;triggerException()&quot;);
</del><ins>+    suite.runTestCasesAndFinish();
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body onload=&quot;runTest()&quot;&gt;
</span><del>-    &lt;p&gt;Checks that &lt;code&gt;$exception&lt;/code&gt; is the value of the current exception, even in nested catch blocks.&lt;/p&gt;
</del><ins>+&lt;p&gt;Checks that &lt;code&gt;$exception&lt;/code&gt; is the value of the current exception, even in nested catch blocks.&lt;/p&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggercommandlineapiexceptionhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/command-line-api-exception.html (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/command-line-api-exception.html        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/LayoutTests/inspector/debugger/command-line-api-exception.html        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -1,98 +1,107 @@
</span><del>-&lt;!doctype html&gt;
</del><ins>+&lt;!DOCTYPE html&gt;
</ins><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;head&gt;
</span><del>-&lt;script type=&quot;text/javascript&quot; src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
-&lt;script type=&quot;text/javascript&quot; src=&quot;./resources/exceptions.js&quot;&gt;&lt;/script&gt;
</del><ins>+&lt;script src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;./resources/exceptions.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx"> &lt;script&gt;
</span><del>-var exceptionIndex = 0;
-var exceptionCausers = [
-    triggerUncaughtTypeException,
-    triggerUncaughtReferenceException,
-    triggerUncaughtSyntaxException,
-    triggerUncaughtDOMException,
-    throwString,
-    throwNumber,
-    throwNull,
-    throwObject,
-    throwNode,
-    function() { catcher(triggerUncaughtTypeException); },
-    function() { catcher(throwString); },
-    function() { catcher(throwObject); },
-];
</del><ins>+// We expect uncaught exceptions, so avoid logs for them.
+window.onerror = function(){};
</ins><span class="cx"> 
</span><del>-
-function triggerNextException()
-{
-    // We expect uncaught exceptions, so avoid logs for them.
-    window.onerror = function(){};
-
-    setTimeout(function() {
-        exceptionCausers[exceptionIndex++]();
-    }, 0);
-}
-
</del><span class="cx"> function test()
</span><span class="cx"> {
</span><span class="cx">     WebInspector.debuggerManager.allExceptionsBreakpoint.disabled = false;
</span><span class="cx"> 
</span><del>-    function triggerNextException() {
-        InspectorTest.evaluateInPage(&quot;triggerNextException()&quot;);
-    }
</del><ins>+    let suite = InspectorTest.createAsyncSuite(&quot;CommandLineAPI.$exception&quot;);
</ins><span class="cx"> 
</span><del>-    function dumpCommandLineAPIValue(prefix) {
-        WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, function(result, wasThrown) {
-            InspectorTest.log(prefix + &quot;: $exception =&gt; &quot; + result.description);
</del><ins>+    function addNoExceptionTest(name) {
+        suite.addTestCase({
+            name, description: &quot;Without exceptions, $exception should be undefined&quot;,
+            test: (resolve, reject) =&gt; {
+                WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) =&gt; {
+                    InspectorTest.expectThat(result.description === &quot;undefined&quot;, &quot;$exception should be undefined if there is no exception.&quot;);
+                    resolve();
+                });
+            }
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    function checkIfExceptionValueMatchesCatchVariable() {
-        WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception === e&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, function(result, wasThrown) {
-            InspectorTest.log(&quot;STEPPED OUT TO CATCH BLOCK: $exception === e ? &quot; + result.description);
</del><ins>+    function addUncaughtExceptionTest(name, testFunction) {
+        suite.addTestCase({
+            name, description: &quot;Trigger an uncaught exception and check $exception.&quot;,
+            test: (resolve, reject) =&gt; {
+                InspectorTest.evaluateInPage(`setTimeout(${testFunction})`);
+                WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Paused, (event) =&gt; {
+                    WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) =&gt; {
+                        InspectorTest.log(&quot;$exception =&gt; &quot; + result.description);
+                        WebInspector.debuggerManager.resume().then(resolve, reject);
+                    });
+                });
+            }
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    var pauses = 0;
-    var stepping = false;
-    var done = false;
-    const pointWhereExpectionsAreBeingCaught = 9;
-    const expectedPauses = 12;
</del><ins>+    function addCaughtExceptionTest(name, expression) {
+        suite.addTestCase({
+            name, description: &quot;Trigger a caught exception and check $exception.&quot;,
+            test: (resolve, reject) =&gt; {
+                InspectorTest.evaluateInPage(expression);
</ins><span class="cx"> 
</span><del>-    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, function(event) {
-        if (done)
-            return;
</del><ins>+                let didStep = false;
+                let didEvaluate = false;
</ins><span class="cx"> 
</span><del>-        if (!stepping) {
-            dumpCommandLineAPIValue(&quot;PAUSE #&quot; + (++pauses));
-            if (pauses &gt; pointWhereExpectionsAreBeingCaught) {
-                WebInspector.debuggerManager.stepOut();
-                stepping = true;
-                return;
</del><ins>+                let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) =&gt; {
+                    if (!WebInspector.debuggerManager.activeCallFrame)
+                        return;
+
+                    if (!didStep) {
+                        didStep = true;
+                        InspectorTest.pass(&quot;Paused, stepping out to catch block...&quot;);
+                        WebInspector.debuggerManager.stepOut();
+                        return;
+                    }
+
+                    if (!didEvaluate) {
+                        didEvaluate = true;
+                        WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception === e&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) =&gt; {
+                            InspectorTest.expectThat(result.description === &quot;true&quot;, &quot;`$exception` should be equal to `e`.&quot;);
+                        });
+                        WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;$exception&quot;, {objectGroup: &quot;test&quot;, includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) =&gt; {
+                            InspectorTest.log(&quot;$exception =&gt; &quot; + result.description);
+                            WebInspector.debuggerManager.resume().then(() =&gt; {
+                                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, listener);
+                                resolve();
+                            }, reject);
+                        });
+                        return;
+                    }
+                });
</ins><span class="cx">             }
</span><del>-        } else {
-            checkIfExceptionValueMatchesCatchVariable();
-            stepping = false;
-        }
</del><ins>+        });
+    }
</ins><span class="cx"> 
</span><del>-        WebInspector.debuggerManager.resume();
</del><ins>+    addNoExceptionTest(&quot;BeforeExceptions&quot;);
</ins><span class="cx"> 
</span><del>-        if (pauses !== expectedPauses) {
-            triggerNextException();
-            return;
-        }
-    });
</del><ins>+    addUncaughtExceptionTest(&quot;UncaughtTypeException&quot;, &quot;triggerUncaughtTypeException&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtReferenceException&quot;, &quot;triggerUncaughtReferenceException&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtSyntaxException&quot;, &quot;triggerUncaughtSyntaxException&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtDOMException&quot;, &quot;triggerUncaughtDOMException&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtString&quot;, &quot;throwString&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtNumber&quot;, &quot;throwNumber&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtNull&quot;, &quot;throwNull&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtObject&quot;, &quot;throwObject&quot;);
+    addUncaughtExceptionTest(&quot;UncaughtNode&quot;, &quot;throwNode&quot;);
</ins><span class="cx"> 
</span><del>-    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, function(event) {
-        done = true;
-        dumpCommandLineAPIValue(&quot;AFTER&quot;);
-        InspectorTest.completeTest();
-    });
</del><ins>+    addCaughtExceptionTest(&quot;CatchTypeException&quot;, &quot;setTimeout(function() { catcher(triggerUncaughtTypeException); })&quot;);
+    addCaughtExceptionTest(&quot;CatchThrownString&quot;, &quot;setTimeout(function() { catcher(throwString); })&quot;);
+    addCaughtExceptionTest(&quot;CatchThrownObject&quot;, &quot;setTimeout(function() { catcher(throwObject); })&quot;);
</ins><span class="cx"> 
</span><del>-    dumpCommandLineAPIValue(&quot;BEFORE&quot;);
-    triggerNextException();
</del><ins>+    addNoExceptionTest(&quot;AfterExceptions&quot;);
+
+    suite.runTestCasesAndFinish();
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body onload=&quot;runTest()&quot;&gt;
</span><del>-    &lt;p&gt;Checks that &lt;code&gt;$exception&lt;/code&gt; is available and accurate in evaluations when paused on an exception.&lt;/p&gt;
</del><ins>+&lt;p&gt;Checks that &lt;code&gt;$exception&lt;/code&gt; is available and accurate in evaluations when paused on an exception.&lt;/p&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -1210,8 +1210,6 @@
</span><span class="cx"> webkit.org/b/148636 inspector/css/selector-specificity.html [ Pass Timeout ]
</span><span class="cx"> webkit.org/b/153460 [ Debug ] inspector/codemirror/prettyprinting-css-rules.html [ Pass Timeout ]
</span><span class="cx"> webkit.org/b/158742 [ Debug ] inspector/debugger/break-in-constructor-before-super.html [ Pass Timeout ]
</span><del>-webkit.org/b/152029 inspector/debugger/command-line-api-exception.html [ Pass Timeout ]
-webkit.org/b/152487 inspector/debugger/command-line-api-exception-nested-catch.html [ Pass Timeout ]
</del><span class="cx"> webkit.org/b/148636 inspector/dom/content-flow-content-nodes.html [ Pass Timeout ]
</span><span class="cx"> webkit.org/b/148636 inspector/dom/content-flow-content-removal.html [ Pass Timeout ]
</span><span class="cx"> webkit.org/b/148636 inspector/dom/content-flow-list.html [ Pass Timeout ]
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-07-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        inspector/debugger/command-line-api-exception.html flakily times out on mac
+        https://bugs.webkit.org/show_bug.cgi?id=152029
+        &lt;rdar://problem/23813812&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Object.js:
+        (WebInspector.Object.addEventListener):
+        Return the listener, this makes it cleaner to write tests.
+
</ins><span class="cx"> 2016-07-01  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Make enabling protocol logging in inspector tests easy to remember
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseObjectjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Object.js (202783 => 202784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Base/Object.js        2016-07-03 03:32:18 UTC (rev 202783)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Object.js        2016-07-03 03:33:34 UTC (rev 202784)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         listenersTable.add(thisObject, listener);
</span><ins>+        return listener;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static singleFireEventListener(eventType, listener, thisObject)
</span></span></pre>
</div>
</div>

</body>
</html>