/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-formatting.html

https://gitlab.com/jonnialva90/iridium-browser · HTML · 283 lines · 234 code · 49 blank · 0 comment · 0 complexity · 3a40409bcf1e64360d8f0652c3b3dfb0 MD5 · raw file

  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. <script>
  6. function test()
  7. {
  8. var formattedStyle;
  9. var unformattedStyle;
  10. InspectorTest.runTestSuite([
  11. function initFormattedStyle(next)
  12. {
  13. function callback(matchedResult)
  14. {
  15. if (!matchedResult) {
  16. InspectorTest.addResult("empty styles");
  17. InspectorTest.completeTest();
  18. return;
  19. }
  20. formattedStyle = matchedResult.nodeStyles()[1];
  21. next();
  22. }
  23. function nodeCallback(node)
  24. {
  25. InspectorTest.cssModel.matchedStylesPromise(node.id).then(callback);
  26. }
  27. InspectorTest.selectNodeWithId("formatted", nodeCallback);
  28. },
  29. function testFormattedInsertStart(next)
  30. {
  31. formattedStyle.insertPropertyAt(0, "firstProperty", "rgba(1, 2, 3, 0)", dumpFormattedAndCallNext.bind(null, next));
  32. },
  33. function testFormattedRemoveStart(next)
  34. {
  35. formattedStyle.allProperties[0].setText("", true, true)
  36. .then(dumpFormattedAndCallNext.bind(null, next));
  37. },
  38. function testFormattedInsertMiddle(next)
  39. {
  40. formattedStyle.insertPropertyAt(1, "middleProperty", "middleValue /* comment */", dumpFormattedAndCallNext.bind(null, next));
  41. },
  42. function testFormattedRemoveMiddle(next)
  43. {
  44. formattedStyle.allProperties[1].setText("", true, true)
  45. .then(dumpFormattedAndCallNext.bind(null, next));
  46. },
  47. function testFormattedInsertEnd(next)
  48. {
  49. formattedStyle.insertPropertyAt(3, "endProperty", "endValue", dumpFormattedAndCallNext.bind(null, next));
  50. },
  51. function testFormattedRemoveEnd(next)
  52. {
  53. formattedStyle.allProperties[3].setText("", true, true)
  54. .then(dumpFormattedAndCallNext.bind(null, next));
  55. },
  56. function testFormattedDisableStart(next)
  57. {
  58. formattedStyle.allProperties[0].setDisabled(true)
  59. .then(dumpFormattedAndCallNext.bind(null, next));
  60. },
  61. function testFormattedDisableEnd(next)
  62. {
  63. formattedStyle.allProperties[2].setDisabled(true)
  64. .then(dumpFormattedAndCallNext.bind(null, next));
  65. },
  66. function testFormattedDisableMiddle(next)
  67. {
  68. formattedStyle.allProperties[1].setDisabled(true)
  69. .then(dumpFormattedAndCallNext.bind(null, next));
  70. },
  71. function testFormattedInsert1(next)
  72. {
  73. formattedStyle.insertPropertyAt(0, "propA", "valA", dumpFormattedAndCallNext.bind(null, next));
  74. },
  75. function testFormattedInsert2(next)
  76. {
  77. formattedStyle.insertPropertyAt(2, "propB", "valB", dumpFormattedAndCallNext.bind(null, next));
  78. },
  79. function testFormattedInsert3(next)
  80. {
  81. formattedStyle.insertPropertyAt(5, "propC", "valC", dumpFormattedAndCallNext.bind(null, next));
  82. },
  83. function testFormattedEnableStart(next)
  84. {
  85. formattedStyle.allProperties[1].setDisabled(false)
  86. .then(dumpFormattedAndCallNext.bind(null, next));
  87. },
  88. function testFormattedEnableEnd(next)
  89. {
  90. formattedStyle.allProperties[4].setDisabled(false)
  91. .then(dumpFormattedAndCallNext.bind(null, next));
  92. },
  93. function testFormattedEnableMiddle(next)
  94. {
  95. formattedStyle.allProperties[3].setDisabled(false)
  96. .then(dumpFormattedAndCallNext.bind(null, next));
  97. },
  98. function testFormattedWithMeta(next)
  99. {
  100. formattedStyle.insertPropertyAt(0, "-webkit-animation", "linear", dumpFormattedAndCallNext.bind(null, next));
  101. },
  102. function testFormattedWithMetaValue(next)
  103. {
  104. formattedStyle.insertPropertyAt(1, "unicode-bidi", "webkit-isolate", dumpFormattedAndCallNext.bind(null, next));
  105. },
  106. function testFormattedWithAtoms(next)
  107. {
  108. formattedStyle.insertPropertyAt(0, "border-left", "1px solid rgb(1,1,1)", dumpFormattedAndCallNext.bind(null, next));
  109. },
  110. function initUnformattedStyle(next)
  111. {
  112. function callback(matchedResult)
  113. {
  114. if (!matchedResult) {
  115. InspectorTest.addResult("empty styles");
  116. InspectorTest.completeTest();
  117. return;
  118. }
  119. unformattedStyle = matchedResult.nodeStyles()[1];
  120. next();
  121. }
  122. function nodeCallback(node)
  123. {
  124. InspectorTest.cssModel.matchedStylesPromise(node.id).then(callback);
  125. }
  126. InspectorTest.selectNodeWithId("unformatted", nodeCallback);
  127. },
  128. function testUnformattedInsertStart(next)
  129. {
  130. unformattedStyle.insertPropertyAt(0, "firstProperty", "firstValue", dumpUnformattedAndCallNext.bind(null, next));
  131. },
  132. function testUnformattedRemoveStart(next)
  133. {
  134. unformattedStyle.allProperties[0].setText("", true, true)
  135. .then(dumpUnformattedAndCallNext.bind(null, next));
  136. },
  137. function testUnformattedInsertMiddle(next)
  138. {
  139. unformattedStyle.insertPropertyAt(1, "middleProperty", "middleValue", dumpUnformattedAndCallNext.bind(null, next));
  140. },
  141. function testUnformattedRemoveMiddle(next)
  142. {
  143. unformattedStyle.allProperties[1].setText("", true, true)
  144. .then(dumpUnformattedAndCallNext.bind(null, next));
  145. },
  146. function testUnformattedInsertEnd(next)
  147. {
  148. unformattedStyle.insertPropertyAt(3, "endProperty", "endValue", dumpUnformattedAndCallNext.bind(null, next));
  149. },
  150. function testUnformattedRemoveEnd(next)
  151. {
  152. unformattedStyle.allProperties[3].setText("", true, true)
  153. .then(dumpUnformattedAndCallNext.bind(null, next));
  154. },
  155. function testUnformattedDisableStart(next)
  156. {
  157. unformattedStyle.allProperties[0].setDisabled(true)
  158. .then(dumpUnformattedAndCallNext.bind(null, next));
  159. },
  160. function testUnformattedDisableEnd(next)
  161. {
  162. unformattedStyle.allProperties[2].setDisabled(true)
  163. .then(dumpUnformattedAndCallNext.bind(null, next));
  164. },
  165. function testUnformattedDisableMiddle(next)
  166. {
  167. unformattedStyle.allProperties[1].setDisabled(true)
  168. .then(dumpUnformattedAndCallNext.bind(null, next));
  169. },
  170. function testUnformattedEnableStart(next)
  171. {
  172. unformattedStyle.allProperties[0].setDisabled(false)
  173. .then(dumpUnformattedAndCallNext.bind(null, next));
  174. },
  175. function testUnformattedEnableEnd(next)
  176. {
  177. unformattedStyle.allProperties[2].setDisabled(false)
  178. .then(dumpUnformattedAndCallNext.bind(null, next));
  179. },
  180. function testUnformattedEnableMiddle(next)
  181. {
  182. unformattedStyle.allProperties[1].setDisabled(false)
  183. .then(dumpUnformattedAndCallNext.bind(null, next));
  184. }
  185. ]);
  186. // Data dumping
  187. function dumpFormattedAndCallNext(next, success)
  188. {
  189. if (!success) {
  190. InspectorTest.addResult("error: operation failed.");
  191. InspectorTest.completeTest();
  192. return;
  193. }
  194. dumpStyle(formattedStyle);
  195. if (next)
  196. next();
  197. }
  198. function dumpUnformattedAndCallNext(next, success)
  199. {
  200. if (!success) {
  201. InspectorTest.addResult("error: operation failed.");
  202. InspectorTest.completeTest();
  203. return;
  204. }
  205. dumpStyle(unformattedStyle);
  206. if (next)
  207. next();
  208. }
  209. function dumpStyle(style)
  210. {
  211. if (!style)
  212. return;
  213. InspectorTest.addResult("raw cssText:");
  214. InspectorTest.addResult("{" + style.cssText + "}");
  215. }
  216. }
  217. </script>
  218. <style>
  219. #formatted {
  220. property1: value1;
  221. property2: value2;
  222. property3: value3
  223. }
  224. #unformatted {property1:value1;property2:value2;property3:value3;}
  225. </style>
  226. </head>
  227. <body id="mainBody" onload="runTest()">
  228. <p>
  229. Tests that InspectorCSSAgent formats the CSS style text based on the CSS model modifications.
  230. </p>
  231. <div id="formatted">Formatted</div>
  232. <div id="unformatted">Unformatted</div>
  233. </body>
  234. </html>