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