Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 description("This test checks the SVGViewSpec API"); | |
|
fs
2016/07/26 16:10:09
This test probably has a corresponding -expected.t
| |
| 2 | |
| 3 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); | |
| 4 var currentView = svgElement.currentView; | |
| 5 svgElement.setAttribute("id", "test"); | |
| 6 svgElement.setAttribute("width", "150"); | |
| 7 svgElement.setAttribute("height", "50"); | |
| 8 svgElement.setAttribute("display", "block"); | |
| 9 | |
| 10 debug(""); | |
| 11 debug("Check initial SVGSVGElement.currentView values on a SVGSVGElement"); | |
| 12 shouldBe("currentView.transform.numberOfItems", "0"); | |
| 13 shouldBeNull("currentView.viewTarget"); | |
| 14 shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_MAGNIFY"); | |
| 15 shouldBe("currentView.viewBox.baseVal.x", "0"); | |
| 16 shouldBe("currentView.viewBox.baseVal.y", "0"); | |
| 17 shouldBe("currentView.viewBox.baseVal.width", "0"); | |
| 18 shouldBe("currentView.viewBox.baseVal.height", "0"); | |
| 19 shouldBe("currentView.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRati o.SVG_PRESERVEASPECTRATIO_XMIDYMID"); | |
| 20 shouldBe("currentView.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspe ctRatio.SVG_MEETORSLICE_MEET"); | |
| 21 shouldBeEqualToString("currentView.viewBoxString", "0 0 0 0"); | |
| 22 shouldBeEqualToString("currentView.preserveAspectRatioString", "xMidYMid meet"); | |
| 23 shouldBeEqualToString("currentView.transformString", ""); | |
| 24 shouldBeEqualToString("currentView.viewTargetString", ""); | |
| 25 shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_MAGNIFY"); | |
| 26 | |
| 27 debug(""); | |
| 28 debug("Try changing zoomAndPan - none of these will work, as SVGViewSpec is full y readonly - even the animated properties it inherits from supplmental classes l ike SVGViewElement/SVGFitToViewBox"); | |
| 29 shouldThrow("currentView.zoomAndPan = SVGViewElement.SVG_ZOOMANDPAN_DISABLE"); | |
| 30 shouldBe("currentView.zoomAndPan", "SVGViewElement.SVG_ZOOMANDPAN_MAGNIFY"); | |
| 31 | |
| 32 debug(""); | |
| 33 debug("Try changing viewBox - this has no affect on the SVGSVGElement the viewSp ec belongs to - it exposed all its properties as read-only"); | |
| 34 shouldThrow("currentView.viewBox.baseVal.x = 10"); | |
| 35 shouldBe("currentView.viewBox.baseVal.x", "0"); | |
| 36 shouldThrow("currentView.viewBox.baseVal.y = 20"); | |
| 37 shouldBe("currentView.viewBox.baseVal.y", "0"); | |
| 38 shouldThrow("currentView.viewBox.baseVal.width = 50"); | |
| 39 shouldBe("currentView.viewBox.baseVal.width", "0"); | |
| 40 shouldThrow("currentView.viewBox.baseVal.height = 100"); | |
| 41 shouldBe("currentView.viewBox.baseVal.height", "0"); | |
| 42 shouldBeEqualToString("currentView.viewBoxString", "0 0 0 0"); | |
| 43 | |
| 44 debug(""); | |
| 45 debug("Try changing viewBoxString"); | |
| 46 shouldBeEqualToString("currentView.viewBoxString = '1 2 3 4'", "1 2 3 4"); | |
| 47 shouldBeEqualToString("currentView.viewBoxString", "0 0 0 0"); | |
| 48 | |
| 49 debug(""); | |
| 50 debug("Try changing preserveAspectRatio"); | |
| 51 shouldThrow("currentView.preserveAspectRatio.baseVal.align = SVGPreserveAspectRa tio.SVG_PRESERVEASPECTRATIO_XMINYMIN"); | |
| 52 shouldBe("currentView.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRati o.SVG_PRESERVEASPECTRATIO_XMIDYMID"); | |
| 53 shouldThrow("currentView.preserveAspectRatio.baseVal.meetOrSlice = SVGPreserveAs pectRatio.SVG_MEETORSLICE_SLICE"); | |
| 54 shouldBe("currentView.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspe ctRatio.SVG_MEETORSLICE_MEET"); | |
| 55 | |
| 56 debug(""); | |
| 57 debug("Try changing preserveAspectRatioString"); | |
| 58 shouldBeEqualToString("currentView.preserveAspectRatioString = 'xMinYMin slice'" , "xMinYMin slice"); | |
| 59 shouldBeEqualToString("currentView.preserveAspectRatioString", "xMidYMid meet"); | |
| 60 | |
| 61 | |
| 62 debug(""); | |
| 63 debug("Try changing transformString"); | |
| 64 shouldBeEqualToString("currentView.transformString = 'rotate(90)'", "rotate(90)" ); | |
| 65 shouldBeEqualToString("currentView.transformString", ""); | |
| 66 | |
| 67 | |
| 68 debug(""); | |
| 69 debug("Try changing viewTarget"); | |
| 70 shouldBe("currentView.viewTarget = svgElement", "svgElement"); | |
| 71 shouldBeNull("currentView.viewTarget"); | |
| 72 | |
| 73 | |
| 74 debug(""); | |
| 75 debug("Try changing viewTargetString"); | |
| 76 shouldBeEqualToString("currentView.viewTargetString = '#test'", "#test"); | |
| 77 shouldBeEqualToString("currentView.viewTargetString", ""); | |
| 78 | |
| 79 debug(""); | |
| 80 debug("Try changing transform"); | |
| 81 shouldThrow("currentView.transform.clear()"); | |
| 82 shouldBe("currentView.transform.numberOfItems", "0"); | |
| 83 | |
| 84 successfullyParsed = true; | |
| OLD | NEW |