Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 shorthand 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: italic bold .8em/1.2 Arial;', |
michael@0 | 13 | ' }', |
michael@0 | 14 | '</style>', |
michael@0 | 15 | '<div id="testElement">test element</div>' |
michael@0 | 16 | ].join("\n"); |
michael@0 | 17 | |
michael@0 | 18 | let test = asyncTest(function*() { |
michael@0 | 19 | yield addTab("data:text/html;charset=utf-8,font family shorthand tooltip test"); |
michael@0 | 20 | |
michael@0 | 21 | info("Creating the test document"); |
michael@0 | 22 | content.document.body.innerHTML = PAGE_CONTENT; |
michael@0 | 23 | |
michael@0 | 24 | info("Opening the rule view"); |
michael@0 | 25 | let {toolbox, inspector, view} = yield openRuleView(); |
michael@0 | 26 | |
michael@0 | 27 | info("Selecting the test node"); |
michael@0 | 28 | yield selectNode("#testElement", inspector); |
michael@0 | 29 | |
michael@0 | 30 | yield testRuleView(view); |
michael@0 | 31 | |
michael@0 | 32 | info("Opening the computed view"); |
michael@0 | 33 | let {toolbox, inspector, view} = yield openComputedView(); |
michael@0 | 34 | |
michael@0 | 35 | yield testComputedView(view); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | function* testRuleView(ruleView) { |
michael@0 | 39 | info("Testing font-family tooltips in the rule view"); |
michael@0 | 40 | |
michael@0 | 41 | let panel = ruleView.previewTooltip.panel; |
michael@0 | 42 | |
michael@0 | 43 | // Check that the rule view has a tooltip and that a XUL panel has been created |
michael@0 | 44 | ok(ruleView.previewTooltip, "Tooltip instance exists"); |
michael@0 | 45 | ok(panel, "XUL panel exists"); |
michael@0 | 46 | |
michael@0 | 47 | // Get the computed font family property inside the font rule view |
michael@0 | 48 | let propertyList = ruleView.element.querySelectorAll(".ruleview-propertylist"); |
michael@0 | 49 | let fontExpander = propertyList[1].querySelectorAll(".ruleview-expander")[0]; |
michael@0 | 50 | fontExpander.click(); |
michael@0 | 51 | |
michael@0 | 52 | let rule = getRuleViewRule(ruleView, "#testElement"); |
michael@0 | 53 | let valueSpan = rule.querySelector(".ruleview-computed .ruleview-propertyvalue"); |
michael@0 | 54 | |
michael@0 | 55 | // And verify that the tooltip gets shown on this property |
michael@0 | 56 | yield assertHoverTooltipOn(ruleView.previewTooltip, valueSpan); |
michael@0 | 57 | |
michael@0 | 58 | let description = panel.getElementsByTagName("description")[0]; |
michael@0 | 59 | is(description.style.fontFamily, "Arial", "Tooltips contains correct font-family style"); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function* testComputedView(computedView) { |
michael@0 | 63 | info("Testing font-family tooltips in the computed view"); |
michael@0 | 64 | |
michael@0 | 65 | let panel = computedView.tooltip.panel; |
michael@0 | 66 | let {valueSpan} = getComputedViewProperty(computedView, "font-family"); |
michael@0 | 67 | |
michael@0 | 68 | yield assertHoverTooltipOn(computedView.tooltip, valueSpan); |
michael@0 | 69 | |
michael@0 | 70 | let description = panel.getElementsByTagName("description")[0]; |
michael@0 | 71 | is(description.style.fontFamily, "Arial", "Tooltips contains correct font-family style"); |
michael@0 | 72 | } |