dom/smil/test/test_smilSetCurrentTime.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>Test for setCurrentTime Behavior </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 <p id="display"></p>
michael@0 9 <div id="content" style="display: none">
michael@0 10 <svg id="svg" xmlns="http://www.w3.org/2000/svg"
michael@0 11 onload="this.pauseAnimations()" />
michael@0 12 </div>
michael@0 13 <pre id="test">
michael@0 14 <script class="testbody" type="text/javascript">
michael@0 15 <![CDATA[
michael@0 16 /** Test for basic setCurrentTime / getCurrentTime Behavior **/
michael@0 17
michael@0 18 /* Global Variables & Constants */
michael@0 19 const PRECISION_LEVEL = 0.0000001; // Allow small level of floating-point error
michael@0 20 const gTimes = [0, 1.5, 0.2, 0.99, -400.5, 10000000, -1];
michael@0 21 const gWaitTime = 20;
michael@0 22 var gSvg = document.getElementById("svg");
michael@0 23
michael@0 24 SimpleTest.waitForExplicitFinish();
michael@0 25
michael@0 26 function main() {
michael@0 27 ok(gSvg.animationsPaused(), "should be paused by <svg> load handler");
michael@0 28 is(gSvg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
michael@0 29
michael@0 30 // Test that seeking takes effect immediately
michael@0 31 for (var i = 0; i < gTimes.length; i++) {
michael@0 32 gSvg.setCurrentTime(gTimes[i]);
michael@0 33 // We adopt the SVGT1.2 behavior of clamping negative times to 0
michael@0 34 assertFloatsEqual(gSvg.getCurrentTime(), Math.max(gTimes[i], 0.0));
michael@0 35 }
michael@0 36
michael@0 37 // Test that seeking isn't messed up by timeouts
michael@0 38 // (using tail recursion to set up the chain of timeout function calls)
michael@0 39 var func = function() {
michael@0 40 checkTimesAfterIndex(0);
michael@0 41 }
michael@0 42 setTimeout(func, gWaitTime);
michael@0 43 }
michael@0 44
michael@0 45 /* This method seeks to the time at gTimes[index],
michael@0 46 * and then sets up a timeout to...
michael@0 47 * - verify that the seek worked
michael@0 48 * - make a recursive call for the next index.
michael@0 49 */
michael@0 50 function checkTimesAfterIndex(index) {
michael@0 51 if (index == gTimes.length) {
michael@0 52 // base case -- we're done!
michael@0 53 SimpleTest.finish();
michael@0 54 return;
michael@0 55 }
michael@0 56
michael@0 57 gSvg.setCurrentTime(gTimes[index]);
michael@0 58 var func = function() {
michael@0 59 assertFloatsEqual(gSvg.getCurrentTime(), Math.max(gTimes[index], 0.0));
michael@0 60 checkTimesAfterIndex(index + 1);
michael@0 61 }
michael@0 62 setTimeout(func, gWaitTime);
michael@0 63 }
michael@0 64
michael@0 65 function assertFloatsEqual(aVal, aExpected) {
michael@0 66 ok(Math.abs(aVal - aExpected) <= PRECISION_LEVEL,
michael@0 67 "getCurrentTime returned " + aVal + " after seeking to " + aExpected)
michael@0 68 }
michael@0 69
michael@0 70 window.addEventListener("load", main, false);
michael@0 71 ]]>
michael@0 72 </script>
michael@0 73 </pre>
michael@0 74 </body>
michael@0 75 </html>

mercurial