browser/devtools/styleinspector/test/browser_ruleview_edit-property-order.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 // Checking properties orders and overrides in the rule-view
     9 let test = asyncTest(function*() {
    10   yield addTab("data:text/html;charset=utf-8,browser_ruleview_manipulation.js");
    11   let {toolbox, inspector, view} = yield openRuleView();
    13   info("Creating the test document and getting the test node");
    14   content.document.body.innerHTML = '<div id="testid">Styled Node</div>';
    15   let element = getNode("#testid");
    17   yield selectNode(element, inspector);
    19   let elementStyle = view._elementStyle;
    20   let elementRule = elementStyle.rules[0];
    22   info("Checking rules insertion order and checking the applied style");
    23   let firstProp = elementRule.createProperty("background-color", "green", "");
    24   let secondProp = elementRule.createProperty("background-color", "blue", "");
    25   is(elementRule.textProps[0], firstProp, "Rules should be in addition order.");
    26   is(elementRule.textProps[1], secondProp, "Rules should be in addition order.");
    27   yield elementRule._applyingModifications;
    28   is(element.style.getPropertyValue("background-color"), "blue", "Second property should have been used.");
    30   info("Removing the second property and checking the applied style again");
    31   secondProp.remove();
    32   yield elementRule._applyingModifications;
    33   is(element.style.getPropertyValue("background-color"), "green", "After deleting second property, first should be used.");
    35   info("Creating a new second property and checking that the insertion order is still the same");
    36   secondProp = elementRule.createProperty("background-color", "blue", "");
    37   yield elementRule._applyingModifications;
    38   is(element.style.getPropertyValue("background-color"), "blue", "New property should be used.");
    39   is(elementRule.textProps[0], firstProp, "Rules shouldn't have switched places.");
    40   is(elementRule.textProps[1], secondProp, "Rules shouldn't have switched places.");
    42   info("Disabling the second property and checking the applied style");
    43   secondProp.setEnabled(false);
    44   yield elementRule._applyingModifications;
    45   is(element.style.getPropertyValue("background-color"), "green", "After disabling second property, first value should be used");
    47   info("Disabling the first property too and checking the applied style");
    48   firstProp.setEnabled(false);
    49   yield elementRule._applyingModifications;
    50   is(element.style.getPropertyValue("background-color"), "", "After disabling both properties, value should be empty.");
    52   info("Re-enabling the second propertyt and checking the applied style");
    53   secondProp.setEnabled(true);
    54   yield elementRule._applyingModifications;
    55   is(element.style.getPropertyValue("background-color"), "blue", "Value should be set correctly after re-enabling");
    57   info("Re-enabling the first property and checking the insertion order is still respected");
    58   firstProp.setEnabled(true);
    59   yield elementRule._applyingModifications;
    60   is(element.style.getPropertyValue("background-color"), "blue", "Re-enabling an earlier property shouldn't make it override a later property.");
    61   is(elementRule.textProps[0], firstProp, "Rules shouldn't have switched places.");
    62   is(elementRule.textProps[1], secondProp, "Rules shouldn't have switched places.");
    64   info("Modifying the first property and checking the applied style");
    65   firstProp.setValue("purple", "");
    66   yield elementRule._applyingModifications;
    67   is(element.style.getPropertyValue("background-color"), "blue", "Modifying an earlier property shouldn't override a later property.");
    68 });

mercurial