<!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.

  var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");

  // 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>
