<!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>[206133] 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/206133">206133</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-19 16:51:00 -0700 (Mon, 19 Sep 2016)</dd>
</dl>

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

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

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

* inspector/css/createStyleSheet.html:
* inspector/css/generate-css-rule-string.html:
* inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt:
* inspector/css/manager-preferredInspectorStyleSheetForFrame.html:
* inspector/css/stylesheet-events-basic.html:
* inspector/css/stylesheet-events-inspector-stylesheet.html:
* inspector/css/stylesheet-events-multiple-documents.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorcsscreateStyleSheethtml">trunk/LayoutTests/inspector/css/createStyleSheet.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcssgeneratecssrulestringhtml">trunk/LayoutTests/inspector/css/generate-css-rule-string.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcssmanagerpreferredInspectorStyleSheetForFrameexpectedtxt">trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorcssmanagerpreferredInspectorStyleSheetForFramehtml">trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcssstylesheeteventsbasichtml">trunk/LayoutTests/inspector/css/stylesheet-events-basic.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcssstylesheeteventsinspectorstylesheethtml">trunk/LayoutTests/inspector/css/stylesheet-events-inspector-stylesheet.html</a></li>
<li><a href="#trunkLayoutTestsinspectorcssstylesheeteventsmultipledocumentshtml">trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/ChangeLog        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-09-19  Devin Rousso  &lt;dcrousso+webkit@gmail.com&gt;
+
+        Web Inspector: adopt Object.awaitEvent in LayoutTests/inspector/css
+        https://bugs.webkit.org/show_bug.cgi?id=162071
+
+        Reviewed by Brian Burg.
+
+        Replace instances of singleFireEventListener with awaitEvent and use promise logic to make
+        tests more readable.
+
+        * inspector/css/createStyleSheet.html:
+        * inspector/css/generate-css-rule-string.html:
+        * inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt:
+        * inspector/css/manager-preferredInspectorStyleSheetForFrame.html:
+        * inspector/css/stylesheet-events-basic.html:
+        * inspector/css/stylesheet-events-inspector-stylesheet.html:
+        * inspector/css/stylesheet-events-multiple-documents.html:
+
</ins><span class="cx"> 2016-09-19  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Align HTMLAppletElement with the specification
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcsscreateStyleSheethtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/createStyleSheet.html (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/createStyleSheet.html        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/createStyleSheet.html        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckNoStyleSheets&quot;,
</span><span class="cx">         description: &quot;Ensure there are no stylesheets.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, &quot;Should be no stylesheets.&quot;);
</span><span class="cx">             resolve();
</span><span class="cx">         }
</span><span class="lines">@@ -23,9 +23,9 @@
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name: &quot;CreateInspectorStyleSheetCall&quot; + i,
</span><span class="cx">             description: &quot;Should create a new inspector stylesheet.&quot;,
</span><del>-            test: (resolve, reject) =&gt; {
-                CSSAgent.createStyleSheet(mainFrame.id);
-                WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+            test(resolve, reject) {
+                WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+                .then((event) =&gt; {
</ins><span class="cx">                     InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === i, &quot;Should increase the list of stylesheets.&quot;);
</span><span class="cx">                     InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;Added StyleSheet origin should be 'inspector'.&quot;);
</span><span class="cx">                     InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="lines">@@ -33,14 +33,17 @@
</span><span class="cx">                     if (addedStyleSheet)
</span><span class="cx">                         InspectorTest.expectThat(event.data.styleSheet !== addedStyleSheet, &quot;Added StyleSheet should be different from the last added stylesheet.&quot;);
</span><span class="cx">                     addedStyleSheet = event.data.styleSheet;
</span><del>-                    resolve();
-                });
</del><ins>+                })
+                .then(resolve, reject);
+
+                CSSAgent.createStyleSheet(mainFrame.id);
</ins><span class="cx">             }
</span><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
-        InspectorTest.assert(false, &quot;Should not be removing any StyleSheets in this test.&quot;);
</del><ins>+    WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+    .then((event) =&gt; {
+        InspectorTest.fail(&quot;Should not be removing any StyleSheets in this test.&quot;);
</ins><span class="cx">     });
</span><span class="cx"> 
</span><span class="cx">     suite.runTestCasesAndFinish();
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssgeneratecssrulestringhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/generate-css-rule-string.html (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/generate-css-rule-string.html        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/generate-css-rule-string.html        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name: &quot;InlineStyleString&quot;,
</span><span class="cx">             description: &quot;Check the formatting of the generated inline style string.&quot;,
</span><del>-            test: (resolve, reject) =&gt; {
</del><ins>+            test(resolve, reject) {
</ins><span class="cx">                 InspectorTest.log(nodeStyles.inlineStyle.generateCSSRuleString());
</span><span class="cx">                 resolve();
</span><span class="cx">             }
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">             suite.addTestCase({
</span><span class="cx">                 name: &quot;CSSRuleString&quot; + i,
</span><span class="cx">                 description: &quot;Check the formatting of the generated string for the matched CSS rule.&quot;,
</span><del>-                test: (resolve, reject) =&gt; {
</del><ins>+                test(resolve, reject) {
</ins><span class="cx">                     InspectorTest.log(rule.style.generateCSSRuleString());
</span><span class="cx">                     resolve();
</span><span class="cx">                 }
</span><span class="lines">@@ -44,19 +44,21 @@
</span><span class="cx">         suite.runTestCasesAndFinish();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    WebInspector.domTreeManager.requestDocument(function(documentNode) {
-        WebInspector.domTreeManager.querySelector(documentNode.id, &quot;#test-node&quot;, function(contentNodeId) {
-            if (contentNodeId) {
-                let domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
-                nodeStyles = WebInspector.cssStyleManager.stylesForNode(domNode);
-                if (nodeStyles.needsRefresh)
-                    nodeStyles.singleFireEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, validateSelectors, this);
-                else
-                    validateSelectors();
-            } else {
</del><ins>+    WebInspector.domTreeManager.requestDocument((documentNode) =&gt; {
+        WebInspector.domTreeManager.querySelector(documentNode.id, &quot;#test-node&quot;, (contentNodeId) =&gt; {
+            if (!contentNodeId) {
</ins><span class="cx">                 InspectorTest.log(&quot;DOM node not found.&quot;);
</span><span class="cx">                 InspectorTest.completeTest();
</span><ins>+                return;
</ins><span class="cx">             }
</span><ins>+
+            let domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
+            nodeStyles = WebInspector.cssStyleManager.stylesForNode(domNode);
+            if (nodeStyles.needsRefresh) {
+                nodeStyles.awaitEvent(WebInspector.DOMNodeStyles.Event.Refreshed)
+                .then(validateSelectors);
+            } else
+                validateSelectors();
</ins><span class="cx">         });
</span><span class="cx">     });
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssmanagerpreferredInspectorStyleSheetForFrameexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -7,12 +7,12 @@
</span><span class="cx"> PASS: Should be no stylesheets.
</span><span class="cx"> 
</span><span class="cx"> -- Running test case: CreateMainFrameInspectorStyleSheet
</span><ins>+PASS: Should be one stylesheet.
+PASS: StyleSheet origin is inspector.
+PASS: StyleSheet.isInspectorStyleSheet() should be true.
</ins><span class="cx"> PASS: Added StyleSheet origin should be 'inspector'.
</span><span class="cx"> PASS: StyleSheet.isInspectorStyleSheet() should be true.
</span><span class="cx"> PASS: Added StyleSheet frame should be the main frame.
</span><del>-PASS: Should be one stylesheet.
-PASS: StyleSheet origin is inspector.
-PASS: StyleSheet.isInspectorStyleSheet() should be true.
</del><span class="cx"> 
</span><span class="cx"> -- Running test case: AnotherMainFrameRequestDoesNothing
</span><span class="cx"> PASS: Should still be one stylesheet.
</span><span class="lines">@@ -20,12 +20,12 @@
</span><span class="cx"> PASS: StyleSheet.isInspectorStyleSheet() should be true.
</span><span class="cx"> 
</span><span class="cx"> -- Running test case: CreateSubFrameInspectorStyleSheet
</span><ins>+PASS: Should be two stylesheets.
+PASS: StyleSheet origin should be 'inspector'.
+PASS: StyleSheet.isInspectorStyleSheet() should be true.
</ins><span class="cx"> PASS: Added StyleSheet origin should be 'inspector'.
</span><span class="cx"> PASS: StyleSheet.isInspectorStyleSheet() should be true.
</span><span class="cx"> PASS: Added StyleSheet frame should be a child frame.
</span><del>-PASS: Should be two stylesheets.
-PASS: StyleSheet origin should be 'inspector'.
-PASS: StyleSheet.isInspectorStyleSheet() should be true.
</del><span class="cx"> 
</span><span class="cx"> -- Running test case: AnotherSubFrameRequestDoesNothing
</span><span class="cx"> PASS: Should be two stylesheets.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssmanagerpreferredInspectorStyleSheetForFramehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckNoStyleSheets&quot;,
</span><span class="cx">         description: &quot;Ensure there are no stylesheets.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, &quot;Should be no stylesheets.&quot;);
</span><span class="cx">             resolve();
</span><span class="cx">         }
</span><span class="lines">@@ -22,13 +22,15 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CreateMainFrameInspectorStyleSheet&quot;,
</span><span class="cx">         description: &quot;First request for main frame should create inspector stylesheet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+        test(resolve, reject) {
+            WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;Added StyleSheet origin should be 'inspector'.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.parentFrame === mainFrame, &quot;Added StyleSheet frame should be the main frame.&quot;);
</span><span class="cx">             });
</span><del>-            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, function(styleSheet) {
</del><ins>+
+            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, (styleSheet) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, &quot;Should be one stylesheet.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;StyleSheet origin is inspector.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="lines">@@ -40,11 +42,11 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;AnotherMainFrameRequestDoesNothing&quot;,
</span><span class="cx">         description: &quot;Second request for main frame should not create a new stylesheet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            let listener = WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+        test(resolve, reject) {
+            let listener = WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, (event) =&gt; {
</ins><span class="cx">                 InspectorTest.assert(false, &quot;Should not create a new StyleSheet, should reuse the existing one&quot;);
</span><span class="cx">             });
</span><del>-            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, function(styleSheet) {
</del><ins>+            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, (styleSheet) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, &quot;Should still be one stylesheet.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;StyleSheet origin should be 'inspector'.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="lines">@@ -57,13 +59,15 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CreateSubFrameInspectorStyleSheet&quot;,
</span><span class="cx">         description: &quot;First request for subframe should create inspector stylesheet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+        test(resolve, reject) {
+            WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;Added StyleSheet origin should be 'inspector'.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.parentFrame === childFrame, &quot;Added StyleSheet frame should be a child frame.&quot;);
</span><span class="cx">             });
</span><del>-            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, function(styleSheet) {
</del><ins>+
+            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, (styleSheet) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, &quot;Should be two stylesheets.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;StyleSheet origin should be 'inspector'.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="lines">@@ -75,11 +79,11 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;AnotherSubFrameRequestDoesNothing&quot;,
</span><span class="cx">         description: &quot;Second request for main frame should not create a new stylesheet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            let listener = WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+        test(resolve, reject) {
+            let listener = WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, (event) =&gt; {
</ins><span class="cx">                 InspectorTest.assert(false, &quot;Should not create a new StyleSheet, should reuse the existing one&quot;);
</span><span class="cx">             });
</span><del>-            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, function(styleSheet) {
</del><ins>+            WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, (styleSheet) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, &quot;Should be two stylesheets.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;StyleSheet origin should be 'inspector'.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), &quot;StyleSheet.isInspectorStyleSheet() should be true.&quot;);
</span><span class="lines">@@ -89,7 +93,8 @@
</span><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+    WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+    .then((event) =&gt; {
</ins><span class="cx">         InspectorTest.assert(false, &quot;Should not be removing any StyleSheets in this test.&quot;);
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssstylesheeteventsbasichtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/stylesheet-events-basic.html (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/stylesheet-events-basic.html        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/stylesheet-events-basic.html        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckNoStyleSheets&quot;,
</span><span class="cx">         description: &quot;Ensure there are currently no stylesheets.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, &quot;Should be no stylesheets.&quot;);
</span><span class="cx">             resolve();
</span><span class="cx">         }
</span><span class="lines">@@ -66,15 +66,17 @@
</span><span class="cx"> 
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name: `Add${title}`,
</span><del>-            test: (resolve, reject) =&gt; {
-                InspectorTest.evaluateInPage(addExpression);
-                WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+            test(resolve, reject) {
+                WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+                .then((event) =&gt; {
</ins><span class="cx">                     addedStyleSheet = event.data.styleSheet;
</span><span class="cx">                     InspectorTest.expectThat(addedStyleSheet instanceof WebInspector.CSSStyleSheet, &quot;StyleSheetAdded event should fire.&quot;);
</span><span class="cx">                     if (checkStyleSheetRemovedCallback)
</span><span class="cx">                         checkStyleSheetAddedCallback(addedStyleSheet);
</span><del>-                    resolve();
-                });
</del><ins>+                })
+                .then(resolve, reject);
+
+                InspectorTest.evaluateInPage(addExpression);
</ins><span class="cx">             }
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="lines">@@ -81,13 +83,15 @@
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name: `Disable${title}`,
</span><span class="cx">             description: &quot;Disable the newly added stylesheet.&quot;,
</span><del>-            test: (resolve, reject) =&gt; {
-                InspectorTest.evaluateInPage(&quot;disableStyleSheet()&quot;);
-                WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+            test(resolve, reject) {
+                WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+                .then((event) =&gt; {
</ins><span class="cx">                     InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, &quot;Event data should be a CSSStyleSheet&quot;);
</span><span class="cx">                     InspectorTest.expectThat(addedStyleSheet === event.data.styleSheet, &quot;StyleSheetRemoved event should fire for the same CSSStyleSheet.&quot;);
</span><del>-                    resolve();
-                });
</del><ins>+                })
+                .then(resolve, reject);
+
+                InspectorTest.evaluateInPage(&quot;disableStyleSheet()&quot;);
</ins><span class="cx">             }
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="lines">@@ -94,14 +98,16 @@
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name: `Enable${title}`,
</span><span class="cx">             description: &quot;Enable the just disabled stylesheet.&quot;,
</span><del>-            test: (resolve, reject) =&gt; {
-                InspectorTest.evaluateInPage(&quot;enableStyleSheet()&quot;);
-                WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+            test(resolve, reject) {
+                WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+                .then((event) =&gt; {
</ins><span class="cx">                     InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, &quot;Event data should be a CSSStyleSheet&quot;);
</span><span class="cx">                     InspectorTest.expectThat(addedStyleSheet !== event.data.styleSheet, &quot;StyleSheetAdded event should fire with a new CSSStyleSheet.&quot;);
</span><span class="cx">                     addedStyleSheet = event.data.styleSheet;
</span><del>-                    resolve();
-                });
</del><ins>+                })
+                .then(resolve, reject);
+
+                InspectorTest.evaluateInPage(&quot;enableStyleSheet()&quot;);
</ins><span class="cx">             }
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="lines">@@ -111,26 +117,30 @@
</span><span class="cx"> 
</span><span class="cx">             suite.addTestCase({
</span><span class="cx">                 name: extraDisableTitle,
</span><del>-                test: (resolve, reject) =&gt; {
-                    InspectorTest.evaluateInPage(extraDisableExpression);
-                    WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+                test(resolve, reject) {
+                    WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+                    .then((event) =&gt; {
</ins><span class="cx">                         InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, &quot;Event data should be a CSSStyleSheet&quot;);
</span><span class="cx">                         InspectorTest.expectThat(addedStyleSheet === event.data.styleSheet, &quot;StyleSheetRemoved event should fire for the same CSSStyleSheet.&quot;);
</span><del>-                        resolve();
-                    });
</del><ins>+                    })
+                    .then(resolve, reject);
+
+                    InspectorTest.evaluateInPage(extraDisableExpression);
</ins><span class="cx">                 }
</span><span class="cx">             });
</span><span class="cx"> 
</span><span class="cx">             suite.addTestCase({
</span><span class="cx">                 name: extraEnableTitle,
</span><del>-                test: (resolve, reject) =&gt; {
-                    InspectorTest.evaluateInPage(extraEnableExpression);
-                    WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+                test(resolve, reject) {
+                    WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+                    .then((event) =&gt; {
</ins><span class="cx">                         InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, &quot;Event data should be a CSSStyleSheet&quot;);
</span><span class="cx">                         InspectorTest.expectThat(addedStyleSheet !== event.data.styleSheet, &quot;StyleSheetAdded event should fire with a new CSSStyleSheet.&quot;);
</span><span class="cx">                         addedStyleSheet = event.data.styleSheet;
</span><del>-                        resolve();
-                    });
</del><ins>+                    })
+                    .then(resolve, reject);
+
+                    InspectorTest.evaluateInPage(extraEnableExpression);
</ins><span class="cx">                 }
</span><span class="cx">             });
</span><span class="cx">         }
</span><span class="lines">@@ -137,15 +147,17 @@
</span><span class="cx"> 
</span><span class="cx">         suite.addTestCase({
</span><span class="cx">             name: `Remove${title}`,
</span><del>-            test: (resolve, reject) =&gt; {
-                InspectorTest.evaluateInPage(removeExpression);
-                WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+            test(resolve, reject) {
+                WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+                .then((event) =&gt; {
</ins><span class="cx">                     InspectorTest.expectThat(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, &quot;StyleSheetAdded event should fire.&quot;);
</span><span class="cx">                     if (checkStyleSheetRemovedCallback)
</span><span class="cx">                         checkStyleSheetRemovedCallback(event.data.styleSheet);
</span><span class="cx">                     addedStyleSheet = null;
</span><del>-                    resolve();
-                });
</del><ins>+                })
+                .then(resolve, reject);
+
+                InspectorTest.evaluateInPage(removeExpression);
</ins><span class="cx">             }
</span><span class="cx">         });
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssstylesheeteventsinspectorstylesheethtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/stylesheet-events-inspector-stylesheet.html (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/stylesheet-events-inspector-stylesheet.html        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/stylesheet-events-inspector-stylesheet.html        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckNoStyleSheets&quot;,
</span><span class="cx">         description: &quot;Ensure there are currently no stylesheets.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, &quot;Should be no stylesheets.&quot;);
</span><span class="cx">             resolve();
</span><span class="cx">         }
</span><span class="lines">@@ -19,14 +19,16 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CreateInspectorStyleSheet&quot;,
</span><span class="cx">         description: &quot;Creating an inspector stylesheet adds a stylesheet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            CSSAgent.createStyleSheet(WebInspector.frameResourceManager.mainFrame.id);
-            WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+        test(resolve, reject) {
+            WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, &quot;Should be one stylesheet.&quot;);
</span><span class="cx">                 InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, &quot;Event data should be a CSSStyleSheet&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, &quot;StyleSheet origin should be 'inspector'.&quot;);
</span><del>-                resolve();
-            });
</del><ins>+            })
+            .then(resolve, reject);
+
+            CSSAgent.createStyleSheet(WebInspector.frameResourceManager.mainFrame.id);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssstylesheeteventsmultipledocumentshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html (206132 => 206133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html        2016-09-19 23:46:59 UTC (rev 206132)
+++ trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html        2016-09-19 23:51:00 UTC (rev 206133)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/external.css&quot;&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> function addSubframe() {
</span><del>-    var iframe = document.createElement(&quot;iframe&quot;);
</del><ins>+    let iframe = document.createElement(&quot;iframe&quot;);
</ins><span class="cx">     iframe.id = &quot;subframe&quot;;
</span><span class="cx">     iframe.src = &quot;resources/stylesheet-events-subframe.html&quot;;
</span><span class="cx">     document.body.appendChild(iframe);
</span><span class="lines">@@ -22,8 +22,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function logStyleSheets() {
</span><del>-        WebInspector.cssStyleManager.styleSheets.sort((a, b) =&gt; a.url.localeCompare(b.url)).forEach(function(styleSheet) {
-            var frameString = styleSheet.parentFrame.id === WebInspector.frameResourceManager.mainFrame.id ? &quot;&lt;mainframe&gt;&quot; : &quot;&lt;childframe&gt;&quot;;
</del><ins>+        WebInspector.cssStyleManager.styleSheets.sort((a, b) =&gt; a.url.localeCompare(b.url)).forEach((styleSheet) =&gt; {
+            let frameString = styleSheet.parentFrame.id === WebInspector.frameResourceManager.mainFrame.id ? &quot;&lt;mainframe&gt;&quot; : &quot;&lt;childframe&gt;&quot;;
</ins><span class="cx">             InspectorTest.log(`URL: ${sanitizeURL(styleSheet.url)} ${frameString}`);
</span><span class="cx">         });
</span><span class="cx">     }
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckStyleSheets&quot;,
</span><span class="cx">         description: &quot;Ensure there is currently one stylesheet.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
</del><ins>+        test(resolve, reject) {
</ins><span class="cx">             InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, &quot;Should be one stylesheets.&quot;);
</span><span class="cx">             logStyleSheets();
</span><span class="cx">             resolve();
</span><span class="lines">@@ -43,14 +43,16 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckStyleSheetsAfterAddingSubframe&quot;,
</span><span class="cx">         description: &quot;Ensure subframe stylesheets are added.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            InspectorTest.evaluateInPage(&quot;addSubframe()&quot;);
-            WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+        test(resolve, reject) {
+            WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+            .then((event) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, &quot;Should be two stylesheets.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.parentFrame !== WebInspector.frameResourceManager.mainFrame.id, &quot;New StyleSheet is for a subframe&quot;);
</span><span class="cx">                 logStyleSheets();
</span><del>-                resolve();
-            });
</del><ins>+            })
+            .then(resolve, reject);
+
+            InspectorTest.evaluateInPage(&quot;addSubframe()&quot;);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -57,14 +59,16 @@
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;CheckStyleSheetsAfterRemovingSubframe&quot;,
</span><span class="cx">         description: &quot;Ensure subframe stylesheets are removed.&quot;,
</span><del>-        test: (resolve, reject) =&gt; {
-            InspectorTest.evaluateInPage(&quot;removeSubframe()&quot;);
-            WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+        test(resolve, reject) {
+            WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+            .then((event) =&gt; {
</ins><span class="cx">                 InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, &quot;Should be one stylesheet.&quot;);
</span><span class="cx">                 InspectorTest.expectThat(event.data.styleSheet.parentFrame !== WebInspector.frameResourceManager.mainFrame.id, &quot;Removed StyleSheet is for a subframe&quot;);
</span><span class="cx">                 logStyleSheets();
</span><del>-                resolve();
-            });
</del><ins>+            })
+            .then(resolve, reject);
+
+            InspectorTest.evaluateInPage(&quot;removeSubframe()&quot;);
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>