browser/devtools/styleinspector/test/browser_styleinspector_tooltip-longhand-fontfamily.js

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

mercurial