SMIL animations of SVG <view> element have no effect
[WebKit-https.git] / LayoutTests / svg / dom / SVGViewSpec-multiple-views.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description("This test checks the SVGViewSpec API using multiple <view> elements");
11 jsTestIsAsync = true;
12
13 var externalSVGFileName = "resources/multiple-view-elements.svg";
14
15 function matrixToString(matrix) {
16     return "[" + matrix.a.toFixed(2) + " " + matrix.b.toFixed(2) + " " + matrix.c.toFixed(2) + " " + matrix.d.toFixed(2) + " " + matrix.e.toFixed(2) + " " + matrix.f.toFixed(2) + "]";
17 }
18
19 var firstDocumentElement;
20
21 function testFirstViewElement() {
22
23     iframeElement = document.getElementById("iframe");
24     currentDocumentElement = iframeElement.contentDocument.documentElement;
25     firstDocumentElement = currentDocumentElement;
26     currentView = currentDocumentElement.currentView;
27
28     debug("");
29     debug("Check transform value");
30     shouldBeEmptyString("currentView.transformString");
31     shouldBe("currentView.transform.numberOfItems", "0");
32
33     debug("");
34     debug("Check viewTarget value");
35     shouldBeEmptyString("currentView.viewTargetString");
36     shouldBeNull("currentView.viewTarget");
37
38     debug("");
39     debug("Check zoomAndPan value");
40     shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_MAGNIFY");
41
42     debug("");
43     debug("Check viewBox value");
44     shouldBe("currentView.viewBox.baseVal.x", "0");
45     shouldBe("currentView.viewBox.baseVal.y", "0");
46     shouldBe("currentView.viewBox.baseVal.width", "10");
47     shouldBe("currentView.viewBox.baseVal.height", "10");
48     shouldBeEqualToString("currentView.viewBoxString", "0 0 10 10");
49
50     debug("");
51     debug("Check preserveAspectRatio value");
52     shouldBeEqualToString("currentView.preserveAspectRatioString", "xMidYMid meet");
53     shouldBe("currentView.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID");
54     shouldBe("currentView.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
55
56     nextView = "#view2";
57     debug("");
58     debug("Loading external SVG " + externalSVGFileName + nextView + "...");
59     debug("");
60
61     iframeElement.src = externalSVGFileName + nextView;
62     testSecondViewElement();
63 }
64
65 function testSecondViewElement() {
66
67     iframeElement = document.getElementById("iframe");
68     currentView = iframeElement.contentDocument.documentElement.currentView;
69
70     debug("Verify that no load was performed, but only a different view was set on the same document");
71     shouldBe("iframeElement.contentDocument.documentElement", "firstDocumentElement");
72
73     debug("");
74     debug("Check transform value");
75     shouldBeEmptyString("currentView.transformString");
76     shouldBe("currentView.transform.numberOfItems", "0");
77
78     debug("");
79     debug("Check viewTarget value");
80     shouldBeEmptyString("currentView.viewTargetString");
81     shouldBeNull("currentView.viewTarget");
82
83     debug("");
84     debug("Check zoomAndPan value");
85     shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_MAGNIFY");
86
87     debug("");
88     debug("Check viewBox value");
89     shouldBe("currentView.viewBox.baseVal.x", "40");
90     shouldBe("currentView.viewBox.baseVal.y", "0");
91     shouldBe("currentView.viewBox.baseVal.width", "20");
92     shouldBe("currentView.viewBox.baseVal.height", "10");
93     shouldBeEqualToString("currentView.viewBoxString", "40 0 20 10");
94
95     debug("");
96     debug("Check preserveAspectRatio value");
97     shouldBeEqualToString("currentView.preserveAspectRatioString", "xMidYMax slice");
98     shouldBe("currentView.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX");
99     shouldBe("currentView.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
100
101     nextView = "#svgView(viewBox(0 0 10 15);transform(scale(2 2));preserveAspectRatio(xMinYMax meet))";
102     debug("");
103     debug("Loading external SVG " + externalSVGFileName + nextView + "...");
104     debug("");
105
106     iframeElement.src = externalSVGFileName + nextView;
107     testCustomViewSpec();
108 }
109
110 function testCustomViewSpec() {
111
112     iframeElement = document.getElementById("iframe");
113     currentView = iframeElement.contentDocument.documentElement.currentView;
114
115     debug("Verify that no load was performed, but only a different view was set on the same document");
116     shouldBe("iframeElement.contentDocument.documentElement", "firstDocumentElement");
117
118     debug("");
119     debug("Check transform value");
120     shouldBeEqualToString("currentView.transformString", "scale(2 2)");
121     shouldBe("currentView.transform.numberOfItems", "1");
122
123     shouldBe("currentView.transform.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
124     shouldBe("currentView.transform.getItem(0).angle", "0");
125     shouldBeEqualToString("matrixToString(currentView.transform.getItem(0).matrix)", "[2.00 0.00 0.00 2.00 0.00 0.00]");
126
127     debug("");
128     debug("Check viewTarget value");
129     shouldBeEmptyString("currentView.viewTargetString");
130     shouldBeNull("currentView.viewTarget");
131
132     debug("");
133     debug("Check zoomAndPan value");
134     shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_MAGNIFY");
135
136     debug("");
137     debug("Check viewBox value");
138     shouldBe("currentView.viewBox.baseVal.x", "0");
139     shouldBe("currentView.viewBox.baseVal.y", "0");
140     shouldBe("currentView.viewBox.baseVal.width", "10");
141     shouldBe("currentView.viewBox.baseVal.height", "15");
142     shouldBeEqualToString("currentView.viewBoxString", "0 0 10 15");
143
144     debug("");
145     debug("Check preserveAspectRatio value");
146     shouldBeEqualToString("currentView.preserveAspectRatioString", "xMinYMax meet");
147     shouldBe("currentView.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX");
148     shouldBe("currentView.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
149
150     finishJSTest();
151 }
152
153 nextView = "#view1";
154 debug("");
155 debug("Loading external SVG " + externalSVGFileName + nextView + "...");
156 debug("");
157
158 var iframeElement = document.createElement("iframe");
159 iframeElement.setAttribute("id", "iframe");
160 iframeElement.setAttribute("width", "120px");
161 iframeElement.setAttribute("height", "120px");
162 iframeElement.setAttribute("onload", "setTimeout(testFirstViewElement, 0)");
163 iframeElement.src = externalSVGFileName + "#view1";
164 document.getElementById("console").appendChild(iframeElement);
165
166 successfullyParsed = true;
167 </script>
168 <script src="../../resources/js-test-post.js"></script>
169 </body>
170 </html>