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: // Tests that the checkbox to include browser styles works properly.
michael@0:
michael@0: let test = asyncTest(function*() {
michael@0: yield addTab("data:text/html,default styles test");
michael@0:
michael@0: info("Creating the test document");
michael@0: content.document.body.innerHTML = '' +
michael@0: 'Some styled text' +
michael@0: '';
michael@0: content.document.title = "Style Inspector Default Styles Test";
michael@0:
michael@0: info("Opening the computed view");
michael@0: let {toolbox, inspector, view} = yield openComputedView();
michael@0:
michael@0: info("Selecting the test node");
michael@0: yield selectNode("#matches", inspector);
michael@0:
michael@0: info("Checking the default styles");
michael@0: is(isPropertyVisible("color", view), true,
michael@0: "span #matches color property is visible");
michael@0: is(isPropertyVisible("background-color", view), false,
michael@0: "span #matches background-color property is hidden");
michael@0:
michael@0: info("Toggling the browser styles");
michael@0: let doc = view.styleDocument;
michael@0: let checkbox = doc.querySelector(".includebrowserstyles");
michael@0: let onRefreshed = inspector.once("computed-view-refreshed");
michael@0: checkbox.click();
michael@0: yield onRefreshed;
michael@0:
michael@0: info("Checking the browser styles");
michael@0: is(isPropertyVisible("color", view), true,
michael@0: "span color property is visible");
michael@0: is(isPropertyVisible("background-color", view), true,
michael@0: "span background-color property is visible");
michael@0: });
michael@0:
michael@0: function isPropertyVisible(name, view) {
michael@0: info("Checking property visibility for " + name);
michael@0: let propertyViews = view.propertyViews;
michael@0: for each (let propView in propertyViews) {
michael@0: if (propView.name == name) {
michael@0: return propView.visible;
michael@0: }
michael@0: }
michael@0: return false;
michael@0: }