browser/devtools/styleinspector/test/browser_computedview_media-queries.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 we correctly display appropriate media query titles in the
     8 // property view.
    10 const TEST_URI = TEST_URL_ROOT + "doc_media_queries.html";
    12 let {PropertyView} = devtools.require("devtools/styleinspector/computed-view");
    13 let {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
    15 let test = asyncTest(function*() {
    16   yield addTab(TEST_URI);
    17   let {toolbox, inspector, view} = yield openComputedView();
    19   info("Selecting the test element");
    20   yield selectNode("div", inspector);
    22   info("Checking CSSLogic");
    23   checkCssLogic();
    25   info("Checking property view");
    26   yield checkPropertyView(view);
    27 });
    29 function checkCssLogic() {
    30   let cssLogic = new CssLogic();
    31   cssLogic.highlight(getNode("div"));
    32   cssLogic.processMatchedSelectors();
    34   let _strings = Services.strings
    35     .createBundle("chrome://global/locale/devtools/styleinspector.properties");
    37   let inline = _strings.GetStringFromName("rule.sourceInline");
    39   let source1 = inline + ":8";
    40   let source2 = inline + ":15 @media screen and (min-width: 1px)";
    41   is(cssLogic._matchedRules[0][0].source, source1,
    42     "rule.source gives correct output for rule 1");
    43   is(cssLogic._matchedRules[1][0].source, source2,
    44     "rule.source gives correct output for rule 2");
    45 }
    47 function checkPropertyView(view) {
    48   let propertyView = new PropertyView(view, "width");
    49   propertyView.buildMain();
    50   propertyView.buildSelectorContainer();
    51   propertyView.matchedExpanded = true;
    53   return propertyView.refreshMatchedSelectors().then(() => {
    54     let numMatchedSelectors = propertyView.matchedSelectors.length;
    56     is(numMatchedSelectors, 2,
    57         "Property view has the correct number of matched selectors for div");
    59     is(propertyView.hasMatchedSelectors, true,
    60         "hasMatchedSelectors returns true");
    61   });
    62 }

mercurial