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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/ */
     5 "use strict";
     7 // Test the fontfamily tooltip on longhand properties
     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");
    20 let test = asyncTest(function*() {
    21   yield addTab("data:text/html;charset=utf-8,font family longhand tooltip test");
    23   info("Creating the test document");
    24   content.document.body.innerHTML = PAGE_CONTENT;
    26   info("Opening the rule view");
    27   let {toolbox, inspector, view} = yield openRuleView();
    29   info("Selecting the test node");
    30   yield selectNode("#testElement", inspector);
    32   yield testRuleView(view);
    34   info("Opening the computed view");
    35   let {toolbox, inspector, view} = yield openComputedView();
    37   yield testComputedView(view);
    38 });
    40 function* testRuleView(ruleView) {
    41   info("Testing font-family tooltips in the rule view");
    43   let panel = ruleView.previewTooltip.panel;
    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");
    49   // Get the font family property inside the rule view
    50   let {valueSpan} = getRuleViewProperty(ruleView, "#testElement", "font-family");
    52   // And verify that the tooltip gets shown on this property
    53   yield assertHoverTooltipOn(ruleView.previewTooltip, valueSpan);
    55   let description = panel.getElementsByTagName("description")[0];
    56   is(description.style.fontFamily, "cursive", "Tooltips contains correct font-family style");
    57 }
    59 function* testComputedView(computedView) {
    60   info("Testing font-family tooltips in the computed view");
    62   let panel = computedView.tooltip.panel;
    63   let {valueSpan} = getComputedViewProperty(computedView, "font-family");
    65   yield assertHoverTooltipOn(computedView.tooltip, valueSpan);
    67   let description = panel.getElementsByTagName("description")[0];
    68   is(description.style.fontFamily, "cursive", "Tooltips contains correct font-family style");
    69 }

mercurial