dom/smil/test/test_smilKeyTimesPacedMode.xhtml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <html xmlns="http://www.w3.org/1999/xhtml">
michael@0 2 <head>
michael@0 3 <title>Tests updated intervals</title>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 6 </head>
michael@0 7 <body>
michael@0 8 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=555026">Mozilla Bug 555026</a>
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" width="120px" height="120px"
michael@0 12 onload="this.pauseAnimations()">
michael@0 13 <circle r="10" id="circle"/>
michael@0 14 </svg>
michael@0 15 </div>
michael@0 16 <pre id="test">
michael@0 17 <script class="testbody" type="text/javascript">
michael@0 18 <![CDATA[
michael@0 19 /** Test that we ignore keyTimes attr when calcMode="paced" **/
michael@0 20
michael@0 21 /* Global Variables */
michael@0 22 const SVGNS = "http://www.w3.org/2000/svg";
michael@0 23 const ANIM_DUR = "2s";
michael@0 24 const HALF_TIME = "1";
michael@0 25 const ATTR_NAME = "cx"
michael@0 26 const KEYTIMES_TO_TEST = [
michael@0 27 // potentially-valid values (depending on number of values in animation)
michael@0 28 "0; 0.2; 1",
michael@0 29 "0; 0.5",
michael@0 30 "0; 1",
michael@0 31 // invalid values:
michael@0 32 "", "abc", "-0.5", "0; 0.5; 1.01", "5"
michael@0 33 ];
michael@0 34 const gSvg = document.getElementById("svg");
michael@0 35 const gCircle = document.getElementById("circle");
michael@0 36
michael@0 37 SimpleTest.waitForExplicitFinish();
michael@0 38
michael@0 39
michael@0 40 // MAIN FUNCTIONS
michael@0 41 function main() {
michael@0 42 ok(gSvg.animationsPaused(), "should be paused by <svg> load handler");
michael@0 43 is(gSvg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
michael@0 44
michael@0 45 testByAnimation();
michael@0 46 testToAnimation();
michael@0 47 testValuesAnimation();
michael@0 48 SimpleTest.finish();
michael@0 49 }
michael@0 50
michael@0 51 function testByAnimation() {
michael@0 52 for (var i = 0; i < KEYTIMES_TO_TEST.length; i++) {
michael@0 53 setupTest();
michael@0 54 var anim = createAnim();
michael@0 55 anim.setAttribute("by", "200");
michael@0 56 var curKeyTimes = KEYTIMES_TO_TEST[i];
michael@0 57 anim.setAttribute("keyTimes", curKeyTimes);
michael@0 58
michael@0 59 gSvg.setCurrentTime(HALF_TIME);
michael@0 60 is(gCircle.cx.animVal.value, 100,
michael@0 61 "Checking animVal with 'by' and keyTimes='" + curKeyTimes + "'");
michael@0 62
michael@0 63 anim.parentNode.removeChild(anim); // clean up
michael@0 64 }
michael@0 65 }
michael@0 66
michael@0 67 function testToAnimation() {
michael@0 68 for (var i = 0; i < KEYTIMES_TO_TEST.length; i++) {
michael@0 69 setupTest();
michael@0 70 var anim = createAnim();
michael@0 71 anim.setAttribute("to", "200");
michael@0 72 var curKeyTimes = KEYTIMES_TO_TEST[i];
michael@0 73 anim.setAttribute("keyTimes", curKeyTimes);
michael@0 74
michael@0 75 gSvg.setCurrentTime(HALF_TIME);
michael@0 76 is(gCircle.cx.animVal.value, 100,
michael@0 77 "Checking animVal with 'to' and keyTimes='" + curKeyTimes + "'");
michael@0 78
michael@0 79 anim.parentNode.removeChild(anim); // clean up
michael@0 80 }
michael@0 81 }
michael@0 82
michael@0 83 function testValuesAnimation() {
michael@0 84 for (var i = 0; i < KEYTIMES_TO_TEST.length; i++) {
michael@0 85 setupTest();
michael@0 86 var anim = createAnim();
michael@0 87 anim.setAttribute("values", "100; 110; 200");
michael@0 88 var curKeyTimes = KEYTIMES_TO_TEST[i];
michael@0 89 anim.setAttribute("keyTimes", curKeyTimes);
michael@0 90
michael@0 91 gSvg.setCurrentTime(HALF_TIME);
michael@0 92 is(gCircle.cx.animVal.value, 150,
michael@0 93 "Checking animVal with 'values' and keyTimes='" + curKeyTimes + "'");
michael@0 94
michael@0 95 anim.parentNode.removeChild(anim); // clean up
michael@0 96 }
michael@0 97 }
michael@0 98
michael@0 99 // HELPER FUNCTIONS
michael@0 100 // Common setup code for each test function: seek to 0, and make sure
michael@0 101 // the previous test cleaned up its animations.
michael@0 102 function setupTest() {
michael@0 103 gSvg.setCurrentTime(0);
michael@0 104 if (gCircle.firstChild) {
michael@0 105 ok(false, "Previous test didn't clean up after itself.");
michael@0 106 }
michael@0 107 }
michael@0 108
michael@0 109 function createAnim() {
michael@0 110 var anim = document.createElementNS(SVGNS,"animate");
michael@0 111 anim.setAttribute("attributeName", ATTR_NAME);
michael@0 112 anim.setAttribute("dur", ANIM_DUR);
michael@0 113 anim.setAttribute("begin", "0s");
michael@0 114 anim.setAttribute("calcMode", "paced");
michael@0 115 return gCircle.appendChild(anim);
michael@0 116 }
michael@0 117
michael@0 118 window.addEventListener("load", main, false);
michael@0 119 ]]>
michael@0 120 </script>
michael@0 121 </pre>
michael@0 122 </body>
michael@0 123 </html>

mercurial