OLD | NEW |
| (Empty) |
1 description("This test checks the SVGViewSpec API, operating on a parsed viewSpe
c"); | |
2 window.jsTestIsAsync = true; | |
3 if (window.testRunner) { | |
4 testRunner.waitUntilDone(); | |
5 | |
6 function completeTest() { | |
7 finishJSTest(); | |
8 } | |
9 | |
10 // Load an external file to test svgView() handling. | |
11 function testFragment(string) { | |
12 debug(""); | |
13 debug("Loading external SVG resources/viewspec-target.svg"); | |
14 debug("Passing SVGViewSpec: " + string); | |
15 debug(""); | |
16 var iframeElement = document.createElement("iframe"); | |
17 iframeElement.setAttribute("id", "iframe"); | |
18 iframeElement.setAttribute("style", "display: block"); | |
19 iframeElement.setAttribute("width", "120px"); | |
20 iframeElement.setAttribute("height", "120px"); | |
21 iframeElement.setAttribute("onload", "setTimeout(continueTesting, 0)"); | |
22 var newURL = "resources/viewspec-target.svg#" + string; | |
23 iframeElement.src = newURL; | |
24 | |
25 document.getElementById("console").appendChild(iframeElement); | |
26 } | |
27 | |
28 function matrixToString(matrix) { | |
29 return "[" + matrix.a.toFixed(2) + " " + matrix.b.toFixed(2) + " " + matrix.
c.toFixed(2) + " " + matrix.d.toFixed(2) + " " + matrix.e.toFixed(2) + " " + mat
rix.f.toFixed(2) + "]"; | |
30 } | |
31 | |
32 function continueTesting() { | |
33 currentView = document.getElementById("iframe").contentDocument.documentElem
ent.currentView; | |
34 | |
35 debug(""); | |
36 debug("Check transform value"); | |
37 shouldBeEqualToString("currentView.transformString", "translate(0 10) transl
ate(25 25) rotate(45) translate(-25 -25) scale(0.7 0.7)"); | |
38 shouldBe("currentView.transform.numberOfItems", "5"); | |
39 | |
40 shouldBe("currentView.transform.getItem(0).type", "SVGTransform.SVG_TRANSFOR
M_TRANSLATE"); | |
41 shouldBe("currentView.transform.getItem(0).angle", "0"); | |
42 shouldBeEqualToString("matrixToString(currentView.transform.getItem(0).matri
x)", "[1.00 0.00 0.00 1.00 0.00 10.00]"); | |
43 | |
44 shouldBe("currentView.transform.getItem(1).type", "SVGTransform.SVG_TRANSFOR
M_TRANSLATE"); | |
45 shouldBe("currentView.transform.getItem(1).angle", "0"); | |
46 shouldBeEqualToString("matrixToString(currentView.transform.getItem(1).matri
x)", "[1.00 0.00 0.00 1.00 25.00 25.00]"); | |
47 | |
48 shouldBe("currentView.transform.getItem(2).type", "SVGTransform.SVG_TRANSFOR
M_ROTATE"); | |
49 shouldBe("currentView.transform.getItem(2).angle", "45"); | |
50 shouldBeEqualToString("matrixToString(currentView.transform.getItem(2).matri
x)", "[0.71 0.71 -0.71 0.71 0.00 0.00]"); | |
51 | |
52 shouldBe("currentView.transform.getItem(3).type", "SVGTransform.SVG_TRANSFOR
M_TRANSLATE"); | |
53 shouldBe("currentView.transform.getItem(3).angle", "0"); | |
54 shouldBeEqualToString("matrixToString(currentView.transform.getItem(3).matri
x)", "[1.00 0.00 0.00 1.00 -25.00 -25.00]"); | |
55 | |
56 shouldBe("currentView.transform.getItem(4).type", "SVGTransform.SVG_TRANSFOR
M_SCALE"); | |
57 shouldBe("currentView.transform.getItem(4).angle", "0"); | |
58 shouldBeEqualToString("matrixToString(currentView.transform.getItem(4).matri
x)", "[0.70 0.00 0.00 0.70 0.00 0.00]"); | |
59 | |
60 debug(""); | |
61 debug("Check viewTarget value"); | |
62 shouldBeEqualToString("currentView.viewTargetString", "blub"); | |
63 shouldBeNull("currentView.viewTarget"); // There's no element named 'blub' i
n the tree. | |
64 | |
65 debug(""); | |
66 debug("Check zoomAndPan value"); | |
67 shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_DISABLE"); | |
68 | |
69 debug(""); | |
70 debug("Check viewBox value"); | |
71 shouldBe("currentView.viewBox.baseVal.x", "0"); | |
72 shouldBe("currentView.viewBox.baseVal.y", "0"); | |
73 shouldBe("currentView.viewBox.baseVal.width", "100"); | |
74 shouldBe("currentView.viewBox.baseVal.height", "50"); | |
75 shouldBeEqualToString("currentView.viewBoxString", "0 0 100 50"); | |
76 | |
77 debug(""); | |
78 debug("Check preserveAspectRatio value"); | |
79 shouldBeEqualToString("currentView.preserveAspectRatioString", "xMinYMid sli
ce"); | |
80 shouldBe("currentView.preserveAspectRatio.baseVal.align", "SVGPreserveAspect
Ratio.SVG_PRESERVEASPECTRATIO_XMINYMID"); | |
81 shouldBe("currentView.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserve
AspectRatio.SVG_MEETORSLICE_SLICE"); | |
82 | |
83 completeTest(); | |
84 } | |
85 | |
86 testFragment("svgView(viewBox(0,0,100,50);preserveAspectRatio(xMinYMid slice);tr
ansform(translate(0 10) translate(25 25) rotate(45) translate(-25 -25) scale(0.7
0.7));viewTarget(blub);zoomAndPan(disable))"); | |
87 successfullyParsed = true; | |
OLD | NEW |