Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 function initialize_StylesTests() | |
| 2 { | |
| 3 | |
| 4 InspectorTest.waitForStylesheetsOnFrontend = function(styleSheetsAmount, callbac k) | |
|
apavlov
2014/01/29 14:08:57
|styleSheetsCount| will sound more common here
lushnikov
2014/01/29 18:21:46
Done.
| |
| 5 { | |
| 6 function styleSheetComparator(a, b) | |
| 7 { | |
| 8 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
| |
| 9 return -1; | |
| 10 else if (a.sourceURL > b.sourceURL) | |
| 11 return 1; | |
| 12 return a.startLine - b.startLine || a.startColumn - b.startColumn; | |
| 13 } | |
| 14 | |
| 15 var styleSheets = WebInspector.cssModel.allStyleSheets(); | |
| 16 if (styleSheets.length >= styleSheetsAmount) { | |
| 17 styleSheets.sort(styleSheetComparator); | |
| 18 callback(styleSheets); | |
| 19 return; | |
| 20 } | |
| 21 | |
| 22 function onStyleSheetAdded() | |
| 23 { | |
| 24 var styleSheets = WebInspector.cssModel.allStyleSheets(); | |
| 25 if (styleSheets.length < styleSheetsAmount) | |
| 26 return; | |
| 27 | |
| 28 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Eve nts.StyleSheetAdded, onStyleSheetAdded, this); | |
| 29 styleSheets.sort(styleSheetComparator); | |
| 30 callback(null, styleSheets); | |
| 31 } | |
| 32 | |
| 33 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty leSheetAdded, onStyleSheetAdded, this); | |
| 34 } | |
| 35 | |
| 36 } | |
| OLD | NEW |