Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /svg/types/scripted/SVGAnimatedRect.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<title>SVGAnimatedRect interface - utilizing the viewBox property of SVGSVGElement</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
// This test checks the SVGAnimatedRect API - utilizing the viewBox property of SVGSVGElement.
// Check initial viewBox value.
assert_true(svgElement.viewBox instanceof SVGAnimatedRect);
assert_true(svgElement.viewBox.baseVal instanceof SVGRect);
assert_equals(svgElement.viewBox.baseVal.x, 0);
assert_true(svgElement.viewBox.animVal instanceof SVGRect);
// Check that rects are dynamic, caching value in a local variable and modifying it, should take effect.
var numRef = svgElement.viewBox.baseVal;
numRef.x = 100;
assert_equals(numRef.x, 100);
assert_equals(svgElement.viewBox.baseVal.x, 100);
// Check that assigning to baseVal has no effect, as no setter is defined.
svgElement.viewBox.baseVal = -1;
assert_equals(svgElement.viewBox.baseVal.x, 100);
svgElement.viewBox.baseVal = 'aString';
assert_equals(svgElement.viewBox.baseVal.x, 100);
svgElement.viewBox.baseVal = svgElement;
assert_equals(svgElement.viewBox.baseVal.x, 100);
// Check that the viewBox baseVal type has not been changed.
assert_true(svgElement.viewBox.baseVal instanceof SVGRect);
});
</script>