| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/elements-test.js"></script> |
| 5 <style> |
| 6 div { color: red; } |
| 7 /*# sourceURL=set-style.css */ |
| 8 </style> |
| 9 |
| 10 <style> |
| 11 div {} |
| 12 /*# sourceURL=set-selector.css */ |
| 13 </style> |
| 14 |
| 15 <style> |
| 16 @media (all) { } |
| 17 /*# sourceURL=set-media.css */ |
| 18 </style> |
| 19 |
| 20 <style> |
| 21 @keyframes animation { 100% { color: red; } } |
| 22 /*# sourceURL=set-keyframe-key.css */ |
| 23 </style> |
| 24 |
| 25 <style> |
| 26 div {} |
| 27 /*# sourceURL=add-rule.css */ |
| 28 </style> |
| 29 |
| 30 <style> |
| 31 div {} |
| 32 /*# sourceURL=set-text.css */ |
| 33 </style> |
| 34 |
| 35 <script> |
| 36 |
| 37 function test() |
| 38 { |
| 39 var headers = InspectorTest.cssModel.styleSheetHeaders(); |
| 40 InspectorTest.runTestSuite([ |
| 41 function testSetStyle(next) |
| 42 { |
| 43 var header = headers.find(header => header.sourceURL.endsWith("set-s
tyle.css")); |
| 44 InspectorTest.cssModel.setStyleText(header.id, new WebInspector.Text
Range(1, 5, 1, 18), "EDITED: EDITED", true) |
| 45 .then(success => onEdit(header, success)) |
| 46 .then(next); |
| 47 }, |
| 48 |
| 49 function testSetSelector(next) |
| 50 { |
| 51 var header = headers.find(header => header.sourceURL.endsWith("set-s
elector.css")); |
| 52 InspectorTest.cssModel.setSelectorText(header.id, new WebInspector.T
extRange(1, 0, 1, 3), "EDITED") |
| 53 .then(success => onEdit(header, success)) |
| 54 .then(next); |
| 55 }, |
| 56 |
| 57 function testSetMedia(next) |
| 58 { |
| 59 var header = headers.find(header => header.sourceURL.endsWith("set-m
edia.css")); |
| 60 InspectorTest.cssModel.setMediaText(header.id, new WebInspector.Text
Range(1, 7, 1, 12), "EDITED") |
| 61 .then(success => onEdit(header, success)) |
| 62 .then(next); |
| 63 }, |
| 64 |
| 65 function testSetKeyframeKey(next) |
| 66 { |
| 67 var header = headers.find(header => header.sourceURL.endsWith("set-k
eyframe-key.css")); |
| 68 InspectorTest.cssModel.setKeyframeKey(header.id, new WebInspector.Te
xtRange(1, 23, 1, 27), "from") |
| 69 .then(success => onEdit(header, success)) |
| 70 .then(next); |
| 71 }, |
| 72 |
| 73 function testAddRule(next) |
| 74 { |
| 75 var header = headers.find(header => header.sourceURL.endsWith("add-r
ule.css")); |
| 76 InspectorTest.cssModel.addRule(header.id, "EDITED {}\n", new WebInsp
ector.TextRange(1, 0, 1, 0)) |
| 77 .then(success => onEdit(header, success)) |
| 78 .then(next); |
| 79 }, |
| 80 |
| 81 function testSetStyleSheetText(next) |
| 82 { |
| 83 var header = headers.find(header => header.sourceURL.endsWith("set-t
ext.css")); |
| 84 InspectorTest.cssModel.setStyleSheetText(header.id, "EDITED {}", tru
e) |
| 85 .then(success => onEdit(header, success)) |
| 86 .then(next); |
| 87 }, |
| 88 ]); |
| 89 |
| 90 function onEdit(header, success) |
| 91 { |
| 92 if (success !== null && !success) { |
| 93 InspectorTest.addResult("Failed to run edit operation."); |
| 94 InspectorTest.completeTest(); |
| 95 return; |
| 96 } |
| 97 var contents = [ |
| 98 header.originalContentProvider().requestContent(), |
| 99 header.requestContent(), |
| 100 ]; |
| 101 return Promise.all(contents) |
| 102 .then(onContents); |
| 103 } |
| 104 |
| 105 function onContents(contents) |
| 106 { |
| 107 InspectorTest.addResult("== Original =="); |
| 108 InspectorTest.addResult(contents[0].trim()); |
| 109 InspectorTest.addResult("== Current =="); |
| 110 InspectorTest.addResult(contents[1].trim()); |
| 111 } |
| 112 } |
| 113 |
| 114 </script> |
| 115 </head> |
| 116 |
| 117 <body onload="runTest()"> |
| 118 <p>Verifies that CSSStyleSheetHeader.originalContentProvider() indeed returns or
iginal content.</p> |
| 119 |
| 120 <div id="inspected"></div> |
| 121 |
| 122 </body> |
| 123 </html> |
| OLD | NEW |