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 | // Tests that the checkbox to include browser styles works properly. |
michael@0 | 8 | |
michael@0 | 9 | let test = asyncTest(function*() { |
michael@0 | 10 | yield addTab("data:text/html,default styles test"); |
michael@0 | 11 | |
michael@0 | 12 | info("Creating the test document"); |
michael@0 | 13 | content.document.body.innerHTML = '<style type="text/css"> ' + |
michael@0 | 14 | '.matches {color: #F00;}</style>' + |
michael@0 | 15 | '<span id="matches" class="matches">Some styled text</span>' + |
michael@0 | 16 | '</div>'; |
michael@0 | 17 | content.document.title = "Style Inspector Default Styles Test"; |
michael@0 | 18 | |
michael@0 | 19 | info("Opening the computed view"); |
michael@0 | 20 | let {toolbox, inspector, view} = yield openComputedView(); |
michael@0 | 21 | |
michael@0 | 22 | info("Selecting the test node"); |
michael@0 | 23 | yield selectNode("#matches", inspector); |
michael@0 | 24 | |
michael@0 | 25 | info("Checking the default styles"); |
michael@0 | 26 | is(isPropertyVisible("color", view), true, |
michael@0 | 27 | "span #matches color property is visible"); |
michael@0 | 28 | is(isPropertyVisible("background-color", view), false, |
michael@0 | 29 | "span #matches background-color property is hidden"); |
michael@0 | 30 | |
michael@0 | 31 | info("Toggling the browser styles"); |
michael@0 | 32 | let doc = view.styleDocument; |
michael@0 | 33 | let checkbox = doc.querySelector(".includebrowserstyles"); |
michael@0 | 34 | let onRefreshed = inspector.once("computed-view-refreshed"); |
michael@0 | 35 | checkbox.click(); |
michael@0 | 36 | yield onRefreshed; |
michael@0 | 37 | |
michael@0 | 38 | info("Checking the browser styles"); |
michael@0 | 39 | is(isPropertyVisible("color", view), true, |
michael@0 | 40 | "span color property is visible"); |
michael@0 | 41 | is(isPropertyVisible("background-color", view), true, |
michael@0 | 42 | "span background-color property is visible"); |
michael@0 | 43 | }); |
michael@0 | 44 | |
michael@0 | 45 | function isPropertyVisible(name, view) { |
michael@0 | 46 | info("Checking property visibility for " + name); |
michael@0 | 47 | let propertyViews = view.propertyViews; |
michael@0 | 48 | for each (let propView in propertyViews) { |
michael@0 | 49 | if (propView.name == name) { |
michael@0 | 50 | return propView.visible; |
michael@0 | 51 | } |
michael@0 | 52 | } |
michael@0 | 53 | return false; |
michael@0 | 54 | } |