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 we correctly display appropriate media query titles in the michael@0: // property view. michael@0: michael@0: const TEST_URI = TEST_URL_ROOT + "doc_media_queries.html"; michael@0: michael@0: let {PropertyView} = devtools.require("devtools/styleinspector/computed-view"); michael@0: let {CssLogic} = devtools.require("devtools/styleinspector/css-logic"); michael@0: michael@0: let test = asyncTest(function*() { michael@0: yield addTab(TEST_URI); michael@0: let {toolbox, inspector, view} = yield openComputedView(); michael@0: michael@0: info("Selecting the test element"); michael@0: yield selectNode("div", inspector); michael@0: michael@0: info("Checking CSSLogic"); michael@0: checkCssLogic(); michael@0: michael@0: info("Checking property view"); michael@0: yield checkPropertyView(view); michael@0: }); michael@0: michael@0: function checkCssLogic() { michael@0: let cssLogic = new CssLogic(); michael@0: cssLogic.highlight(getNode("div")); michael@0: cssLogic.processMatchedSelectors(); michael@0: michael@0: let _strings = Services.strings michael@0: .createBundle("chrome://global/locale/devtools/styleinspector.properties"); michael@0: michael@0: let inline = _strings.GetStringFromName("rule.sourceInline"); michael@0: michael@0: let source1 = inline + ":8"; michael@0: let source2 = inline + ":15 @media screen and (min-width: 1px)"; michael@0: is(cssLogic._matchedRules[0][0].source, source1, michael@0: "rule.source gives correct output for rule 1"); michael@0: is(cssLogic._matchedRules[1][0].source, source2, michael@0: "rule.source gives correct output for rule 2"); michael@0: } michael@0: michael@0: function checkPropertyView(view) { michael@0: let propertyView = new PropertyView(view, "width"); michael@0: propertyView.buildMain(); michael@0: propertyView.buildSelectorContainer(); michael@0: propertyView.matchedExpanded = true; michael@0: michael@0: return propertyView.refreshMatchedSelectors().then(() => { michael@0: let numMatchedSelectors = propertyView.matchedSelectors.length; michael@0: michael@0: is(numMatchedSelectors, 2, michael@0: "Property view has the correct number of matched selectors for div"); michael@0: michael@0: is(propertyView.hasMatchedSelectors, true, michael@0: "hasMatchedSelectors returns true"); michael@0: }); michael@0: }