| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 | 3 |
| 4 <style> | 4 <style> |
| 5 | 5 |
| 6 /* An inline stylesheet */ | 6 /* An inline stylesheet */ |
| 7 body.mainpage { | 7 body.mainpage { |
| 8 text-decoration: none; | 8 text-decoration: none; |
| 9 } | 9 } |
| 10 </style> | 10 </style> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 function findStyleSheet() | 25 function findStyleSheet() |
| 26 { | 26 { |
| 27 var styleSheetHeaders = InspectorTest.cssModel.styleSheetHeaders(); | 27 var styleSheetHeaders = InspectorTest.cssModel.styleSheetHeaders(); |
| 28 for (var i = 0; i < styleSheetHeaders.length; ++i) { | 28 for (var i = 0; i < styleSheetHeaders.length; ++i) { |
| 29 styleSheetHeader = styleSheetHeaders[i]; | 29 styleSheetHeader = styleSheetHeaders[i]; |
| 30 if (styleSheetHeader.sourceURL.indexOf("get-set-stylesheet-text.css"
) >= 0) { | 30 if (styleSheetHeader.sourceURL.indexOf("get-set-stylesheet-text.css"
) >= 0) { |
| 31 foundStyleSheetHeader = styleSheetHeader; | 31 foundStyleSheetHeader = styleSheetHeader; |
| 32 foundStyleSheetHeader.requestContent().then(callback); | 32 foundStyleSheetHeader.requestContent().then(callback); |
| 33 } | 33 } |
| 34 if (!foundStyleSheetHeader) | 34 if (!foundStyleSheetHeader) |
| 35 InspectorTest.cssModel.addEventListener(WebInspector.CSSModel.Ev
ents.StyleSheetAdded, styleSheetAdded); | 35 InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.Styl
eSheetAdded, styleSheetAdded); |
| 36 } | 36 } |
| 37 | 37 |
| 38 function callback(content) | 38 function callback(content) |
| 39 { | 39 { |
| 40 foundStyleSheetText = content; | 40 foundStyleSheetText = content; |
| 41 InspectorTest.runTestSuite([ testSetText, testNewElementStyles ]); | 41 InspectorTest.runTestSuite([ testSetText, testNewElementStyles ]); |
| 42 } | 42 } |
| 43 | 43 |
| 44 function styleSheetAdded() | 44 function styleSheetAdded() |
| 45 { | 45 { |
| 46 InspectorTest.cssModel.removeEventListener(WebInspector.CSSModel.Eve
nts.StyleSheetAdded, styleSheetAdded); | 46 InspectorTest.cssModel.removeEventListener(SDK.CSSModel.Events.Style
SheetAdded, styleSheetAdded); |
| 47 findStyleSheet(); | 47 findStyleSheet(); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 function testSetText(next) | 51 function testSetText(next) |
| 52 { | 52 { |
| 53 function callback(error) | 53 function callback(error) |
| 54 { | 54 { |
| 55 if (error) { | 55 if (error) { |
| 56 InspectorTest.addResult("Failed to set stylesheet text: " + erro
r); | 56 InspectorTest.addResult("Failed to set stylesheet text: " + erro
r); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 InspectorTest.addResult("=== Original stylesheet text: ==="); | 61 InspectorTest.addResult("=== Original stylesheet text: ==="); |
| 62 InspectorTest.addResult(foundStyleSheetText); | 62 InspectorTest.addResult(foundStyleSheetText); |
| 63 InspectorTest.cssModel.addEventListener(WebInspector.CSSModel.Events.Sty
leSheetChanged, next, this); | 63 InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetCh
anged, next, this); |
| 64 InspectorTest.cssModel.setStyleSheetText(foundStyleSheetHeader.id, "h1 {
COLOR: Red; }", true).then(callback); | 64 InspectorTest.cssModel.setStyleSheetText(foundStyleSheetHeader.id, "h1 {
COLOR: Red; }", true).then(callback); |
| 65 } | 65 } |
| 66 | 66 |
| 67 function testNewElementStyles() | 67 function testNewElementStyles() |
| 68 { | 68 { |
| 69 function callback(error, inlineStyle, attributeStyle, matchedCSSRules) | 69 function callback(error, inlineStyle, attributeStyle, matchedCSSRules) |
| 70 { | 70 { |
| 71 if (error) { | 71 if (error) { |
| 72 InspectorTest.addResult("error: " + error); | 72 InspectorTest.addResult("error: " + error); |
| 73 return; | 73 return; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 </script> | 112 </script> |
| 113 </head> | 113 </head> |
| 114 | 114 |
| 115 <body onload="runTest()"> | 115 <body onload="runTest()"> |
| 116 <p> | 116 <p> |
| 117 Tests that WebInspector.CSSStyleSheet methods work as expected. | 117 Tests that WebInspector.CSSStyleSheet methods work as expected. |
| 118 </p> | 118 </p> |
| 119 <h1 id="inspected">Inspect Me</h1> | 119 <h1 id="inspected">Inspect Me</h1> |
| 120 </body> | 120 </body> |
| 121 </html> | 121 </html> |
| OLD | NEW |