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 | <!-- |
michael@0 | 3 | https://bugzilla.mozilla.org/show_bug.cgi?id=699143 |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test for Bug 699143</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="text/javascript" src="smilTestUtils.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=699143">Mozilla Bug 699143</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | <svg xmlns="http://www.w3.org/2000/svg"> |
michael@0 | 16 | <rect id="r" height="500px" width="500px" fill="blue"/> |
michael@0 | 17 | </svg> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script type="text/javascript"> |
michael@0 | 21 | <![CDATA[ |
michael@0 | 22 | |
michael@0 | 23 | /** Test for Bug 699143 **/ |
michael@0 | 24 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 25 | |
michael@0 | 26 | // Values for 'width' attr on the <rect> above |
michael@0 | 27 | const INITIAL_VAL = "500px" |
michael@0 | 28 | const FROM_VAL = "20px"; |
michael@0 | 29 | const TO_VAL = "80px"; |
michael@0 | 30 | |
michael@0 | 31 | // Helper functions |
michael@0 | 32 | |
michael@0 | 33 | // This function allows 10ms to pass |
michael@0 | 34 | function allowTimeToPass() { |
michael@0 | 35 | var initialDate = new Date(); |
michael@0 | 36 | while (new Date() - initialDate < 10) {} |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | // This function returns a newly created <animate> element for use in this test |
michael@0 | 40 | function createAnim() { |
michael@0 | 41 | var a = document.createElementNS('http://www.w3.org/2000/svg', 'animate'); |
michael@0 | 42 | a.setAttribute('attributeName', 'width'); |
michael@0 | 43 | a.setAttribute('from', FROM_VAL); |
michael@0 | 44 | a.setAttribute('to', TO_VAL); |
michael@0 | 45 | a.setAttribute('begin', 'indefinite'); |
michael@0 | 46 | a.setAttribute('dur', '3s'); |
michael@0 | 47 | a.setAttribute('fill', 'freeze'); |
michael@0 | 48 | return a; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | // Main Functions |
michael@0 | 52 | function main() { |
michael@0 | 53 | // In unpatched Firefox builds, we'll only trigger Bug 699143 if we insert |
michael@0 | 54 | // an animation and call beginElement() **after** the document start-time. |
michael@0 | 55 | // Hence, we use executeSoon here to allow some time to pass. (And then |
michael@0 | 56 | // we'll use a short busy-loop, for good measure.) |
michael@0 | 57 | SimpleTest.executeSoon(runTest); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function runTest() { |
michael@0 | 61 | var svg = SMILUtil.getSVGRoot(); |
michael@0 | 62 | |
michael@0 | 63 | // In case our executeSoon fired immediately, we force a very small amount |
michael@0 | 64 | // of time to pass here, using a 10ms busy-loop. |
michael@0 | 65 | allowTimeToPass(); |
michael@0 | 66 | |
michael@0 | 67 | is(svg.getCurrentTime(), 0, |
michael@0 | 68 | "even though we've allowed time to pass, we shouldn't have bothered " + |
michael@0 | 69 | "updating the current time, since there aren't any animation elements"); |
michael@0 | 70 | |
michael@0 | 71 | // Insert an animation elem (should affect currentTime but not targeted attr) |
michael@0 | 72 | var r = document.getElementById("r"); |
michael@0 | 73 | var a = createAnim(); |
michael@0 | 74 | r.appendChild(a); |
michael@0 | 75 | isnot(svg.getCurrentTime(), 0, |
michael@0 | 76 | "insertion of first animation element should have triggered a " + |
michael@0 | 77 | "synchronous sample and updated our current time"); |
michael@0 | 78 | is(r.width.animVal.valueAsString, INITIAL_VAL, |
michael@0 | 79 | "inserted animation shouldn't have affected its targeted attribute, " + |
michael@0 | 80 | "since it doesn't have any intervals yet"); |
michael@0 | 81 | |
michael@0 | 82 | // Trigger the animation & be sure it takes effect |
michael@0 | 83 | a.beginElement(); |
michael@0 | 84 | is(r.width.animVal.valueAsString, FROM_VAL, |
michael@0 | 85 | "beginElement() should activate our animation & set its 'from' val"); |
michael@0 | 86 | |
michael@0 | 87 | // Rewind to time=0 & check target attr, to be sure beginElement()-generated |
michael@0 | 88 | // interval starts later than that. |
michael@0 | 89 | svg.setCurrentTime(0); |
michael@0 | 90 | is(r.width.animVal.valueAsString, INITIAL_VAL, |
michael@0 | 91 | "after rewinding to 0, our beginElement()-generated interval " + |
michael@0 | 92 | "shouldn't be active yet"); |
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 | ]]> |
michael@0 | 100 | </script> |
michael@0 | 101 | </pre> |
michael@0 | 102 | </body> |
michael@0 | 103 | </html> |