michael@0: /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Tests that adding properties to rules work and reselecting the element still michael@0: // show them michael@0: michael@0: const TEST_URI = TEST_URL_ROOT + "doc_content_stylesheet.html"; michael@0: michael@0: let test = asyncTest(function*() { michael@0: yield addTab(TEST_URI); michael@0: michael@0: let target = getNode("#target"); michael@0: michael@0: let {toolbox, inspector, view} = yield openRuleView(); michael@0: yield selectNode(target, inspector); michael@0: michael@0: info("Setting a font-weight property on all rules"); michael@0: setPropertyOnAllRules(view); michael@0: michael@0: info("Reselecting the element"); michael@0: yield reselectElement(target, inspector); michael@0: michael@0: checkPropertyOnAllRules(view); michael@0: }); michael@0: michael@0: function* reselectElement(node, inspector) { michael@0: yield selectNode(node.parentNode, inspector); michael@0: yield selectNode(node, inspector); michael@0: } michael@0: michael@0: function setPropertyOnAllRules(view) { michael@0: for (let rule of view._elementStyle.rules) { michael@0: rule.editor.addProperty("font-weight", "bold", ""); michael@0: } michael@0: } michael@0: michael@0: function checkPropertyOnAllRules(view) { michael@0: for (let rule of view._elementStyle.rules) { michael@0: let lastRule = rule.textProps[rule.textProps.length - 1]; michael@0: michael@0: is(lastRule.name, "font-weight", "Last rule name is font-weight"); michael@0: is(lastRule.value, "bold", "Last rule value is bold"); michael@0: } michael@0: }