This test checks the SVGPaint API

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".



Check initial paint values
PASS (fillPaint = rectElement.style.getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Try invalid arguments for setPaint()
PASS fillPaint.setPaint(null, null, null, null) threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_RGBCOLOR, svgElement, '', ''); threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_RGBCOLOR, '', '') threw exception TypeError: Not enough arguments.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR + 1, '', '', ''); threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_NONE - 1, '', '', ''); threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI + 1, '', '', ''); threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint() threw exception TypeError: Not enough arguments.
PASS fillPaint.setPaint(fillPaint) threw exception TypeError: Not enough arguments.

Try invalid arguments for setUri()
PASS fillPaint.setUri() threw exception TypeError: Not enough arguments.

Try assigning to the readonly paintType property, which silently fails
PASS fillPaint.paintType = SVGPaint.SVG_PAINTTYPE_UNKKNOWN; is undefined.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_UNKNOWN
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_UNKKNOWN, '', '', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_UNKKNOWN, 'url(#foo)', '', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_UNKKNOWN, '', 'rgb(0,128,128)', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_UNKKNOWN, '', '', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_UNKKNOWN, 'url(#foo)', 'rgb(0,0,0)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.

Test using setPaint() and SVG_PAINTTYPE_NONE - a
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_NONE, '', '', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Reset style to initial value
PASS (fillPaint = rectElement.style.getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_NONE - b
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_NONE, 'url(#foo)', '', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Reset style to initial value
PASS (fillPaint = rectElement.style.getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_NONE - c
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_NONE, '', 'rgb(0,128,128)', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Reset style to initial value
PASS (fillPaint = rectElement.style.getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_NONE - d
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_NONE, '', '', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Reset style to initial value
PASS (fillPaint = rectElement.style.getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_NONE - e
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_NONE, 'url(#foo)', 'rgb(0,0,0)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI - a
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI, '', '', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI - b
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI, '', 'rgb(0,128,128)', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI - c
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI, '', '', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI - d
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI, 'url(#test)', '', '') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Reset style to initial value
PASS (fillPaint = rectElement.style.getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI - e
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI, 'url(#foo)', 'rgb(0,0,0)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI_NONE
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, 'url(#test)', 'rgb(0,0,0)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI_CURRENTCOLOR
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI_CURRENTCOLOR, 'url(#foo)', 'rgb(0,0,0)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI_RGBCOLOR
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR, 'url(#test)', 'rgb(77,0,77)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR, 'url(#foo)', 'rgb(77,0,77)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR, 'url(#test)', 'rgb(77,0,77)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_CURRENTCOLOR
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR, 'url(#foo)', 'rgb(77,0,77)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setPaint() and SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.setPaint(SVGPaint.SVG_PAINTTYPE_RGBCOLOR, 'url(#test)', 'rgb(0,77,0)', 'icc-color(myRGB, 0, 1, 2)') threw exception Error: NoModificationAllowedError: DOM Exception 7.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"

Test using setUri()
PASS fillPaint.setUri('url(#foobar)'); is undefined.
PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_RGBCOLOR
PASS fillPaint.uri is ""
PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_RGBCOLOR
PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128
PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
PASS rectElement.style.fill is "#008000"
PASS document.defaultView.getComputedStyle(rectElement).fill is "#008000"
PASS successfullyParsed is true

TEST COMPLETE

