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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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