|
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 // Test the rule-view content |
|
8 |
|
9 let test = asyncTest(function*() { |
|
10 yield addTab("data:text/html;charset=utf-8,browser_ruleview_ui.js"); |
|
11 let {toolbox, inspector, view} = yield openRuleView(); |
|
12 |
|
13 info("Creating the test document"); |
|
14 let style = "" + |
|
15 "#testid {" + |
|
16 " background-color: blue;" + |
|
17 "}" + |
|
18 ".testclass, .unmatched {" + |
|
19 " background-color: green;" + |
|
20 "}"; |
|
21 let styleNode = addStyle(content.document, style); |
|
22 content.document.body.innerHTML = "<div id='testid' class='testclass'>Styled Node</div>" + |
|
23 "<div id='testid2'>Styled Node</div>"; |
|
24 |
|
25 yield testContentAfterNodeSelection(inspector, view); |
|
26 }); |
|
27 |
|
28 function* testContentAfterNodeSelection(inspector, ruleView) { |
|
29 yield selectNode("#testid", inspector); |
|
30 is(ruleView.element.querySelectorAll("#noResults").length, 0, |
|
31 "After a highlight, no longer has a no-results element."); |
|
32 |
|
33 yield clearCurrentNodeSelection(inspector) |
|
34 is(ruleView.element.querySelectorAll("#noResults").length, 1, |
|
35 "After highlighting null, has a no-results element again."); |
|
36 |
|
37 yield selectNode("#testid", inspector); |
|
38 let classEditor = ruleView.element.children[2]._ruleEditor; |
|
39 is(classEditor.selectorText.querySelector(".ruleview-selector-matched").textContent, |
|
40 ".testclass", ".textclass should be matched."); |
|
41 is(classEditor.selectorText.querySelector(".ruleview-selector-unmatched").textContent, |
|
42 ".unmatched", ".unmatched should not be matched."); |
|
43 } |