1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_computedview_browser-styles.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Tests that the checkbox to include browser styles works properly. 1.11 + 1.12 +let test = asyncTest(function*() { 1.13 + yield addTab("data:text/html,default styles test"); 1.14 + 1.15 + info("Creating the test document"); 1.16 + content.document.body.innerHTML = '<style type="text/css"> ' + 1.17 + '.matches {color: #F00;}</style>' + 1.18 + '<span id="matches" class="matches">Some styled text</span>' + 1.19 + '</div>'; 1.20 + content.document.title = "Style Inspector Default Styles Test"; 1.21 + 1.22 + info("Opening the computed view"); 1.23 + let {toolbox, inspector, view} = yield openComputedView(); 1.24 + 1.25 + info("Selecting the test node"); 1.26 + yield selectNode("#matches", inspector); 1.27 + 1.28 + info("Checking the default styles"); 1.29 + is(isPropertyVisible("color", view), true, 1.30 + "span #matches color property is visible"); 1.31 + is(isPropertyVisible("background-color", view), false, 1.32 + "span #matches background-color property is hidden"); 1.33 + 1.34 + info("Toggling the browser styles"); 1.35 + let doc = view.styleDocument; 1.36 + let checkbox = doc.querySelector(".includebrowserstyles"); 1.37 + let onRefreshed = inspector.once("computed-view-refreshed"); 1.38 + checkbox.click(); 1.39 + yield onRefreshed; 1.40 + 1.41 + info("Checking the browser styles"); 1.42 + is(isPropertyVisible("color", view), true, 1.43 + "span color property is visible"); 1.44 + is(isPropertyVisible("background-color", view), true, 1.45 + "span background-color property is visible"); 1.46 +}); 1.47 + 1.48 +function isPropertyVisible(name, view) { 1.49 + info("Checking property visibility for " + name); 1.50 + let propertyViews = view.propertyViews; 1.51 + for each (let propView in propertyViews) { 1.52 + if (propView.name == name) { 1.53 + return propView.visible; 1.54 + } 1.55 + } 1.56 + return false; 1.57 +}