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.

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

mercurial