| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <script src="../../resources/js-test-pre.js"/> |
| </head> |
| <body> |
| <svg display="none" xmlns="http://www.w3.org/2000/svg"><text id="text"/></svg> |
| <p id="description"></p> |
| <div id="console"/> |
| <script> |
| var textElement = document.getElementById("text"); |
| var computedStyle; |
| |
| function parseGlyphOrientationHelper(property, angleValue, expectedValue) |
| { |
| textElement.setAttributeNS(null, property, angleValue); |
| computedStyle = textElement.ownerDocument.defaultView.getComputedStyle(textElement); |
| |
| debug("Test angleValue: '" + angleValue + "'"); |
| |
| if (expectedValue == "auto") { |
| shouldBe("computedStyle.getPropertyValue('" + property + "')", '"auto"'); |
| } else { |
| shouldBe("computedStyle.getPropertyCSSValue('" + property + "').getFloatValue(CSSPrimitiveValue.CSS_DEG)", "" + expectedValue); |
| } |
| |
| debug(""); |
| } |
| |
| function parseGlyphOrientation(angleValue, expectedValue) |
| { |
| if (expectedValue == undefined) { |
| parseGlyphOrientationHelper("glyph-orientation-horizontal", angleValue, 0.0); |
| parseGlyphOrientationHelper("glyph-orientation-vertical", angleValue, "auto"); |
| } else { |
| parseGlyphOrientationHelper("glyph-orientation-horizontal", angleValue, expectedValue); |
| parseGlyphOrientationHelper("glyph-orientation-vertical", angleValue, expectedValue); |
| } |
| } |
| |
| description('Stress test glyph-orientation SVG CSS properties'); |
| debug(''); |
| |
| debug('Strings that fail to parse, and hence parse as "0" for horziontal and "auto" as vertical.'); |
| debug(''); |
| |
| parseGlyphOrientation(" 0,1"); |
| parseGlyphOrientation(" 0,00000.1"); |
| parseGlyphOrientation(" 0 1"); |
| parseGlyphOrientation("0.1 0.2"); |
| |
| parseGlyphOrientation(" 270,1"); |
| parseGlyphOrientation(" 270,00000.1"); |
| parseGlyphOrientation(" 270 1"); |
| parseGlyphOrientation("270.1 0.2"); |
| |
| |
| debug('This tests the rounding of glyph orientation values to the only allowed values 0, 90, 180, 270.'); |
| debug(''); |
| |
| parseGlyphOrientation("-0.0", 0.0); |
| parseGlyphOrientation("-10.0", 0.0); |
| parseGlyphOrientation("-45.0", 0.0); |
| parseGlyphOrientation("0.0", 0.0); |
| parseGlyphOrientation("10.0", 0.0); |
| parseGlyphOrientation("45.0", 0.0); |
| |
| parseGlyphOrientation("-90.0", 90.0); |
| parseGlyphOrientation("-100.0", 90.0); |
| parseGlyphOrientation("-135.0", 90.0); |
| parseGlyphOrientation("90.0", 90.0); |
| parseGlyphOrientation("100.0", 90.0); |
| parseGlyphOrientation("135.0", 90.0); |
| |
| parseGlyphOrientation("-180.0", 180.0); |
| parseGlyphOrientation("-190.0", 180.0); |
| parseGlyphOrientation("-225.0", 180.0); |
| parseGlyphOrientation("180.0", 180.0); |
| parseGlyphOrientation("190.0", 180.0); |
| parseGlyphOrientation("225.0", 180.0); |
| |
| parseGlyphOrientation("-270.0", 270.0); |
| parseGlyphOrientation("-280.0", 270.0); |
| parseGlyphOrientation("-305.0", 270.0); |
| parseGlyphOrientation("270.0", 270.0); |
| parseGlyphOrientation("280.0", 270.0); |
| parseGlyphOrientation("305.0", 270.0); |
| |
| debug('Tests angles bigger than 360.'); |
| debug(''); |
| |
| parseGlyphOrientation("449.0", 90.0); |
| parseGlyphOrientation("450.0", 90.0); |
| parseGlyphOrientation("451.0", 90.0); |
| |
| parseGlyphOrientation("539.0", 180.0); |
| parseGlyphOrientation("540.0", 180.0); |
| parseGlyphOrientation("541.0", 180.0); |
| |
| parseGlyphOrientation("629.0", 270.0); |
| parseGlyphOrientation("630.0", 270.0); |
| parseGlyphOrientation("631.0", 270.0); |
| |
| debug('Tests whitespace before/after angle value.'); |
| debug(''); |
| |
| parseGlyphOrientation(" .0 ", 0.0); |
| parseGlyphOrientation(" 0 ", 0.0); |
| parseGlyphOrientation(" 90.0 ", 90.0); |
| parseGlyphOrientation(" 180.0 ", 180.0); |
| parseGlyphOrientation(" 270.0 ", 270.0); |
| |
| debug('Tests rounding of fractional angle values.'); |
| debug(''); |
| |
| parseGlyphOrientation("45.0000", 0.0); |
| parseGlyphOrientation("45.0001", 90.0); |
| parseGlyphOrientation("135.000", 90.0); |
| parseGlyphOrientation("135.001", 180.0); |
| |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| |
| </body> |
| </html> |