Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: LayoutTests/inspector/styles/styles-test.js

Issue 148523012: DevTools: [CSS] remove getAllStylesheets method from protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/inspector/styles/styles-test.js
diff --git a/LayoutTests/inspector/styles/styles-test.js b/LayoutTests/inspector/styles/styles-test.js
new file mode 100644
index 0000000000000000000000000000000000000000..08223454d973bd984b19655dd47367163d56a828
--- /dev/null
+++ b/LayoutTests/inspector/styles/styles-test.js
@@ -0,0 +1,36 @@
+function initialize_StylesTests()
+{
+
+InspectorTest.waitForStylesheetsOnFrontend = function(styleSheetsAmount, callback)
apavlov 2014/01/29 14:08:57 |styleSheetsCount| will sound more common here
lushnikov 2014/01/29 18:21:46 Done.
+{
+ function styleSheetComparator(a, b)
+ {
+ if (a.sourceURL < b.sourceURL)
apavlov 2014/01/29 14:08:57 This can be written as: return a.sourceURL.locale
lushnikov 2014/01/29 18:21:46 Left as-is due to discussion offline
+ return -1;
+ else if (a.sourceURL > b.sourceURL)
+ return 1;
+ return a.startLine - b.startLine || a.startColumn - b.startColumn;
+ }
+
+ var styleSheets = WebInspector.cssModel.allStyleSheets();
+ if (styleSheets.length >= styleSheetsAmount) {
+ styleSheets.sort(styleSheetComparator);
+ callback(styleSheets);
+ return;
+ }
+
+ function onStyleSheetAdded()
+ {
+ var styleSheets = WebInspector.cssModel.allStyleSheets();
+ if (styleSheets.length < styleSheetsAmount)
+ return;
+
+ WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded, onStyleSheetAdded, this);
+ styleSheets.sort(styleSheetComparator);
+ callback(null, styleSheets);
+ }
+
+ WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded, onStyleSheetAdded, this);
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698