browser/devtools/styleinspector/test/browser_computedview_media-queries.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleinspector/test/browser_computedview_media-queries.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     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 we correctly display appropriate media query titles in the
    1.11 +// property view.
    1.12 +
    1.13 +const TEST_URI = TEST_URL_ROOT + "doc_media_queries.html";
    1.14 +
    1.15 +let {PropertyView} = devtools.require("devtools/styleinspector/computed-view");
    1.16 +let {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
    1.17 +
    1.18 +let test = asyncTest(function*() {
    1.19 +  yield addTab(TEST_URI);
    1.20 +  let {toolbox, inspector, view} = yield openComputedView();
    1.21 +
    1.22 +  info("Selecting the test element");
    1.23 +  yield selectNode("div", inspector);
    1.24 +
    1.25 +  info("Checking CSSLogic");
    1.26 +  checkCssLogic();
    1.27 +
    1.28 +  info("Checking property view");
    1.29 +  yield checkPropertyView(view);
    1.30 +});
    1.31 +
    1.32 +function checkCssLogic() {
    1.33 +  let cssLogic = new CssLogic();
    1.34 +  cssLogic.highlight(getNode("div"));
    1.35 +  cssLogic.processMatchedSelectors();
    1.36 +
    1.37 +  let _strings = Services.strings
    1.38 +    .createBundle("chrome://global/locale/devtools/styleinspector.properties");
    1.39 +
    1.40 +  let inline = _strings.GetStringFromName("rule.sourceInline");
    1.41 +
    1.42 +  let source1 = inline + ":8";
    1.43 +  let source2 = inline + ":15 @media screen and (min-width: 1px)";
    1.44 +  is(cssLogic._matchedRules[0][0].source, source1,
    1.45 +    "rule.source gives correct output for rule 1");
    1.46 +  is(cssLogic._matchedRules[1][0].source, source2,
    1.47 +    "rule.source gives correct output for rule 2");
    1.48 +}
    1.49 +
    1.50 +function checkPropertyView(view) {
    1.51 +  let propertyView = new PropertyView(view, "width");
    1.52 +  propertyView.buildMain();
    1.53 +  propertyView.buildSelectorContainer();
    1.54 +  propertyView.matchedExpanded = true;
    1.55 +
    1.56 +  return propertyView.refreshMatchedSelectors().then(() => {
    1.57 +    let numMatchedSelectors = propertyView.matchedSelectors.length;
    1.58 +
    1.59 +    is(numMatchedSelectors, 2,
    1.60 +        "Property view has the correct number of matched selectors for div");
    1.61 +
    1.62 +    is(propertyView.hasMatchedSelectors, true,
    1.63 +        "hasMatchedSelectors returns true");
    1.64 +  });
    1.65 +}

mercurial