<!doctype html> <title>getScreenCTM tests</title> <script src=../../resources/testharness.js></script> <script src=../../resources/testharnessreport.js></script> <div id="testcontainer"> <style> svg { visibility: hidden; position: absolute; top:0; left:0; } #a, #c, #d, #e { width: 50px; height: 100px } </style> <svg id="a" width="100" height="200"/> <svg id="b" width="100" height="200"/> <svg id="c" width="100" height="200" viewBox="0 0 100 200"/> <svg id="d" viewBox="0 0 100 200"/> <svg id="e" viewBox="0 0 200 400"> <svg id="f" viewBox="0 0 100 200"> <g id="g"/> </svg> </svg> </div> <div id=log></div> <script> function ctmToString(ctm) { return [ ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f ].join(' '); } test(function() { var ctm = ctmToString(document.getElementById("a").getScreenCTM()); assert_equals(ctm, "1 0 0 1 0 0", ""); }, "css defined viewport"); test(function() { var ctm = ctmToString(document.getElementById("b").getScreenCTM()); assert_equals(ctm, "1 0 0 1 0 0", ""); }, "svg defined viewport"); test(function() { var ctm = ctmToString(document.getElementById("c").getScreenCTM()); assert_equals(ctm, "0.5 0 0 0.5 0 0", ""); }, "css defined viewport + svg has w, h, viewBox"); test(function() { var ctm = ctmToString(document.getElementById("d").getScreenCTM()); assert_equals(ctm, "0.5 0 0 0.5 0 0", ""); }, "css defined viewport + svg has viewBox"); test(function() { var ctm = ctmToString(document.getElementById("f").getScreenCTM()); assert_equals(ctm, "0.5 0 0 0.5 0 0", ""); }, "nested svg"); test(function() { var ctm = ctmToString(document.getElementById("g").getScreenCTM()); assert_equals(ctm, "0.5 0 0 0.5 0 0", ""); }, "g child of nested svg"); </script>