browser/devtools/styleinspector/test/browser_styleinspector_tooltip-transform.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.

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 that the css transform preview tooltip is shown on transform properties
michael@0 8
michael@0 9 const PAGE_CONTENT = [
michael@0 10 '<style type="text/css">',
michael@0 11 ' #testElement {',
michael@0 12 ' width: 500px;',
michael@0 13 ' height: 300px;',
michael@0 14 ' background: red;',
michael@0 15 ' transform: skew(16deg);',
michael@0 16 ' }',
michael@0 17 ' .test-element {',
michael@0 18 ' transform-origin: top left;',
michael@0 19 ' transform: rotate(45deg);',
michael@0 20 ' }',
michael@0 21 ' div {',
michael@0 22 ' transform: scaleX(1.5);',
michael@0 23 ' transform-origin: bottom right;',
michael@0 24 ' }',
michael@0 25 ' [attr] {',
michael@0 26 ' }',
michael@0 27 '</style>',
michael@0 28 '<div id="testElement" class="test-element" attr="value">transformed element</div>'
michael@0 29 ].join("\n");
michael@0 30
michael@0 31 let test = asyncTest(function*() {
michael@0 32 yield addTab("data:text/html,rule view css transform tooltip test");
michael@0 33 content.document.body.innerHTML = PAGE_CONTENT;
michael@0 34 let {toolbox, inspector, view} = yield openRuleView();
michael@0 35
michael@0 36 info("Selecting the test node");
michael@0 37 yield selectNode("#testElement", inspector);
michael@0 38
michael@0 39 info("Checking that transforms tooltips are shown in various rule-view properties");
michael@0 40 for (let selector of [".test-element", "div", "#testElement"]) {
michael@0 41 yield testTransformTooltipOnSelector(view, selector);
michael@0 42 }
michael@0 43
michael@0 44 info("Checking that the transform tooltip doesn't appear for invalid transforms");
michael@0 45 yield testTransformTooltipNotShownOnInvalidTransform(view);
michael@0 46
michael@0 47 info("Checking transforms in the computed-view");
michael@0 48 let {view} = yield openComputedView();
michael@0 49 yield testTransformTooltipOnComputedView(view);
michael@0 50 });
michael@0 51
michael@0 52 function* testTransformTooltipOnSelector(view, selector) {
michael@0 53 info("Testing that a transform tooltip appears on transform in " + selector);
michael@0 54
michael@0 55 let {valueSpan} = getRuleViewProperty(view, selector, "transform");
michael@0 56 ok(valueSpan, "The transform property was found");
michael@0 57 yield assertHoverTooltipOn(view.previewTooltip, valueSpan);
michael@0 58
michael@0 59 // The transform preview is canvas, so there's not much we can test, so for
michael@0 60 // now, let's just be happy with the fact that the tooltips is shown!
michael@0 61 ok(true, "Tooltip shown on the transform property in " + selector);
michael@0 62 }
michael@0 63
michael@0 64 function* testTransformTooltipNotShownOnInvalidTransform(view) {
michael@0 65 let ruleEditor;
michael@0 66 for (let rule of view._elementStyle.rules) {
michael@0 67 if (rule.matchedSelectors[0] === "[attr]") {
michael@0 68 ruleEditor = rule.editor;
michael@0 69 }
michael@0 70 }
michael@0 71 ruleEditor.addProperty("transform", "muchTransform(suchAngle)", "");
michael@0 72
michael@0 73 let {valueSpan} = getRuleViewProperty(view, "[attr]", "transform");
michael@0 74 let isValid = yield isHoverTooltipTarget(view.previewTooltip, valueSpan);
michael@0 75 ok(!isValid, "The tooltip did not appear on hover of an invalid transform value");
michael@0 76 }
michael@0 77
michael@0 78 function* testTransformTooltipOnComputedView(view) {
michael@0 79 info("Testing that a transform tooltip appears in the computed view too");
michael@0 80
michael@0 81 let {valueSpan} = getComputedViewProperty(view, "transform");
michael@0 82 yield assertHoverTooltipOn(view.tooltip, valueSpan);
michael@0 83
michael@0 84 // The transform preview is canvas, so there's not much we can test, so for
michael@0 85 // now, let's just be happy with the fact that the tooltips is shown!
michael@0 86 ok(true, "Tooltip shown on the computed transform property");
michael@0 87 }

mercurial