DOMRect-nan.html (1416B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>DOMQuad's handling of NaN in getBounds()</title> 4 <link rel=help href="https://drafts.fxtf.org/geometry/#dom-domquad-getbounds"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script> 8 "use strict"; 9 10 const testCases = [ 11 { 12 name: "x coordinate is NaN", 13 idx: 0, 14 exp: { 15 x: NaN, 16 y: 0, 17 width: 0, 18 height: 0, 19 top: 0, 20 bottom: 0, 21 left: NaN, 22 right: NaN 23 } 24 }, 25 { 26 name: "y coordinate is NaN", 27 idx: 1, 28 exp: { 29 x: 0, 30 y: NaN, 31 width: 0, 32 height: 0, 33 top: NaN, 34 bottom: NaN, 35 left: 0, 36 right: 0 37 } 38 }, 39 { 40 name: "width is NaN", 41 idx: 2, 42 exp: { 43 x: 0, 44 y: 0, 45 width: NaN, 46 height: 0, 47 top: 0, 48 bottom: 0, 49 left: NaN, 50 right: NaN 51 } 52 }, 53 { 54 name: "height is NaN", 55 idx: 3, 56 exp: { 57 x: 0, 58 y: 0, 59 width: 0, 60 height: NaN, 61 top: NaN, 62 bottom: NaN, 63 left: 0, 64 right: 0 65 } 66 }, 67 ]; 68 69 for (const Rect of [DOMRect, DOMRectReadOnly]) { 70 for (const testCase of testCases) { 71 test(() => { 72 const args = [0, 0, 0, 0]; 73 args[testCase.idx] = NaN; 74 const rect = new Rect(...args); 75 assert_object_equals(rect.toJSON(), testCase.exp); 76 }, `${Rect.name}'s ${testCase.name}`); 77 } 78 } 79 </script>