1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 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 fontfamily tooltip on longhand properties 1.11 + 1.12 +const PAGE_CONTENT = [ 1.13 + '<style type="text/css">', 1.14 + ' #testElement {', 1.15 + ' font-family: cursive;', 1.16 + ' color: #333;', 1.17 + ' padding-left: 70px;', 1.18 + ' }', 1.19 + '</style>', 1.20 + '<div id="testElement">test element</div>' 1.21 +].join("\n"); 1.22 + 1.23 +let test = asyncTest(function*() { 1.24 + yield addTab("data:text/html;charset=utf-8,font family longhand tooltip test"); 1.25 + 1.26 + info("Creating the test document"); 1.27 + content.document.body.innerHTML = PAGE_CONTENT; 1.28 + 1.29 + info("Opening the rule view"); 1.30 + let {toolbox, inspector, view} = yield openRuleView(); 1.31 + 1.32 + info("Selecting the test node"); 1.33 + yield selectNode("#testElement", inspector); 1.34 + 1.35 + yield testRuleView(view); 1.36 + 1.37 + info("Opening the computed view"); 1.38 + let {toolbox, inspector, view} = yield openComputedView(); 1.39 + 1.40 + yield testComputedView(view); 1.41 +}); 1.42 + 1.43 +function* testRuleView(ruleView) { 1.44 + info("Testing font-family tooltips in the rule view"); 1.45 + 1.46 + let panel = ruleView.previewTooltip.panel; 1.47 + 1.48 + // Check that the rule view has a tooltip and that a XUL panel has been created 1.49 + ok(ruleView.previewTooltip, "Tooltip instance exists"); 1.50 + ok(panel, "XUL panel exists"); 1.51 + 1.52 + // Get the font family property inside the rule view 1.53 + let {valueSpan} = getRuleViewProperty(ruleView, "#testElement", "font-family"); 1.54 + 1.55 + // And verify that the tooltip gets shown on this property 1.56 + yield assertHoverTooltipOn(ruleView.previewTooltip, valueSpan); 1.57 + 1.58 + let description = panel.getElementsByTagName("description")[0]; 1.59 + is(description.style.fontFamily, "cursive", "Tooltips contains correct font-family style"); 1.60 +} 1.61 + 1.62 +function* testComputedView(computedView) { 1.63 + info("Testing font-family tooltips in the computed view"); 1.64 + 1.65 + let panel = computedView.tooltip.panel; 1.66 + let {valueSpan} = getComputedViewProperty(computedView, "font-family"); 1.67 + 1.68 + yield assertHoverTooltipOn(computedView.tooltip, valueSpan); 1.69 + 1.70 + let description = panel.getElementsByTagName("description")[0]; 1.71 + is(description.style.fontFamily, "cursive", "Tooltips contains correct font-family style"); 1.72 +}