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