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: // Checking properties orders and overrides in the rule-view michael@0: michael@0: let test = asyncTest(function*() { michael@0: yield addTab("data:text/html;charset=utf-8,browser_ruleview_manipulation.js"); michael@0: let {toolbox, inspector, view} = yield openRuleView(); michael@0: michael@0: info("Creating the test document and getting the test node"); michael@0: content.document.body.innerHTML = '
Styled Node
'; michael@0: let element = getNode("#testid"); michael@0: michael@0: yield selectNode(element, inspector); michael@0: michael@0: let elementStyle = view._elementStyle; michael@0: let elementRule = elementStyle.rules[0]; michael@0: michael@0: info("Checking rules insertion order and checking the applied style"); michael@0: let firstProp = elementRule.createProperty("background-color", "green", ""); michael@0: let secondProp = elementRule.createProperty("background-color", "blue", ""); michael@0: is(elementRule.textProps[0], firstProp, "Rules should be in addition order."); michael@0: is(elementRule.textProps[1], secondProp, "Rules should be in addition order."); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "blue", "Second property should have been used."); michael@0: michael@0: info("Removing the second property and checking the applied style again"); michael@0: secondProp.remove(); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "green", "After deleting second property, first should be used."); michael@0: michael@0: info("Creating a new second property and checking that the insertion order is still the same"); michael@0: secondProp = elementRule.createProperty("background-color", "blue", ""); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "blue", "New property should be used."); michael@0: is(elementRule.textProps[0], firstProp, "Rules shouldn't have switched places."); michael@0: is(elementRule.textProps[1], secondProp, "Rules shouldn't have switched places."); michael@0: michael@0: info("Disabling the second property and checking the applied style"); michael@0: secondProp.setEnabled(false); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "green", "After disabling second property, first value should be used"); michael@0: michael@0: info("Disabling the first property too and checking the applied style"); michael@0: firstProp.setEnabled(false); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "", "After disabling both properties, value should be empty."); michael@0: michael@0: info("Re-enabling the second propertyt and checking the applied style"); michael@0: secondProp.setEnabled(true); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "blue", "Value should be set correctly after re-enabling"); michael@0: michael@0: info("Re-enabling the first property and checking the insertion order is still respected"); michael@0: firstProp.setEnabled(true); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "blue", "Re-enabling an earlier property shouldn't make it override a later property."); michael@0: is(elementRule.textProps[0], firstProp, "Rules shouldn't have switched places."); michael@0: is(elementRule.textProps[1], secondProp, "Rules shouldn't have switched places."); michael@0: michael@0: info("Modifying the first property and checking the applied style"); michael@0: firstProp.setValue("purple", ""); michael@0: yield elementRule._applyingModifications; michael@0: is(element.style.getPropertyValue("background-color"), "blue", "Modifying an earlier property shouldn't override a later property."); michael@0: });