mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
118 lines
No EOL
6.3 KiB
HTML
118 lines
No EOL
6.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
<title>Geometry Interfaces: DOMRect and DOMRectReadOnly interface tests</title>
|
|
<link href="mailto:dschulze@adobe.com" rel="author" title="Dirk Schulze" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#DOMRect" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrect" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrect-domrect" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-x" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-y" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-width" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-height" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-top" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-left" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-right" rel="help" />
|
|
<link href="http://www.w3.org/TR/geometry-1/#dom-domrectreadonly-domrect-bottom" rel="help" />
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
</head>
|
|
<body>
|
|
<p>Test DOMRect and DOMRectReadOnly interfaces</p>
|
|
<div id="log"></div>
|
|
<script>
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(),
|
|
{ x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 });
|
|
},'testConstructor0');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(1),
|
|
{ x: 1, y: 0, width: 0, height: 0, top: 0, right: 1, bottom: 0, left: 1 });
|
|
},'testConstructor1');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(1, 2),
|
|
{ x: 1, y: 2, width: 0, height: 0, top: 2, right: 1, bottom: 2, left: 1 });
|
|
},'testConstructor2');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(1, 2, 3),
|
|
{ x: 1, y: 2, width: 3, height: 0, top: 2, right: 4, bottom: 2, left: 1 });
|
|
},'testConstructor3');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(1, 2, 3, 4),
|
|
{ x: 1, y: 2, width: 3, height: 4, top: 2, right: 4, bottom: 6, left: 1 });
|
|
},'testConstructor4');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(1, 2, 3, 4, 5),
|
|
{ x: 1, y: 2, width: 3, height: 4, top: 2, right: 4, bottom: 6, left: 1 });
|
|
},'testConstructor5');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(2, 2, -4, 4),
|
|
{ x: 2, y: 2, width: -4, height: 4, top: 2, right: 2, bottom: 6, left: -2 });
|
|
},'testConstructorNegativeWidth');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(2, 2, 4, -4),
|
|
{ x: 2, y: 2, width: 4, height: -4, top: -2, right: 6, bottom: 2, left: 2 });
|
|
},'testConstructorNegativeHeight');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(2, 2, -4, -4),
|
|
{ x: 2, y: 2, width: -4, height: -4, top: -2, right: 2, bottom: 2, left: -2 });
|
|
},'testConstructorNegativeWidthHeight');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(0, 0, undefined, 4),
|
|
{ x: 0, y: 0, width: NaN, height: 4, top: 0, right: 0, bottom: 4, left: 0 });
|
|
},'testConstructorUndefined1');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect(NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, null),
|
|
{ x: NaN, y: -Infinity, width: Infinity, height: 0, top: -Infinity, right: NaN, bottom: -Infinity, left: NaN });
|
|
},'testConstructorUndefined2');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect("1", "2", "3", "4"),
|
|
{ x: 1, y: 2, width: 3, height: 4, top: 2, right: 4, bottom: 6, left: 1 });
|
|
},'testConstructorString1');
|
|
test(function() {
|
|
checkDOMRect(new DOMRect("a", "b", "c", "d"),
|
|
{ x: NaN, y: NaN, width: NaN, height: NaN, top: NaN, right: NaN, bottom: NaN, left: NaN });
|
|
},'testConstructorString2');
|
|
test(function() {
|
|
assert_throws(new TypeError(), function() { new DOMRectReadOnly(); });
|
|
},'testConstructorIllegal1');
|
|
test(function() {
|
|
assert_throws(new TypeError(), function() { new DOMRectReadOnly(1, 2, 3, 4); });
|
|
},'testConstructorIllegal2');
|
|
test(function() {
|
|
var r = new DOMRect();
|
|
r.top = 5;
|
|
assert_equals(r.top, 0, "Expected value for top is 0");
|
|
r.right = 5;
|
|
assert_equals(r.right, 0, "Expected value for right is 0");
|
|
r.bottom = 5;
|
|
assert_equals(r.bottom, 0, "Expected value for bottom is 0");
|
|
r.left = 5;
|
|
assert_equals(r.left, 0, "Expected value for left is 0");
|
|
},'testSetReadOnlyAttributes');
|
|
test(function() {
|
|
var r = new DOMRect();
|
|
r.x = 5;
|
|
assert_equals(r.x, 5, "Expected value for x is 5");
|
|
r.y = 5;
|
|
assert_equals(r.y, 5, "Expected value for y is 5");
|
|
r.width = 5;
|
|
assert_equals(r.width, 5, "Expected value for width is 5");
|
|
r.height = 5;
|
|
assert_equals(r.height, 5, "Expected value for height is 5");
|
|
},'testSetAttributes');
|
|
|
|
function checkDOMRect(r, exp) {
|
|
assert_equals(r.x, exp.x, "Expected value for x is " + exp.x);
|
|
assert_equals(r.y, exp.y, "Expected value for y is " + exp.y);
|
|
assert_equals(r.width, exp.width, "Expected value for width is " + exp.width);
|
|
assert_equals(r.height, exp.height, "Expected value for height is " + exp.height);
|
|
assert_equals(r.top, exp.top, "Expected value for top is " + exp.top);
|
|
assert_equals(r.left, exp.left, "Expected value for left is " + exp.left);
|
|
assert_equals(r.bottom, exp.bottom, "Expected value for bottom is " + exp.bottom);
|
|
assert_equals(r.right, exp.right, "Expected value for right is " + exp.right);
|
|
}
|
|
</script>
|
|
|
|
|
|
</body></html> |