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 | <html xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>Test for Animation Behavior on CSS Properties</title> |
michael@0 | 4 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 5 | <script type="text/javascript" src="smilTestUtils.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | <svg id="svg" xmlns="http://www.w3.org/2000/svg"> |
michael@0 | 12 | </svg> |
michael@0 | 13 | </div> |
michael@0 | 14 | <pre id="test"> |
michael@0 | 15 | <script class="testbody" type="text/javascript"> |
michael@0 | 16 | <![CDATA[ |
michael@0 | 17 | /* This testcase verifies that animated values of "wider" and "narrower" for |
michael@0 | 18 | "font-stretch" have the expected effect, across all possible inherited |
michael@0 | 19 | values of the property. |
michael@0 | 20 | XXXdholbert Currently, we don't support animating relative values of |
michael@0 | 21 | font-stretch, so most of the tests here use todo_is() rather than is(). |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 25 | |
michael@0 | 26 | const gPropertyName="font-stretch"; |
michael@0 | 27 | |
michael@0 | 28 | // List of non-relative font-stretch values, from smallest to largest |
michael@0 | 29 | const gFontStretchValues = [ |
michael@0 | 30 | "ultra-condensed", |
michael@0 | 31 | "extra-condensed", |
michael@0 | 32 | "condensed", |
michael@0 | 33 | "semi-condensed", |
michael@0 | 34 | "normal", |
michael@0 | 35 | "semi-expanded", |
michael@0 | 36 | "expanded", |
michael@0 | 37 | "extra-expanded", |
michael@0 | 38 | "ultra-expanded" |
michael@0 | 39 | ]; |
michael@0 | 40 | |
michael@0 | 41 | function testFontStretchValue(baseValue, narrowerStep, widerStep) |
michael@0 | 42 | { |
michael@0 | 43 | var svg = SMILUtil.getSVGRoot(); |
michael@0 | 44 | var gElem = document.createElementNS(SVG_NS, "g"); |
michael@0 | 45 | gElem.setAttribute("style", "font-stretch: " + baseValue); |
michael@0 | 46 | svg.appendChild(gElem); |
michael@0 | 47 | |
michael@0 | 48 | var textElem = document.createElementNS(SVG_NS, "text"); |
michael@0 | 49 | gElem.appendChild(textElem); |
michael@0 | 50 | |
michael@0 | 51 | var animElem = document.createElementNS(SVG_NS, "set"); |
michael@0 | 52 | animElem.setAttribute("attributeName", gPropertyName); |
michael@0 | 53 | animElem.setAttribute("attributeType", "CSS"); |
michael@0 | 54 | animElem.setAttribute("begin", "0s"); |
michael@0 | 55 | animElem.setAttribute("dur", "indefinite"); |
michael@0 | 56 | textElem.appendChild(animElem); |
michael@0 | 57 | |
michael@0 | 58 | // CHECK EFFECT OF 'narrower' |
michael@0 | 59 | // NOTE: Using is() instead of todo_is() for ultra-condensed, since |
michael@0 | 60 | // 'narrower' has no effect on that value. |
michael@0 | 61 | var myIs = (baseValue == "ultra-condensed" ? is : todo_is); |
michael@0 | 62 | animElem.setAttribute("to", "narrower"); |
michael@0 | 63 | SMILUtil.getSVGRoot().setCurrentTime(1.0); // Force a resample |
michael@0 | 64 | myIs(SMILUtil.getComputedStyleSimple(textElem, gPropertyName), narrowerStep, |
michael@0 | 65 | "checking effect of 'narrower' on inherited value '" + baseValue + "'"); |
michael@0 | 66 | |
michael@0 | 67 | // CHECK EFFECT OF 'wider' |
michael@0 | 68 | // NOTE: using is() instead of todo_is() for ultra-expanded, since |
michael@0 | 69 | // 'wider' has no effect on that value. |
michael@0 | 70 | myIs = (baseValue == "ultra-expanded" ? is : todo_is); |
michael@0 | 71 | animElem.setAttribute("to", "wider"); |
michael@0 | 72 | SMILUtil.getSVGRoot().setCurrentTime(1.0); // Force a resample |
michael@0 | 73 | myIs(SMILUtil.getComputedStyleSimple(textElem, gPropertyName), widerStep, |
michael@0 | 74 | "checking effect of 'wider' on inherited value '" + baseValue + "'"); |
michael@0 | 75 | |
michael@0 | 76 | // Removing animation should clear animated effects |
michael@0 | 77 | textElem.removeChild(animElem); |
michael@0 | 78 | svg.removeChild(gElem); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | function main() |
michael@0 | 82 | { |
michael@0 | 83 | var valuesList = gFontStretchValues; |
michael@0 | 84 | for (var baseIdx in valuesList) { |
michael@0 | 85 | // 'narrower' and 'wider' are expected to shift us by one slot, but not |
michael@0 | 86 | // past the ends of the list of possible values. |
michael@0 | 87 | var narrowerIdx = Math.max(baseIdx - 1, 0); |
michael@0 | 88 | var widerIdx = Math.min(baseIdx + 1, valuesList.length - 1); |
michael@0 | 89 | |
michael@0 | 90 | testFontStretchValue(valuesList[baseIdx], |
michael@0 | 91 | valuesList[narrowerIdx], valuesList[widerIdx]); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | SimpleTest.finish(); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | window.addEventListener("load", main, false); |
michael@0 | 98 | ]]> |
michael@0 | 99 | </script> |
michael@0 | 100 | </pre> |
michael@0 | 101 | </body> |
michael@0 | 102 | </html> |