DOMPoint-001.html (3598B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Geometry Interfaces: DOMPoint and DOMPointReadOnly interface tests</title> 5 <link rel="author" title="Dirk Schulze" href="mailto:dschulze@adobe.com" /> 6 <link rel="help" href="https://www.w3.org/TR/geometry-1/#dictdef-dompointinit"> 7 <link rel="help" href="https://www.w3.org/TR/geometry-1/#dom-dompoint-dompoint"> 8 <link rel="help" href="https://www.w3.org/TR/geometry-1/#DOMPoint"> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 </head> 12 <body> 13 <p>Test DOMPoint and DOMPointReadOnly interfaces</p> 14 <div id="log"></div> 15 <script> 16 test(function() { 17 checkDOMPoint(new DOMPoint(), {x:0, y:0, z:0, w:1}); 18 },'testConstructor0'); 19 test(function() { 20 checkDOMPoint(new DOMPoint(1), {x:1, y:0, z:0, w:1}); 21 },'testConstructor1'); 22 test(function() { 23 checkDOMPoint(new DOMPoint(1, 2), {x:1, y:2, z:0, w:1}); 24 },'testConstructor2'); 25 test(function() { 26 checkDOMPoint(new DOMPoint(1, 2, 3), {x:1, y:2, z:3, w:1}); 27 },'testConstructor3'); 28 test(function() { 29 checkDOMPoint(new DOMPoint(1, 2, 3, 4), {x:1, y:2, z:3, w:4}); 30 },'testConstructor4'); 31 test(function() { 32 checkDOMPoint(new DOMPoint(1, 2, 3, 4, 5), {x:1, y:2, z:3, w:4}); 33 },'testConstructor5'); 34 test(function() { 35 checkDOMPoint(new DOMPoint({}), {x:NaN, y:0, z:0, w:1}); 36 },'testConstructorDictionary0'); 37 test(function() { 38 checkDOMPoint(new DOMPoint({x:1}), {x:NaN, y:0, z:0, w:1}); 39 },'testConstructorDictionary1'); 40 test(function() { 41 checkDOMPoint(new DOMPoint({x:1, y:2}), {x:NaN, y:0, z:0, w:1}); 42 },'testConstructorDictionary2'); 43 test(function() { 44 checkDOMPoint(new DOMPoint(1, undefined), {x:1, y:0, z:0, w:1}); 45 },'testConstructor2undefined'); 46 test(function() { 47 checkDOMPoint(new DOMPoint("a", "b"), {x:NaN, y:NaN, z:0, w:1}); 48 },'testConstructorUndefined1'); 49 test(function() { 50 checkDOMPoint(new DOMPoint({x:"a", y:"b"}), {x:NaN, y:0, z:0, w:1}); 51 },'testConstructorUndefined2'); 52 test(function() { 53 checkDOMPoint(new DOMPointReadOnly(), {x:0, y:0, z:0, w:1}); 54 },'DOMPointReadOnly constructor with no values'); 55 test(function() { 56 checkDOMPoint(new DOMPointReadOnly(1, 2, 3, 4), {x:1, y:2, z:3, w:4}); 57 },'DOMPointReadOnly constructor with 4 values'); 58 test(function() { 59 var p = new DOMPoint(0, 0, 0, 1); 60 p.x = undefined; 61 p.y = undefined; 62 p.z = undefined; 63 p.w = undefined; 64 checkDOMPoint(p, {x:NaN, y:NaN, z:NaN, w:NaN}); 65 },'testAttributesUndefined'); 66 test(function() { 67 var p = new DOMPoint(0, 0, 0, 1); 68 p.x = NaN; 69 p.y = Number.POSITIVE_INFINITY; 70 p.z = Number.NEGATIVE_INFINITY; 71 p.w = Infinity; 72 checkDOMPoint(p, {x:NaN, y:Infinity, z:-Infinity, w:Infinity}); 73 },'testAttributesNaNInfinity'); 74 75 function checkDOMPoint(p, exp) { 76 assert_equals(p.x, exp.x, "Expected value for x is " + exp.x); 77 assert_equals(p.y, exp.y, "Expected value for y is " + exp.y); 78 assert_equals(p.z, exp.z, "Expected value for z is " + exp.z); 79 assert_equals(p.w, exp.w, "Expected value for w is " + exp.w); 80 } 81 </script> 82 </body> 83 </html>