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