1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_ruleview_content.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Test the rule-view content 1.11 + 1.12 +let test = asyncTest(function*() { 1.13 + yield addTab("data:text/html;charset=utf-8,browser_ruleview_ui.js"); 1.14 + let {toolbox, inspector, view} = yield openRuleView(); 1.15 + 1.16 + info("Creating the test document"); 1.17 + let style = "" + 1.18 + "#testid {" + 1.19 + " background-color: blue;" + 1.20 + "}" + 1.21 + ".testclass, .unmatched {" + 1.22 + " background-color: green;" + 1.23 + "}"; 1.24 + let styleNode = addStyle(content.document, style); 1.25 + content.document.body.innerHTML = "<div id='testid' class='testclass'>Styled Node</div>" + 1.26 + "<div id='testid2'>Styled Node</div>"; 1.27 + 1.28 + yield testContentAfterNodeSelection(inspector, view); 1.29 +}); 1.30 + 1.31 +function* testContentAfterNodeSelection(inspector, ruleView) { 1.32 + yield selectNode("#testid", inspector); 1.33 + is(ruleView.element.querySelectorAll("#noResults").length, 0, 1.34 + "After a highlight, no longer has a no-results element."); 1.35 + 1.36 + yield clearCurrentNodeSelection(inspector) 1.37 + is(ruleView.element.querySelectorAll("#noResults").length, 1, 1.38 + "After highlighting null, has a no-results element again."); 1.39 + 1.40 + yield selectNode("#testid", inspector); 1.41 + let classEditor = ruleView.element.children[2]._ruleEditor; 1.42 + is(classEditor.selectorText.querySelector(".ruleview-selector-matched").textContent, 1.43 + ".testclass", ".textclass should be matched."); 1.44 + is(classEditor.selectorText.querySelector(".ruleview-selector-unmatched").textContent, 1.45 + ".unmatched", ".unmatched should not be matched."); 1.46 +}