<!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 <dcrousso+webkit@gmail.com> 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 <dcrousso+webkit@gmail.com>
+
+ 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 <cdumez@apple.com>
</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: "CheckNoStyleSheets",
</span><span class="cx"> description: "Ensure there are no stylesheets.",
</span><del>- test: (resolve, reject) => {
</del><ins>+ test(resolve, reject) {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, "Should be no stylesheets.");
</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: "CreateInspectorStyleSheetCall" + i,
</span><span class="cx"> description: "Should create a new inspector stylesheet.",
</span><del>- test: (resolve, reject) => {
- 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) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === i, "Should increase the list of stylesheets.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "Added StyleSheet origin should be 'inspector'.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</span><span class="lines">@@ -33,14 +33,17 @@
</span><span class="cx"> if (addedStyleSheet)
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet !== addedStyleSheet, "Added StyleSheet should be different from the last added stylesheet.");
</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, "Should not be removing any StyleSheets in this test.");
</del><ins>+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+ .then((event) => {
+ InspectorTest.fail("Should not be removing any StyleSheets in this test.");
</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: "InlineStyleString",
</span><span class="cx"> description: "Check the formatting of the generated inline style string.",
</span><del>- test: (resolve, reject) => {
</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: "CSSRuleString" + i,
</span><span class="cx"> description: "Check the formatting of the generated string for the matched CSS rule.",
</span><del>- test: (resolve, reject) => {
</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, "#test-node", 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) => {
+ WebInspector.domTreeManager.querySelector(documentNode.id, "#test-node", (contentNodeId) => {
+ if (!contentNodeId) {
</ins><span class="cx"> InspectorTest.log("DOM node not found.");
</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: "CheckNoStyleSheets",
</span><span class="cx"> description: "Ensure there are no stylesheets.",
</span><del>- test: (resolve, reject) => {
</del><ins>+ test(resolve, reject) {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, "Should be no stylesheets.");
</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: "CreateMainFrameInspectorStyleSheet",
</span><span class="cx"> description: "First request for main frame should create inspector stylesheet.",
</span><del>- test: (resolve, reject) => {
- WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+ test(resolve, reject) {
+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+ .then((event) => {
</ins><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "Added StyleSheet origin should be 'inspector'.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.parentFrame === mainFrame, "Added StyleSheet frame should be the main frame.");
</span><span class="cx"> });
</span><del>- WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, function(styleSheet) {
</del><ins>+
+ WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, (styleSheet) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, "Should be one stylesheet.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin is inspector.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</span><span class="lines">@@ -40,11 +42,11 @@
</span><span class="cx"> suite.addTestCase({
</span><span class="cx"> name: "AnotherMainFrameRequestDoesNothing",
</span><span class="cx"> description: "Second request for main frame should not create a new stylesheet.",
</span><del>- test: (resolve, reject) => {
- 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) => {
</ins><span class="cx"> InspectorTest.assert(false, "Should not create a new StyleSheet, should reuse the existing one");
</span><span class="cx"> });
</span><del>- WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, function(styleSheet) {
</del><ins>+ WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(mainFrame, (styleSheet) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, "Should still be one stylesheet.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin should be 'inspector'.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</span><span class="lines">@@ -57,13 +59,15 @@
</span><span class="cx"> suite.addTestCase({
</span><span class="cx"> name: "CreateSubFrameInspectorStyleSheet",
</span><span class="cx"> description: "First request for subframe should create inspector stylesheet.",
</span><del>- test: (resolve, reject) => {
- WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+ test(resolve, reject) {
+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+ .then((event) => {
</ins><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "Added StyleSheet origin should be 'inspector'.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.parentFrame === childFrame, "Added StyleSheet frame should be a child frame.");
</span><span class="cx"> });
</span><del>- WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, function(styleSheet) {
</del><ins>+
+ WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, (styleSheet) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, "Should be two stylesheets.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin should be 'inspector'.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</span><span class="lines">@@ -75,11 +79,11 @@
</span><span class="cx"> suite.addTestCase({
</span><span class="cx"> name: "AnotherSubFrameRequestDoesNothing",
</span><span class="cx"> description: "Second request for main frame should not create a new stylesheet.",
</span><del>- test: (resolve, reject) => {
- 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) => {
</ins><span class="cx"> InspectorTest.assert(false, "Should not create a new StyleSheet, should reuse the existing one");
</span><span class="cx"> });
</span><del>- WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, function(styleSheet) {
</del><ins>+ WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, (styleSheet) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, "Should be two stylesheets.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin should be 'inspector'.");
</span><span class="cx"> InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
</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) => {
</ins><span class="cx"> InspectorTest.assert(false, "Should not be removing any StyleSheets in this test.");
</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: "CheckNoStyleSheets",
</span><span class="cx"> description: "Ensure there are currently no stylesheets.",
</span><del>- test: (resolve, reject) => {
</del><ins>+ test(resolve, reject) {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, "Should be no stylesheets.");
</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) => {
- 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) => {
</ins><span class="cx"> addedStyleSheet = event.data.styleSheet;
</span><span class="cx"> InspectorTest.expectThat(addedStyleSheet instanceof WebInspector.CSSStyleSheet, "StyleSheetAdded event should fire.");
</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: "Disable the newly added stylesheet.",
</span><del>- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("disableStyleSheet()");
- WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+ test(resolve, reject) {
+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+ .then((event) => {
</ins><span class="cx"> InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, "Event data should be a CSSStyleSheet");
</span><span class="cx"> InspectorTest.expectThat(addedStyleSheet === event.data.styleSheet, "StyleSheetRemoved event should fire for the same CSSStyleSheet.");
</span><del>- resolve();
- });
</del><ins>+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("disableStyleSheet()");
</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: "Enable the just disabled stylesheet.",
</span><del>- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("enableStyleSheet()");
- WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+ test(resolve, reject) {
+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+ .then((event) => {
</ins><span class="cx"> InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, "Event data should be a CSSStyleSheet");
</span><span class="cx"> InspectorTest.expectThat(addedStyleSheet !== event.data.styleSheet, "StyleSheetAdded event should fire with a new CSSStyleSheet.");
</span><span class="cx"> addedStyleSheet = event.data.styleSheet;
</span><del>- resolve();
- });
</del><ins>+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("enableStyleSheet()");
</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) => {
- 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) => {
</ins><span class="cx"> InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, "Event data should be a CSSStyleSheet");
</span><span class="cx"> InspectorTest.expectThat(addedStyleSheet === event.data.styleSheet, "StyleSheetRemoved event should fire for the same CSSStyleSheet.");
</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) => {
- 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) => {
</ins><span class="cx"> InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, "Event data should be a CSSStyleSheet");
</span><span class="cx"> InspectorTest.expectThat(addedStyleSheet !== event.data.styleSheet, "StyleSheetAdded event should fire with a new CSSStyleSheet.");
</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) => {
- 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) => {
</ins><span class="cx"> InspectorTest.expectThat(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, "StyleSheetAdded event should fire.");
</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: "CheckNoStyleSheets",
</span><span class="cx"> description: "Ensure there are currently no stylesheets.",
</span><del>- test: (resolve, reject) => {
</del><ins>+ test(resolve, reject) {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 0, "Should be no stylesheets.");
</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: "CreateInspectorStyleSheet",
</span><span class="cx"> description: "Creating an inspector stylesheet adds a stylesheet.",
</span><del>- test: (resolve, reject) => {
- 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) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, "Should be one stylesheet.");
</span><span class="cx"> InspectorTest.assert(event.data.styleSheet instanceof WebInspector.CSSStyleSheet, "Event data should be a CSSStyleSheet");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin should be 'inspector'.");
</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"> <link rel="stylesheet" href="resources/external.css">
</span><span class="cx"> <script>
</span><span class="cx"> function addSubframe() {
</span><del>- var iframe = document.createElement("iframe");
</del><ins>+ let iframe = document.createElement("iframe");
</ins><span class="cx"> iframe.id = "subframe";
</span><span class="cx"> iframe.src = "resources/stylesheet-events-subframe.html";
</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) => a.url.localeCompare(b.url)).forEach(function(styleSheet) {
- var frameString = styleSheet.parentFrame.id === WebInspector.frameResourceManager.mainFrame.id ? "<mainframe>" : "<childframe>";
</del><ins>+ WebInspector.cssStyleManager.styleSheets.sort((a, b) => a.url.localeCompare(b.url)).forEach((styleSheet) => {
+ let frameString = styleSheet.parentFrame.id === WebInspector.frameResourceManager.mainFrame.id ? "<mainframe>" : "<childframe>";
</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: "CheckStyleSheets",
</span><span class="cx"> description: "Ensure there is currently one stylesheet.",
</span><del>- test: (resolve, reject) => {
</del><ins>+ test(resolve, reject) {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, "Should be one stylesheets.");
</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: "CheckStyleSheetsAfterAddingSubframe",
</span><span class="cx"> description: "Ensure subframe stylesheets are added.",
</span><del>- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("addSubframe()");
- WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, function(event) {
</del><ins>+ test(resolve, reject) {
+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetAdded)
+ .then((event) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, "Should be two stylesheets.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.parentFrame !== WebInspector.frameResourceManager.mainFrame.id, "New StyleSheet is for a subframe");
</span><span class="cx"> logStyleSheets();
</span><del>- resolve();
- });
</del><ins>+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("addSubframe()");
</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: "CheckStyleSheetsAfterRemovingSubframe",
</span><span class="cx"> description: "Ensure subframe stylesheets are removed.",
</span><del>- test: (resolve, reject) => {
- InspectorTest.evaluateInPage("removeSubframe()");
- WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetRemoved, function(event) {
</del><ins>+ test(resolve, reject) {
+ WebInspector.cssStyleManager.awaitEvent(WebInspector.CSSStyleManager.Event.StyleSheetRemoved)
+ .then((event) => {
</ins><span class="cx"> InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 1, "Should be one stylesheet.");
</span><span class="cx"> InspectorTest.expectThat(event.data.styleSheet.parentFrame !== WebInspector.frameResourceManager.mainFrame.id, "Removed StyleSheet is for a subframe");
</span><span class="cx"> logStyleSheets();
</span><del>- resolve();
- });
</del><ins>+ })
+ .then(resolve, reject);
+
+ InspectorTest.evaluateInPage("removeSubframe()");
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>