test_fragments.html (3052B)
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=759124 5 --> 6 <head> 7 <title>Test for Bug 759124</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=759124">Mozilla Bug 759124</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"></div> 15 16 <iframe id="svg"></iframe> 17 18 <pre id="test"> 19 <script class="testbody" type="application/javascript"> 20 var svg = $("svg"); 21 22 SimpleTest.waitForExplicitFinish(); 23 24 function Test(svgFragmentIdentifier) { 25 this.svgFragmentIdentifier = svgFragmentIdentifier; 26 } 27 28 function runTests() { 29 var doc = svg.contentWindow.document; 30 var rootElement = doc.documentElement; 31 32 var tests = [ 33 new Test("svgView(viewBox(0,0,200,200))"), 34 new Test("svgView(preserveAspectRatio(xMaxYMin slice))"), 35 new Test("svgView(viewBox(1,2,3,4);preserveAspectRatio(xMinYMax))"), 36 new Test("svgView(viewBox(none))"), 37 new Test("svgView(zoomAndPan(disable))"), 38 new Test("svgView(transform(translate(-10,-20) scale(2) rotate(45) translate(5,10)))"), 39 ]; 40 41 var src = svg.getAttribute("src"); 42 43 is(false, rootElement.hasAttribute("viewBox"), 44 "expecting to start without a viewBox set"); 45 is(false, rootElement.hasAttribute("preserveAspectRatio"), 46 "expecting to start without preserveAspectRatio set"); 47 is(false, rootElement.hasAttribute("zoomAndPan"), 48 "expecting to start without zoomAndPan set"); 49 50 for (var j = 0; j < 2; j++) { 51 var initialViewBox = rootElement.getAttribute("viewBox"); 52 var initialPreserveAspectRatio = 53 rootElement.getAttribute("preserveAspectRatio"); 54 var initialZoomAndPan = rootElement.getAttribute("zoomAndPan"); 55 var initialTransform = rootElement.getAttribute("transform"); 56 57 for (var i = 0; i < tests.length; i++) { 58 var test = tests[i]; 59 svg.setAttribute("src", src + "#" + test.svgFragmentIdentifier); 60 61 // check that assigning a viewSpec does not modify the underlying 62 // attribute values. 63 is(rootElement.getAttribute("viewBox"), 64 initialViewBox, "unexpected viewBox"); 65 66 is(rootElement.getAttribute("preserveAspectRatio"), 67 initialPreserveAspectRatio, "unexpected preserveAspectRatio"); 68 69 is(rootElement.getAttribute("zoomAndPan"), 70 initialZoomAndPan, "unexpected zoomAndPan"); 71 72 is(rootElement.getAttribute("transform"), 73 initialTransform, "unexpected transform"); 74 } 75 76 // repeat tests with underlying attributes set to values 77 rootElement.setAttribute("viewBox", "0 0 100 100"); 78 rootElement.setAttribute("preserveAspectRatio", "none"); 79 rootElement.setAttribute("zoomAndPan", "disable"); 80 rootElement.setAttribute("transform", "translate(10,10)"); 81 } 82 83 SimpleTest.finish(); 84 } 85 86 svg.addEventListener("load", runTests); 87 svg.setAttribute("src", "fragments-helper.svg"); 88 </script> 89 </pre> 90 </body> 91 </html>