test_smilXHR.xhtml (2561B)
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <title>Test for SMIL Behavior in Data Documents</title> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <script type="text/javascript" src="smilTestUtils.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 </head> 8 <body> 9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529387">Mozilla Bug 529387</a> 10 <p id="display"></p> 11 <div id="content" style="display: none"> 12 </div> 13 <pre id="test"> 14 <script class="testbody" type="text/javascript"> 15 <![CDATA[ 16 /** Test for SMIL Behavior in Data Documents, with XMLHttpRequest */ 17 18 SimpleTest.waitForExplicitFinish(); 19 20 function tryPausing(svg) { 21 // Check that pausing has no effect 22 ok(!svg.animationsPaused(), 23 "shouldn't be paused (because we shouldn't have even started"); 24 svg.pauseAnimations(); 25 ok(!svg.animationsPaused(), "attempts to pause should have no effect"); 26 svg.unpauseAnimations(); 27 ok(!svg.animationsPaused(), "still shouldn't be paused, after pause/unpause"); 28 } 29 30 function trySeeking(svg) { 31 // Check that seeking is ineffective 32 is(svg.getCurrentTime(), 0, "should start out at time=0"); 33 svg.setCurrentTime(1); 34 is(svg.getCurrentTime(), 0, "shouldn't be able to seek away from time=0"); 35 } 36 37 function tryBeginEnd(anim) { 38 // Check that beginning / ending a particular animation element will trigger 39 // exceptions. 40 var didThrow = false; 41 ok(anim, "need a non-null animate element"); 42 try { 43 anim.beginElement(); 44 } catch (e) { 45 didThrow = true; 46 } 47 ok(didThrow, "beginElement should fail"); 48 49 didThrow = false; 50 try { 51 anim.endElement(); 52 } catch (e) { 53 didThrow = true; 54 } 55 ok(didThrow, "endElement should fail"); 56 } 57 58 function main() { 59 var xhr = new XMLHttpRequest(); 60 xhr.open("GET", "smilXHR_helper.svg", false); 61 xhr.send(); 62 var xdoc = xhr.responseXML; 63 64 var svg = xdoc.getElementById("svg"); 65 var circ = xdoc.getElementById("circ"); 66 var animXML = xdoc.getElementById("animXML"); 67 var animCSS = xdoc.getElementById("animCSS"); 68 69 tryPausing(svg); 70 trySeeking(svg); 71 tryBeginEnd(animXML); 72 tryBeginEnd(animCSS); 73 74 // Check that the actual values of our animated attr/prop aren't affected 75 is(circ.cx.animVal.value, circ.cx.baseVal.value, 76 "animation of attribute shouldn't be taking effect"); 77 is(SMILUtil.getComputedStyleSimple(circ, "opacity"), "1", 78 "animation of CSS property shouldn't be taking effect"); 79 80 SimpleTest.finish(); 81 } 82 83 window.addEventListener("load", main); 84 ]]> 85 </script> 86 </pre> 87 </body> 88 </html>