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