OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <link rel="stylesheet" href="resources/set-style-text.css"/> | 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> | 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> | 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> | 6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot
ocol-test.js"></script> |
7 <script type="text/javascript"> | 7 <script type="text/javascript"> |
8 function test() | 8 function test() |
9 { | 9 { |
10 var styleSheetId; | 10 var styleSheetId; |
11 var documentNodeId; | 11 var documentNodeId; |
12 var setStyleText; | 12 var setStyleTexts; |
13 var verifyProtocolError; | 13 var verifyProtocolError; |
14 var dumpStyleSheet; | |
15 | 14 |
16 InspectorTest.sendCommandOrDie("DOM.enable", {}); | 15 InspectorTest.sendCommandOrDie("DOM.enable", {}); |
17 InspectorTest.sendCommandOrDie("CSS.enable", {}, cssWasEnabled); | 16 InspectorTest.sendCommandOrDie("CSS.enable", {}, cssWasEnabled); |
18 | 17 |
19 function cssWasEnabled() | 18 function cssWasEnabled() |
20 { | 19 { |
21 InspectorTest.sendCommandOrDie("DOM.getDocument", {}, onGotDocument); | 20 InspectorTest.sendCommandOrDie("DOM.getDocument", {}, onGotDocument); |
22 } | 21 } |
23 | 22 |
24 function onGotDocument(result) | 23 function onGotDocument(result) |
25 { | 24 { |
26 documentNodeId = result.root.nodeId; | 25 documentNodeId = result.root.nodeId; |
27 InspectorTest.sendCommandOrDie("DOM.querySelector", { nodeId: documentNo
deId, selector: "#inliner" }, onGotNode); | 26 InspectorTest.sendCommandOrDie("DOM.querySelector", { nodeId: documentNo
deId, selector: "#inliner" }, onGotNode); |
28 } | 27 } |
29 | 28 |
30 function onGotNode(node) | 29 function onGotNode(node) |
31 { | 30 { |
32 InspectorTest.sendCommandOrDie("CSS.getInlineStylesForNode", { nodeId: n
ode.nodeId }, onGotInlineStyles); | 31 InspectorTest.sendCommandOrDie("CSS.getInlineStylesForNode", { nodeId: n
ode.nodeId }, onGotInlineStyles); |
33 } | 32 } |
34 | 33 |
35 function onGotInlineStyles(result) | 34 function onGotInlineStyles(result) |
36 { | 35 { |
37 styleSheetId = result.inlineStyle.styleSheetId; | 36 styleSheetId = result.inlineStyle.styleSheetId; |
38 setStyleText = InspectorTest.setStyleText.bind(InspectorTest, styleSheet
Id, false); | 37 setStyleTexts = InspectorTest.setStyleTexts.bind(InspectorTest, styleShe
etId, false); |
39 verifyProtocolError = InspectorTest.setStyleText.bind(InspectorTest, sty
leSheetId, true); | 38 verifyProtocolError = InspectorTest.setStyleTexts.bind(InspectorTest, st
yleSheetId, true); |
40 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI
d); | |
41 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); | 39 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); |
42 } | 40 } |
43 | 41 |
44 function dumpAndNext(next) | 42 function dumpAndNext(next) |
45 { | 43 { |
46 return function() | 44 return function() |
47 { | 45 { |
48 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheet
Id: styleSheetId }, onReceiveStyleSheetText); | 46 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheet
Id: styleSheetId }, onReceiveStyleSheetText); |
49 | 47 |
50 function onReceiveStyleSheetText(result) | 48 function onReceiveStyleSheetText(result) |
51 { | 49 { |
52 InspectorTest.log("Stylesheet text: " + result.text); | 50 InspectorTest.log("Stylesheet text: " + result.text); |
53 InspectorTest.domUndo(next); | 51 InspectorTest.domUndo(next); |
54 } | 52 } |
55 } | 53 } |
56 } | 54 } |
57 | 55 |
58 function onInitialStyleSheetText(result) | 56 function onInitialStyleSheetText(result) |
59 { | 57 { |
60 InspectorTest.log("==== Initial style sheet text ===="); | 58 InspectorTest.log("==== Initial style sheet text ===="); |
61 InspectorTest.log(result.text); | 59 InspectorTest.log(result.text); |
62 InspectorTest.runTestSuite(testSuite); | 60 InspectorTest.runTestSuite(testSuite); |
63 } | 61 } |
64 | 62 |
65 var testSuite = [ | 63 var testSuite = [ |
66 function testBasicSetStyle(next) | 64 function testBasicSetStyle(next) |
67 { | 65 { |
68 setStyleText({ | 66 setStyleTexts([{ |
69 styleSheetId: styleSheetId, | 67 styleSheetId: styleSheetId, |
70 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, | 68 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, |
71 text: "content: 'EDITED'", | 69 text: "content: 'EDITED'", |
72 }, dumpAndNext(next)); | 70 }], dumpAndNext(next)); |
73 }, | 71 }, |
74 | 72 |
75 function testSetStylePoorContent(next) | 73 function testSetStylePoorContent(next) |
76 { | 74 { |
77 verifyProtocolError({ | 75 verifyProtocolError([{ |
78 styleSheetId: styleSheetId, | 76 styleSheetId: styleSheetId, |
79 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, | 77 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, |
80 text: "}", | 78 text: "}", |
81 }, dumpAndNext(next)); | 79 }], dumpAndNext(next)); |
82 }, | 80 }, |
83 | 81 |
84 function testDeleteStyleBody(next) | 82 function testDeleteStyleBody(next) |
85 { | 83 { |
86 setStyleText({ | 84 setStyleTexts([{ |
87 styleSheetId: styleSheetId, | 85 styleSheetId: styleSheetId, |
88 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, | 86 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, |
89 text: "", | 87 text: "", |
90 }, dumpAndNext(next)); | 88 }], dumpAndNext(next)); |
91 }, | 89 }, |
92 | 90 |
93 function testSetStyleOpenComment(next) | 91 function testSetStyleOpenComment(next) |
94 { | 92 { |
95 verifyProtocolError({ | 93 verifyProtocolError([{ |
96 styleSheetId: styleSheetId, | 94 styleSheetId: styleSheetId, |
97 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, | 95 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11
}, |
98 text: "/*", | 96 text: "/*", |
99 }, dumpAndNext(next)); | 97 }], dumpAndNext(next)); |
100 } | 98 } |
101 ]; | 99 ]; |
102 } | 100 } |
103 | 101 |
104 </script> | 102 </script> |
105 </head> | 103 </head> |
106 <body onload="runTest();"> | 104 <body onload="runTest();"> |
107 <p>The test verifies functionality of protocol method CSS.setStyleText for inlin
e elements.</p> | 105 <p>The test verifies functionality of protocol method CSS.setStyleTexts for inli
ne elements.</p> |
108 <div id="inliner" style="color: red;"> | 106 <div id="inliner" style="color: red;"> |
109 </body> | 107 </body> |
110 </html> | 108 </html> |
OLD | NEW |