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.

michael@0 1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 // Tests that we correctly display appropriate media query titles in the
michael@0 8 // property view.
michael@0 9
michael@0 10 const TEST_URI = TEST_URL_ROOT + "doc_media_queries.html";
michael@0 11
michael@0 12 let {PropertyView} = devtools.require("devtools/styleinspector/computed-view");
michael@0 13 let {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
michael@0 14
michael@0 15 let test = asyncTest(function*() {
michael@0 16 yield addTab(TEST_URI);
michael@0 17 let {toolbox, inspector, view} = yield openComputedView();
michael@0 18
michael@0 19 info("Selecting the test element");
michael@0 20 yield selectNode("div", inspector);
michael@0 21
michael@0 22 info("Checking CSSLogic");
michael@0 23 checkCssLogic();
michael@0 24
michael@0 25 info("Checking property view");
michael@0 26 yield checkPropertyView(view);
michael@0 27 });
michael@0 28
michael@0 29 function checkCssLogic() {
michael@0 30 let cssLogic = new CssLogic();
michael@0 31 cssLogic.highlight(getNode("div"));
michael@0 32 cssLogic.processMatchedSelectors();
michael@0 33
michael@0 34 let _strings = Services.strings
michael@0 35 .createBundle("chrome://global/locale/devtools/styleinspector.properties");
michael@0 36
michael@0 37 let inline = _strings.GetStringFromName("rule.sourceInline");
michael@0 38
michael@0 39 let source1 = inline + ":8";
michael@0 40 let source2 = inline + ":15 @media screen and (min-width: 1px)";
michael@0 41 is(cssLogic._matchedRules[0][0].source, source1,
michael@0 42 "rule.source gives correct output for rule 1");
michael@0 43 is(cssLogic._matchedRules[1][0].source, source2,
michael@0 44 "rule.source gives correct output for rule 2");
michael@0 45 }
michael@0 46
michael@0 47 function checkPropertyView(view) {
michael@0 48 let propertyView = new PropertyView(view, "width");
michael@0 49 propertyView.buildMain();
michael@0 50 propertyView.buildSelectorContainer();
michael@0 51 propertyView.matchedExpanded = true;
michael@0 52
michael@0 53 return propertyView.refreshMatchedSelectors().then(() => {
michael@0 54 let numMatchedSelectors = propertyView.matchedSelectors.length;
michael@0 55
michael@0 56 is(numMatchedSelectors, 2,
michael@0 57 "Property view has the correct number of matched selectors for div");
michael@0 58
michael@0 59 is(propertyView.hasMatchedSelectors, true,
michael@0 60 "hasMatchedSelectors returns true");
michael@0 61 });
michael@0 62 }

mercurial