Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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=485157 |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test repeat timing</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <a target="_blank" |
michael@0 | 12 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=485157">Mozilla Bug |
michael@0 | 13 | 485157</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px"> |
michael@0 | 17 | <rect width="100" height="100" fill="green"> |
michael@0 | 18 | <set attributeName="width" to="100" dur="20s" repeatCount="5" begin="0s" |
michael@0 | 19 | id="a" onrepeat="startWaiting(evt)"/> |
michael@0 | 20 | <set attributeName="fill" attributeType="CSS" to="green" |
michael@0 | 21 | begin="a.repeat(1)" onbegin="expectedBegin()" dur="20s"/> |
michael@0 | 22 | <set attributeName="x" to="100" |
michael@0 | 23 | begin="a.repeat(2)" onbegin="unexpectedBegin(this)" dur="20s"/> |
michael@0 | 24 | <set attributeName="y" to="100" |
michael@0 | 25 | begin="a.repeat(0)" onbegin="unexpectedBegin(this)" dur="20s"/> |
michael@0 | 26 | <set attributeName="width" to="100" |
michael@0 | 27 | begin="a.repeat(-1)" onbegin="unexpectedBegin(this)" dur="20s"/> |
michael@0 | 28 | <set attributeName="height" to="100" |
michael@0 | 29 | begin="a.repeat(a)" onbegin="unexpectedBegin(this)" dur="20s"/> |
michael@0 | 30 | </rect> |
michael@0 | 31 | </svg> |
michael@0 | 32 | </div> |
michael@0 | 33 | <pre id="test"> |
michael@0 | 34 | <script class="testbody" type="text/javascript"> |
michael@0 | 35 | <![CDATA[ |
michael@0 | 36 | /** Test SMIL repeat timing **/ |
michael@0 | 37 | |
michael@0 | 38 | /* Global Variables */ |
michael@0 | 39 | const gTimeoutDur = 5000; // Time until we give up waiting for events in ms |
michael@0 | 40 | var gSvg = document.getElementById('svg'); |
michael@0 | 41 | var gRect = document.getElementById('circle'); |
michael@0 | 42 | var gTimeoutID; |
michael@0 | 43 | var gGotBegin = false; |
michael@0 | 44 | |
michael@0 | 45 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 46 | |
michael@0 | 47 | function testBegin() |
michael@0 | 48 | { |
michael@0 | 49 | gSvg.setCurrentTime(19.999); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function startWaiting(evt) |
michael@0 | 53 | { |
michael@0 | 54 | is(evt.detail, 1, "Unexpected repeat event received: test broken"); |
michael@0 | 55 | if (gGotBegin) |
michael@0 | 56 | return; |
michael@0 | 57 | |
michael@0 | 58 | gTimeoutID = setTimeout(timeoutFail, gTimeoutDur); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function timeoutFail() |
michael@0 | 62 | { |
michael@0 | 63 | ok(false, "Timed out waiting for begin event"); |
michael@0 | 64 | finish(); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function expectedBegin() |
michael@0 | 68 | { |
michael@0 | 69 | is(gGotBegin, false, |
michael@0 | 70 | "Got begin event more than once for non-repeating animation"); |
michael@0 | 71 | gGotBegin = true; |
michael@0 | 72 | clearTimeout(gTimeoutID); |
michael@0 | 73 | // Wait a moment before finishing in case there are erroneous events waiting |
michael@0 | 74 | // to be processed. |
michael@0 | 75 | setTimeout(finish, 10); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | function unexpectedBegin(elem) |
michael@0 | 79 | { |
michael@0 | 80 | ok(false, "Got unexpected begin from animation with spec: " + |
michael@0 | 81 | elem.getAttribute('begin')); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function finish() |
michael@0 | 85 | { |
michael@0 | 86 | gSvg.pauseAnimations(); |
michael@0 | 87 | SimpleTest.finish(); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | window.addEventListener("load", testBegin, false); |
michael@0 | 91 | ]]> |
michael@0 | 92 | </script> |
michael@0 | 93 | </pre> |
michael@0 | 94 | </body> |
michael@0 | 95 | </html> |