DOMQuad-nan.html (1406B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>DOMRect's handling of NaN in top/bottom/left/right</title> 4 <link rel=help href="https://drafts.fxtf.org/geometry/#dom-domrectreadonly-domrect-top"> 5 <link rel=help href="https://drafts.fxtf.org/geometry/#dom-domrectreadonly-domrect-bottom"> 6 <link rel=help href="https://drafts.fxtf.org/geometry/#dom-domrectreadonly-domrect-left"> 7 <link rel=help href="https://drafts.fxtf.org/geometry/#dom-domrectreadonly-domrect-right"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script> 11 "use strict"; 12 13 for (const i of [1, 2, 3, 4]) { 14 for (const comp of ["x", "y"]) { 15 test(() => { 16 const args = [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }]; 17 args[i - 1][comp] = NaN; 18 const quad = new DOMQuad(...args); 19 const bounds = quad.getBounds(); 20 if (comp === "x") { 21 assert_equals(bounds.x, NaN, "x coordinate"); 22 assert_equals(bounds.y, 0, "y coordinate"); 23 assert_equals(bounds.width, NaN, "width"); 24 assert_equals(bounds.height, 0, "height"); 25 } else { 26 assert_equals(bounds.x, 0, "x coordinate"); 27 assert_equals(bounds.y, NaN, "y coordinate"); 28 assert_equals(bounds.width, 0, "width"); 29 assert_equals(bounds.height, NaN, "height"); 30 } 31 }, `Setting DOMQuad's p${i}.${comp} to NaN`); 32 } 33 } 34 </script>