browser/devtools/styleinspector/test/browser_ruleview_add-property-and-reselect.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:7017618ecdb9
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
4
5 "use strict";
6
7 // Tests that adding properties to rules work and reselecting the element still
8 // show them
9
10 const TEST_URI = TEST_URL_ROOT + "doc_content_stylesheet.html";
11
12 let test = asyncTest(function*() {
13 yield addTab(TEST_URI);
14
15 let target = getNode("#target");
16
17 let {toolbox, inspector, view} = yield openRuleView();
18 yield selectNode(target, inspector);
19
20 info("Setting a font-weight property on all rules");
21 setPropertyOnAllRules(view);
22
23 info("Reselecting the element");
24 yield reselectElement(target, inspector);
25
26 checkPropertyOnAllRules(view);
27 });
28
29 function* reselectElement(node, inspector) {
30 yield selectNode(node.parentNode, inspector);
31 yield selectNode(node, inspector);
32 }
33
34 function setPropertyOnAllRules(view) {
35 for (let rule of view._elementStyle.rules) {
36 rule.editor.addProperty("font-weight", "bold", "");
37 }
38 }
39
40 function checkPropertyOnAllRules(view) {
41 for (let rule of view._elementStyle.rules) {
42 let lastRule = rule.textProps[rule.textProps.length - 1];
43
44 is(lastRule.name, "font-weight", "Last rule name is font-weight");
45 is(lastRule.value, "bold", "Last rule value is bold");
46 }
47 }

mercurial