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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 shorthand properties
     9 const PAGE_CONTENT = [
    10   '<style type="text/css">',
    11   '  #testElement {',
    12   '    font: italic bold .8em/1.2 Arial;',
    13   '  }',
    14   '</style>',
    15   '<div id="testElement">test element</div>'
    16 ].join("\n");
    18 let test = asyncTest(function*() {
    19   yield addTab("data:text/html;charset=utf-8,font family shorthand tooltip test");
    21   info("Creating the test document");
    22   content.document.body.innerHTML = PAGE_CONTENT;
    24   info("Opening the rule view");
    25   let {toolbox, inspector, view} = yield openRuleView();
    27   info("Selecting the test node");
    28   yield selectNode("#testElement", inspector);
    30   yield testRuleView(view);
    32   info("Opening the computed view");
    33   let {toolbox, inspector, view} = yield openComputedView();
    35   yield testComputedView(view);
    36 });
    38 function* testRuleView(ruleView) {
    39   info("Testing font-family tooltips in the rule view");
    41   let panel = ruleView.previewTooltip.panel;
    43   // Check that the rule view has a tooltip and that a XUL panel has been created
    44   ok(ruleView.previewTooltip, "Tooltip instance exists");
    45   ok(panel, "XUL panel exists");
    47   // Get the computed font family property inside the font rule view
    48   let propertyList = ruleView.element.querySelectorAll(".ruleview-propertylist");
    49   let fontExpander = propertyList[1].querySelectorAll(".ruleview-expander")[0];
    50   fontExpander.click();
    52   let rule = getRuleViewRule(ruleView, "#testElement");
    53   let valueSpan = rule.querySelector(".ruleview-computed .ruleview-propertyvalue");
    55   // And verify that the tooltip gets shown on this property
    56   yield assertHoverTooltipOn(ruleView.previewTooltip, valueSpan);
    58   let description = panel.getElementsByTagName("description")[0];
    59   is(description.style.fontFamily, "Arial", "Tooltips contains correct font-family style");
    60 }
    62 function* testComputedView(computedView) {
    63   info("Testing font-family tooltips in the computed view");
    65   let panel = computedView.tooltip.panel;
    66   let {valueSpan} = getComputedViewProperty(computedView, "font-family");
    68   yield assertHoverTooltipOn(computedView.tooltip, valueSpan);
    70   let description = panel.getElementsByTagName("description")[0];
    71   is(description.style.fontFamily, "Arial", "Tooltips contains correct font-family style");
    72 }

mercurial