|
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/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 // Tests that we correctly display appropriate media query titles in the |
|
8 // property view. |
|
9 |
|
10 const TEST_URI = TEST_URL_ROOT + "doc_media_queries.html"; |
|
11 |
|
12 let {PropertyView} = devtools.require("devtools/styleinspector/computed-view"); |
|
13 let {CssLogic} = devtools.require("devtools/styleinspector/css-logic"); |
|
14 |
|
15 let test = asyncTest(function*() { |
|
16 yield addTab(TEST_URI); |
|
17 let {toolbox, inspector, view} = yield openComputedView(); |
|
18 |
|
19 info("Selecting the test element"); |
|
20 yield selectNode("div", inspector); |
|
21 |
|
22 info("Checking CSSLogic"); |
|
23 checkCssLogic(); |
|
24 |
|
25 info("Checking property view"); |
|
26 yield checkPropertyView(view); |
|
27 }); |
|
28 |
|
29 function checkCssLogic() { |
|
30 let cssLogic = new CssLogic(); |
|
31 cssLogic.highlight(getNode("div")); |
|
32 cssLogic.processMatchedSelectors(); |
|
33 |
|
34 let _strings = Services.strings |
|
35 .createBundle("chrome://global/locale/devtools/styleinspector.properties"); |
|
36 |
|
37 let inline = _strings.GetStringFromName("rule.sourceInline"); |
|
38 |
|
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 } |
|
46 |
|
47 function checkPropertyView(view) { |
|
48 let propertyView = new PropertyView(view, "width"); |
|
49 propertyView.buildMain(); |
|
50 propertyView.buildSelectorContainer(); |
|
51 propertyView.matchedExpanded = true; |
|
52 |
|
53 return propertyView.refreshMatchedSelectors().then(() => { |
|
54 let numMatchedSelectors = propertyView.matchedSelectors.length; |
|
55 |
|
56 is(numMatchedSelectors, 2, |
|
57 "Property view has the correct number of matched selectors for div"); |
|
58 |
|
59 is(propertyView.hasMatchedSelectors, true, |
|
60 "hasMatchedSelectors returns true"); |
|
61 }); |
|
62 } |