<!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>[206152] trunk/LayoutTests</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/206152">206152</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-20 10:28:51 -0700 (Tue, 20 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: adopt Object.awaitEvent in LayoutTests/inspector/model
https://bugs.webkit.org/show_bug.cgi?id=162074

Patch by Devin Rousso &lt;dcrousso+webkit@gmail.com&gt; on 2016-09-20
Reviewed by Brian Burg.

Replace instances of singleFireEventListener with awaitEvent and use promise logic to make
tests more readable.

* inspector/model/frame-extra-scripts.html:
* inspector/model/scope-chain-node.html:
* inspector/model/script-resource-relationship-expected.txt:
* inspector/model/script-resource-relationship.html:
* inspector/model/stack-trace.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectormodelframeextrascriptshtml">trunk/LayoutTests/inspector/model/frame-extra-scripts.html</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscopechainnodehtml">trunk/LayoutTests/inspector/model/scope-chain-node.html</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscriptresourcerelationshipexpectedtxt">trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscriptresourcerelationshiphtml">trunk/LayoutTests/inspector/model/script-resource-relationship.html</a></li>
<li><a href="#trunkLayoutTestsinspectormodelstacktracehtml">trunk/LayoutTests/inspector/model/stack-trace.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206151 => 206152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-20 17:14:00 UTC (rev 206151)
+++ trunk/LayoutTests/ChangeLog        2016-09-20 17:28:51 UTC (rev 206152)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-09-20  Devin Rousso  &lt;dcrousso+webkit@gmail.com&gt;
+
+        Web Inspector: adopt Object.awaitEvent in LayoutTests/inspector/model
+        https://bugs.webkit.org/show_bug.cgi?id=162074
+
+        Reviewed by Brian Burg.
+
+        Replace instances of singleFireEventListener with awaitEvent and use promise logic to make
+        tests more readable.
+
+        * inspector/model/frame-extra-scripts.html:
+        * inspector/model/scope-chain-node.html:
+        * inspector/model/script-resource-relationship-expected.txt:
+        * inspector/model/script-resource-relationship.html:
+        * inspector/model/stack-trace.html:
+
</ins><span class="cx"> 2016-09-20  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [media-source] Support MediaSource.setLiveSeekableRanges()
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelframeextrascriptshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/frame-extra-scripts.html (206151 => 206152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/frame-extra-scripts.html        2016-09-20 17:14:00 UTC (rev 206151)
+++ trunk/LayoutTests/inspector/model/frame-extra-scripts.html        2016-09-20 17:28:51 UTC (rev 206152)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;FrameHasNoExtraScriptsYet&quot;,
</span><span class="cx">         description: &quot;No extra scripts yet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             let mainFrame = WebInspector.frameResourceManager.mainFrame;
</span><span class="cx">             InspectorTest.expectThat(mainFrame.extraScripts.length === 0, &quot;Main frame should have no dynamic scripts.&quot;);
</span><span class="cx">             resolve();
</span><span class="lines">@@ -26,17 +26,18 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;AddExtraScript&quot;,
</span><span class="cx">         description: &quot;Add extra script.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {            
-            WebInspector.frameResourceManager.mainFrame.singleFireEventListener(WebInspector.Frame.Event.ExtraScriptAdded, (event) =&gt; {
</del><ins>+        test(resolve, reject) {
+            WebInspector.frameResourceManager.mainFrame.awaitEvent(WebInspector.Frame.Event.ExtraScriptAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 InspectorTest.pass(&quot;ExtraScriptAdded event fired.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.script.dynamicallyAddedScriptElement, &quot;Script should identify as dynamic.&quot;);
</span><del>-            });
</del><span class="cx"> 
</span><del>-            InspectorTest.evaluateInPage(&quot;triggerAddScriptElement()&quot;, () =&gt; {
</del><span class="cx">                 let mainFrame = WebInspector.frameResourceManager.mainFrame;
</span><span class="cx">                 InspectorTest.expectThat(mainFrame.extraScripts.length === 1, &quot;Main frame should have 1 dynamic script.&quot;);
</span><del>-                resolve();
-            });
</del><ins>+            })
+            .then(resolve, reject);
+
+            InspectorTest.evaluateInPage(&quot;triggerAddScriptElement()&quot;);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscopechainnodehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/scope-chain-node.html (206151 => 206152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/scope-chain-node.html        2016-09-20 17:14:00 UTC (rev 206151)
+++ trunk/LayoutTests/inspector/model/scope-chain-node.html        2016-09-20 17:28:51 UTC (rev 206152)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">         return &quot;Unexpected Scope Type&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    function harvestScopeChain(scopeChain) {        
</del><ins>+    function harvestScopeChain(scopeChain) {
</ins><span class="cx">         let promises = [];
</span><span class="cx">         for (let scope of scopeChain) {
</span><span class="cx">             promises.push(new Promise((resolve, reject) =&gt; {
</span><span class="lines">@@ -40,7 +40,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function logScopeChain(scopeChain) {
</span><del>-        return harvestScopeChain(scopeChain).then((results) =&gt; {
</del><ins>+        return harvestScopeChain(scopeChain)
+        .then((results) =&gt; {
</ins><span class="cx">             InspectorTest.log(&quot;SCOPE CHAIN:&quot;);
</span><span class="cx">             for (let {scope, propertyDescriptors} of results) {
</span><span class="cx">                 InspectorTest.log(`    ${scopeTypeToString(scope.type)}`);
</span><span class="lines">@@ -59,18 +60,21 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;WebInspector.ScopeChainNode.AllTypes&quot;,
</span><span class="cx">         description: &quot;Tests for each of the different scope chain node types.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            InspectorTest.evaluateInPage(&quot;setTimeout(testAllScopes)&quot;);
-            WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) =&gt; {
</del><ins>+        test(resolve, reject) {
+            WebInspector.debuggerManager.awaitEvent(WebInspector.DebuggerManager.Event.CallFramesDidChange)
+            .then((event) =&gt; {
</ins><span class="cx">                 let scopeChain = WebInspector.debuggerManager.activeCallFrame.scopeChain;
</span><span class="cx">                 InspectorTest.expectThat(scopeChain.length === 13, &quot;ScopeChain should have 13 scopes.&quot;);
</span><del>-                logScopeChain(scopeChain).then((result) =&gt; {
-                    WebInspector.debuggerManager.resume();
-                    WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Resumed, (event) =&gt; {
-                        resolve();
-                    });
-                });
-            });
</del><ins>+                return logScopeChain(scopeChain);
+            })
+            .then((result) =&gt; {
+                let promise = WebInspector.debuggerManager.awaitEvent(WebInspector.DebuggerManager.Event.Resumed);
+                WebInspector.debuggerManager.resume();
+                return promise;
+            })
+            .then(resolve, reject);
+
+            InspectorTest.evaluateInPage(&quot;setTimeout(testAllScopes)&quot;);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -77,17 +81,20 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;WebInspector.ScopeChainNode.FunctionNameInFunctionExpression&quot;,
</span><span class="cx">         description: &quot;Tests that there should be a FunctionName scope inside a function expression.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
+            WebInspector.debuggerManager.awaitEvent(WebInspector.DebuggerManager.Event.CallFramesDidChange)
+            .then((event) =&gt; {
+                let scopeChain = WebInspector.debuggerManager.activeCallFrame.scopeChain;
+                return logScopeChain(scopeChain);
+            })
+            .then((result) =&gt; {
+                let promise = WebInspector.debuggerManager.awaitEvent(WebInspector.DebuggerManager.Event.Resumed);
+                WebInspector.debuggerManager.resume();
+                return promise;
+            })
+            .then(resolve, reject);
+
</ins><span class="cx">             InspectorTest.evaluateInPage(&quot;setTimeout(testFunctionNameScope1)&quot;);
</span><del>-            WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) =&gt; {
-                let scopeChain = WebInspector.debuggerManager.activeCallFrame.scopeChain;
-                logScopeChain(scopeChain).then((result) =&gt; {
-                    WebInspector.debuggerManager.resume();
-                    WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Resumed, (event) =&gt; {
-                        resolve();
-                    });
-                });
-            });
</del><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -94,17 +101,20 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;WebInspector.ScopeChainNode.FunctionNameInClassMethod&quot;,
</span><span class="cx">         description: &quot;Tests that there should be a FunctionName scope inside a class method.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
+            WebInspector.debuggerManager.awaitEvent(WebInspector.DebuggerManager.Event.CallFramesDidChange)
+            .then((event) =&gt; {
+                let scopeChain = WebInspector.debuggerManager.activeCallFrame.scopeChain;
+                return logScopeChain(scopeChain);
+            })
+            .then((result) =&gt; {
+                let promise = WebInspector.debuggerManager.awaitEvent(WebInspector.DebuggerManager.Event.Resumed);
+                WebInspector.debuggerManager.resume();
+                return promise;
+            })
+            .then(resolve, reject);
+
</ins><span class="cx">             InspectorTest.evaluateInPage(&quot;setTimeout(testFunctionNameScope2)&quot;);
</span><del>-            WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) =&gt; {
-                let scopeChain = WebInspector.debuggerManager.activeCallFrame.scopeChain;
-                logScopeChain(scopeChain).then((result) =&gt; {
-                    WebInspector.debuggerManager.resume();
-                    WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Resumed, (event) =&gt; {
-                        resolve();
-                    });
-                });
-            });
</del><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -111,10 +121,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;WebInspector.ScopeChainNode.BlockScopes&quot;,
</span><span class="cx">         description: &quot;Tests for a Block scope inside all the different types of blocks.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            InspectorTest.evaluateInPage(&quot;setTimeout(testBlockScopes)&quot;);
-            WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, callFramesDidChangeListener);
-
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             let pauseCount = 0;
</span><span class="cx">             let pauseEventsExpected = 19;
</span><span class="cx">             function callFramesDidChangeListener(event) {
</span><span class="lines">@@ -121,7 +128,7 @@
</span><span class="cx">                 if (!WebInspector.debuggerManager.activeCallFrame)
</span><span class="cx">                     return;
</span><span class="cx"> 
</span><del>-                pauseCount++;                
</del><ins>+                pauseCount++;
</ins><span class="cx">                 let scopeChain = WebInspector.debuggerManager.activeCallFrame.scopeChain;
</span><span class="cx"> 
</span><span class="cx">                 // First, normal function scope.
</span><span class="lines">@@ -149,10 +156,15 @@
</span><span class="cx"> 
</span><span class="cx">                 // Print out the full scope of the last few where there are nested or buried block scopes.
</span><span class="cx">                 InspectorTest.expectThat(scopeChain.some((scopeChain) =&gt; scopeChain.type === WebInspector.ScopeChainNode.Type.Block), `Pause #${pauseCount} - Contains a Block scope.`);
</span><del>-                logScopeChain(scopeChain).then((result) =&gt; {
</del><ins>+
+                logScopeChain(scopeChain)
+                .then((result) =&gt; {
</ins><span class="cx">                     WebInspector.debuggerManager.resume();
</span><span class="cx">                 });
</span><span class="cx">             }
</span><ins>+
+            WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, callFramesDidChangeListener);
+            InspectorTest.evaluateInPage(&quot;setTimeout(testBlockScopes)&quot;);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscriptresourcerelationshipexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt (206151 => 206152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt        2016-09-20 17:14:00 UTC (rev 206151)
+++ trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt        2016-09-20 17:28:51 UTC (rev 206152)
</span><span class="lines">@@ -3,8 +3,7 @@
</span><span class="cx"> 
</span><span class="cx"> == Running test suite: WebInspector.Script and WebInspector.Resource relationship
</span><span class="cx"> -- Running test case: ScriptWithResource
</span><del>-PASS: Resource was added.
-PASS: Script was added.
</del><ins>+PASS: Only one Script should be added.
</ins><span class="cx"> PASS: Resource and Script have the same URL.
</span><span class="cx"> PASS: Resource should be related to one script.
</span><span class="cx"> PASS: Resource should be related to the newly added script.
</span><span class="lines">@@ -12,8 +11,7 @@
</span><span class="cx"> PASS: Script should not have a sourceURL.
</span><span class="cx"> 
</span><span class="cx"> -- Running test case: NamedScriptWithResource
</span><del>-PASS: Resource was added.
-PASS: Script was added.
</del><ins>+PASS: Only one Script should be added.
</ins><span class="cx"> PASS: Resource and Script have the same URL.
</span><span class="cx"> PASS: Resource should be related to one script.
</span><span class="cx"> PASS: Resource should be related to the newly added script.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscriptresourcerelationshiphtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/script-resource-relationship.html (206151 => 206152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/script-resource-relationship.html        2016-09-20 17:14:00 UTC (rev 206151)
+++ trunk/LayoutTests/inspector/model/script-resource-relationship.html        2016-09-20 17:28:51 UTC (rev 206152)
</span><span class="lines">@@ -46,24 +46,31 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;ScriptWithResource&quot;,
</span><span class="cx">         description: &quot;Normal relationship between a script and a resource.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            let script = null, resource = null;
</del><ins>+        test(resolve, reject) {
+            let script = null;
+            let resource = null;
</ins><span class="cx">             
</span><span class="cx">             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
</span><del>-            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) =&gt; {
-                InspectorTest.pass(&quot;Resource was added.&quot;);
</del><ins>+            WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 resource = event.data.resource;
</span><ins>+                validateRelationship();
</ins><span class="cx">             });
</span><span class="cx">             
</span><span class="cx">             function scriptListener(event) {
</span><span class="cx">                 if (!event.data.script.url)
</span><span class="cx">                     return;
</span><del>-                InspectorTest.pass(&quot;Script was added.&quot;);
</del><ins>+
+                InspectorTest.expectThat(!script, &quot;Only one Script should be added.&quot;);
+
</ins><span class="cx">                 script = event.data.script;
</span><span class="cx">                 validateRelationship();
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             function validateRelationship() {
</span><ins>+                if (!resource || !script)
+                    return;
+
</ins><span class="cx">                 validateNormalRelationship(resource, script);
</span><span class="cx">                 InspectorTest.expectThat(!script.sourceURL, &quot;Script should not have a sourceURL.&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -78,24 +85,31 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;NamedScriptWithResource&quot;,
</span><span class="cx">         description: &quot;Normal relationship between a named script and a resource.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            let script = null, resource = null;
</del><ins>+        test(resolve, reject) {
+            let script = null;
+            let resource = null;
</ins><span class="cx"> 
</span><span class="cx">             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
</span><del>-            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) =&gt; {
-                InspectorTest.pass(&quot;Resource was added.&quot;);
</del><ins>+            WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.ResourceWasAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 resource = event.data.resource;
</span><ins>+                validateRelationship();
</ins><span class="cx">             });
</span><span class="cx"> 
</span><span class="cx">             function scriptListener(event) {
</span><span class="cx">                 if (!event.data.script.url)
</span><span class="cx">                     return;
</span><del>-                InspectorTest.pass(&quot;Script was added.&quot;);
</del><ins>+
+                InspectorTest.expectThat(!script, &quot;Only one Script should be added.&quot;);
+
</ins><span class="cx">                 script = event.data.script;
</span><span class="cx">                 validateRelationship();
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             function validateRelationship() {
</span><ins>+                if (!resource || !script)
+                    return;
+
</ins><span class="cx">                 validateNormalRelationship(resource, script);
</span><span class="cx">                 InspectorTest.expectThat(script.sourceURL === &quot;foo.js&quot;, &quot;Script should have a sourceURL.&quot;);
</span><span class="cx">                 WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener, null);
</span><span class="lines">@@ -109,7 +123,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;ScriptWithoutResource&quot;,
</span><span class="cx">         description: &quot;A named eval does not have a resource.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
</span><span class="cx">             let resourceListener = WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) =&gt; {
</span><span class="cx">                 InspectorTest.fail(&quot;Resource should not be added.&quot;);
</span><span class="lines">@@ -138,7 +152,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;DynamicallyAddedScriptElementNoResource&quot;,
</span><span class="cx">         description: &quot;A dynamically added script element has no resource.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
</span><span class="cx"> 
</span><span class="cx">             function scriptListener(event) {
</span><span class="lines">@@ -161,7 +175,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;DocumentWithInlineScripts&quot;,
</span><span class="cx">         description: &quot;A document resource may be associated with multiple inline scripts.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             let mainResource = WebInspector.frameResourceManager.mainFrame.mainResource;
</span><span class="cx">             let scripts = mainResource.scripts.slice().sort((a, b) =&gt; a.range.startLine - b.range.startLine);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelstacktracehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/stack-trace.html (206151 => 206152)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/stack-trace.html        2016-09-20 17:14:00 UTC (rev 206151)
+++ trunk/LayoutTests/inspector/model/stack-trace.html        2016-09-20 17:28:51 UTC (rev 206152)
</span><span class="lines">@@ -30,9 +30,9 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;WebInspector.ConsoleMessage.StackTrace&quot;,
</span><span class="cx">         description: &quot;Test we can create a StackTrace from console messages (Console.StackTrace).&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            InspectorTest.evaluateInPage(&quot;triggerConsoleMessage()&quot;);
-            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, function addListener(event) {
</del><ins>+        test(resolve, reject) {
+            WebInspector.logManager.awaitEvent(WebInspector.LogManager.Event.MessageAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 // Trace message should always have a stack trace.
</span><span class="cx">                 let consoleMessage = event.data.message;
</span><span class="cx">                 let stackTrace = consoleMessage.stackTrace;
</span><span class="lines">@@ -45,8 +45,10 @@
</span><span class="cx">                 InspectorTest.expectThat(!stackTrace.callFrames[0].scopeChain.length, &quot;CallFrame in StackTrace has no scopeChain.&quot;);
</span><span class="cx"> 
</span><span class="cx">                 logStackTrace(consoleMessage.stackTrace);
</span><del>-                resolve();
-            });
</del><ins>+            })
+            .then(resolve, reject);
+
+            InspectorTest.evaluateInPage(&quot;triggerConsoleMessage()&quot;);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>