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> |
11 | 11 |
12 <link rel="stylesheet" href="resources/get-set-stylesheet-text.css"> | 12 <link rel="stylesheet" href="resources/get-set-stylesheet-text.css"> |
13 | 13 |
14 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 14 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
15 <script src="../../../http/tests/inspector/elements-test.js"></script> | 15 <script src="../../../http/tests/inspector/elements-test.js"></script> |
16 <script> | 16 <script> |
17 | 17 |
18 function test() | 18 function test() |
19 { | 19 { |
20 var foundStyleSheetHeader; | 20 var foundStyleSheetHeader; |
21 var foundStyleSheetText; | 21 var foundStyleSheetText; |
22 | 22 |
23 findStyleSheet(); | 23 findStyleSheet(); |
24 | 24 |
25 function findStyleSheet() | 25 function findStyleSheet() |
26 { | 26 { |
27 var styleSheetHeaders = WebInspector.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(callback); | 32 foundStyleSheetHeader.requestContent(callback); |
33 } | 33 } |
34 if (!foundStyleSheetHeader) | 34 if (!foundStyleSheetHeader) |
35 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleMode
l.Events.StyleSheetAdded, styleSheetAdded); | 35 InspectorTest.cssModel.addEventListener(WebInspector.CSSStyleMod
el.Events.StyleSheetAdded, 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 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel
.Events.StyleSheetAdded, styleSheetAdded); | 46 InspectorTest.cssModel.removeEventListener(WebInspector.CSSStyleMode
l.Events.StyleSheetAdded, 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 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events
.StyleSheetChanged, next, this); | 63 InspectorTest.cssModel.addEventListener(WebInspector.CSSStyleModel.Event
s.StyleSheetChanged, next, this); |
64 WebInspector.cssModel.setStyleSheetText(foundStyleSheetHeader.id, "h1 {
COLOR: Red; }", true, callback); | 64 InspectorTest.cssModel.setStyleSheetText(foundStyleSheetHeader.id, "h1 {
COLOR: Red; }", true, callback); |
65 } | 65 } |
66 | 66 |
67 function testNewElementStyles() | 67 function testNewElementStyles() |
68 { | 68 { |
69 function callback(error, matchedCSSRules) | 69 function callback(error, matchedCSSRules) |
70 { | 70 { |
71 if (error) { | 71 if (error) { |
72 InspectorTest.addResult("error: " + error); | 72 InspectorTest.addResult("error: " + error); |
73 return; | 73 return; |
74 } | 74 } |
(...skipping 37 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 |