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

mercurial