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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/ */
     5 "use strict";
     7 // Tests that adding properties to rules work and reselecting the element still
     8 // show them
    10 const TEST_URI = TEST_URL_ROOT + "doc_content_stylesheet.html";
    12 let test = asyncTest(function*() {
    13   yield addTab(TEST_URI);
    15   let target = getNode("#target");
    17   let {toolbox, inspector, view} = yield openRuleView();
    18   yield selectNode(target, inspector);
    20   info("Setting a font-weight property on all rules");
    21   setPropertyOnAllRules(view);
    23   info("Reselecting the element");
    24   yield reselectElement(target, inspector);
    26   checkPropertyOnAllRules(view);
    27 });
    29 function* reselectElement(node, inspector) {
    30   yield selectNode(node.parentNode, inspector);
    31   yield selectNode(node, inspector);
    32 }
    34 function setPropertyOnAllRules(view) {
    35   for (let rule of view._elementStyle.rules) {
    36     rule.editor.addProperty("font-weight", "bold", "");
    37   }
    38 }
    40 function checkPropertyOnAllRules(view) {
    41   for (let rule of view._elementStyle.rules) {
    42     let lastRule = rule.textProps[rule.textProps.length - 1];
    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