browser_boxmodel_positions.js (1631B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that the box model displays the right values for positions. 7 8 const TEST_URI = ` 9 <style type='text/css'> 10 div { 11 position: absolute; 12 left: 0; 13 margin: 0; 14 padding: 0; 15 display: none; 16 height: 100px; 17 width: 100px; 18 border: 10px solid black; 19 } 20 </style> 21 <div>Test Node</div> 22 `; 23 24 // Expected values: 25 const res1 = [ 26 { 27 selector: ".boxmodel-position.boxmodel-top > span", 28 value: "auto", 29 }, 30 { 31 selector: ".boxmodel-position.boxmodel-right > span", 32 value: "auto", 33 }, 34 { 35 selector: ".boxmodel-position.boxmodel-bottom > span", 36 value: "auto", 37 }, 38 { 39 selector: ".boxmodel-position.boxmodel-left > span", 40 value: "0", 41 }, 42 ]; 43 44 add_task(async function () { 45 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 46 const { inspector, boxmodel } = await openLayoutView(); 47 const node = await getNodeFront("div", inspector); 48 const children = await inspector.markup.walker.children(node); 49 const beforeElement = children.nodes[0]; 50 51 await selectNode(beforeElement, inspector); 52 await testPositionValues(inspector, boxmodel); 53 }); 54 55 function testPositionValues(inspector, boxmodel) { 56 info("Test that the position values of the box model are correct"); 57 const doc = boxmodel.document; 58 59 for (let i = 0; i < res1.length; i++) { 60 const elt = doc.querySelector(res1[i].selector); 61 is( 62 elt.textContent, 63 res1[i].value, 64 res1[i].selector + " has the right value." 65 ); 66 } 67 }