| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <link rel="stylesheet" href="resources/set-style-text.css"/> |
| 4 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 5 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot
ocol-test.js"></script> |
| 6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot
ocol-test.js"></script> |
| 7 <script type="text/javascript"> |
| 8 function test() |
| 9 { |
| 10 var setStyleText; |
| 11 var verifyProtocolError; |
| 12 var dumpStyleSheet; |
| 13 var documentNodeId; |
| 14 var styleSheetId; |
| 15 |
| 16 InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| 17 |
| 18 function onDocumentNodeId(nodeId) |
| 19 { |
| 20 documentNodeId = nodeId; |
| 21 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| 22 InspectorTest.sendCommandOrDie("CSS.enable", {}); |
| 23 } |
| 24 |
| 25 function styleSheetAdded(result) |
| 26 { |
| 27 styleSheetId = result.params.header.styleSheetId; |
| 28 setStyleText = InspectorTest.setStyleText.bind(InspectorTest, styleSheet
Id, false); |
| 29 verifyProtocolError = InspectorTest.setStyleText.bind(InspectorTest, sty
leSheetId, true); |
| 30 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI
d); |
| 31 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); |
| 32 } |
| 33 |
| 34 function dumpAndNext(next) |
| 35 { |
| 36 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume
ntNodeId, "#test", InspectorTest.undoAndNext(next)); |
| 37 } |
| 38 |
| 39 function onInitialStyleSheetText(result) |
| 40 { |
| 41 InspectorTest.log("==== Initial style sheet text ===="); |
| 42 InspectorTest.log(result.text); |
| 43 InspectorTest.runTestSuite(testSuite); |
| 44 } |
| 45 |
| 46 var testSuite = [ |
| 47 function testBasicSetStyle(next) |
| 48 { |
| 49 setStyleText({ |
| 50 styleSheetId: styleSheetId, |
| 51 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, |
| 52 text: "\n content: 'EDITED';\n", |
| 53 }, dumpAndNext(next)); |
| 54 }, |
| 55 |
| 56 function testSetStylePoorContent(next) |
| 57 { |
| 58 verifyProtocolError({ |
| 59 styleSheetId: styleSheetId, |
| 60 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, |
| 61 text: "}", |
| 62 }, dumpAndNext(next)); |
| 63 }, |
| 64 |
| 65 function testSetStyleInMedia(next) |
| 66 { |
| 67 setStyleText({ |
| 68 styleSheetId: styleSheetId, |
| 69 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 70 text: "\n content: 'EDITED';\n color: red;\n
/** foo */\n ", |
| 71 }, dumpAndNext(next)); |
| 72 }, |
| 73 |
| 74 function testDeleteStyleBody(next) |
| 75 { |
| 76 setStyleText({ |
| 77 styleSheetId: styleSheetId, |
| 78 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 79 text: "", |
| 80 }, dumpAndNext(next)); |
| 81 }, |
| 82 |
| 83 function testSetStylePoorRange(next) |
| 84 { |
| 85 verifyProtocolError({ |
| 86 styleSheetId: styleSheetId, |
| 87 range: { startLine: 11, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 88 text: "\n content: 'EDITED';\n", |
| 89 }, dumpAndNext(next)); |
| 90 }, |
| 91 |
| 92 function testSetStyleOpenComment(next) |
| 93 { |
| 94 verifyProtocolError({ |
| 95 styleSheetId: styleSheetId, |
| 96 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 97 text: "\n content: 'EDITED'/* ;\n", |
| 98 }, dumpAndNext(next)); |
| 99 } |
| 100 ]; |
| 101 } |
| 102 |
| 103 </script> |
| 104 </head> |
| 105 <body onload="runTest();"> |
| 106 <p>The test verifies functionality of protocol method CSS.setStyleText.</p> |
| 107 <article id="test"></article> |
| 108 </body> |
| 109 </html> |
| OLD | NEW |