Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 fontfamily tooltip on longhand properties |
michael@0 | 8 | |
michael@0 | 9 | const PAGE_CONTENT = [ |
michael@0 | 10 | '<style type="text/css">', |
michael@0 | 11 | ' #testElement {', |
michael@0 | 12 | ' font-family: cursive;', |
michael@0 | 13 | ' color: #333;', |
michael@0 | 14 | ' padding-left: 70px;', |
michael@0 | 15 | ' }', |
michael@0 | 16 | '</style>', |
michael@0 | 17 | '<div id="testElement">test element</div>' |
michael@0 | 18 | ].join("\n"); |
michael@0 | 19 | |
michael@0 | 20 | let test = asyncTest(function*() { |
michael@0 | 21 | yield addTab("data:text/html;charset=utf-8,font family longhand tooltip test"); |
michael@0 | 22 | |
michael@0 | 23 | info("Creating the test document"); |
michael@0 | 24 | content.document.body.innerHTML = PAGE_CONTENT; |
michael@0 | 25 | |
michael@0 | 26 | info("Opening the rule view"); |
michael@0 | 27 | let {toolbox, inspector, view} = yield openRuleView(); |
michael@0 | 28 | |
michael@0 | 29 | info("Selecting the test node"); |
michael@0 | 30 | yield selectNode("#testElement", inspector); |
michael@0 | 31 | |
michael@0 | 32 | yield testRuleView(view); |
michael@0 | 33 | |
michael@0 | 34 | info("Opening the computed view"); |
michael@0 | 35 | let {toolbox, inspector, view} = yield openComputedView(); |
michael@0 | 36 | |
michael@0 | 37 | yield testComputedView(view); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | function* testRuleView(ruleView) { |
michael@0 | 41 | info("Testing font-family tooltips in the rule view"); |
michael@0 | 42 | |
michael@0 | 43 | let panel = ruleView.previewTooltip.panel; |
michael@0 | 44 | |
michael@0 | 45 | // Check that the rule view has a tooltip and that a XUL panel has been created |
michael@0 | 46 | ok(ruleView.previewTooltip, "Tooltip instance exists"); |
michael@0 | 47 | ok(panel, "XUL panel exists"); |
michael@0 | 48 | |
michael@0 | 49 | // Get the font family property inside the rule view |
michael@0 | 50 | let {valueSpan} = getRuleViewProperty(ruleView, "#testElement", "font-family"); |
michael@0 | 51 | |
michael@0 | 52 | // And verify that the tooltip gets shown on this property |
michael@0 | 53 | yield assertHoverTooltipOn(ruleView.previewTooltip, valueSpan); |
michael@0 | 54 | |
michael@0 | 55 | let description = panel.getElementsByTagName("description")[0]; |
michael@0 | 56 | is(description.style.fontFamily, "cursive", "Tooltips contains correct font-family style"); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | function* testComputedView(computedView) { |
michael@0 | 60 | info("Testing font-family tooltips in the computed view"); |
michael@0 | 61 | |
michael@0 | 62 | let panel = computedView.tooltip.panel; |
michael@0 | 63 | let {valueSpan} = getComputedViewProperty(computedView, "font-family"); |
michael@0 | 64 | |
michael@0 | 65 | yield assertHoverTooltipOn(computedView.tooltip, valueSpan); |
michael@0 | 66 | |
michael@0 | 67 | let description = panel.getElementsByTagName("description")[0]; |
michael@0 | 68 | is(description.style.fontFamily, "cursive", "Tooltips contains correct font-family style"); |
michael@0 | 69 | } |