browser_layout_getGrids.js (3025B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Check the output of getGrids for the LayoutActor 7 8 const GRID_FRAGMENT_DATA = { 9 areas: [ 10 { 11 columnEnd: 3, 12 columnStart: 2, 13 name: "header", 14 rowEnd: 2, 15 rowStart: 1, 16 type: "explicit", 17 }, 18 { 19 columnEnd: 2, 20 columnStart: 1, 21 name: "sidebar", 22 rowEnd: 3, 23 rowStart: 2, 24 type: "explicit", 25 }, 26 { 27 columnEnd: 3, 28 columnStart: 2, 29 name: "content", 30 rowEnd: 3, 31 rowStart: 2, 32 type: "explicit", 33 }, 34 ], 35 cols: { 36 lines: [ 37 { 38 breadth: 0, 39 names: ["col-1", "col-start-1", "sidebar-start"], 40 number: 1, 41 start: 0, 42 type: "explicit", 43 }, 44 { 45 breadth: 0, 46 names: ["col-2", "header-start", "sidebar-end", "content-start"], 47 number: 2, 48 start: 100, 49 type: "explicit", 50 }, 51 { 52 breadth: 0, 53 names: ["header-end", "content-end"], 54 number: 3, 55 start: 200, 56 type: "explicit", 57 }, 58 ], 59 tracks: [ 60 { 61 breadth: 100, 62 start: 0, 63 state: "static", 64 type: "explicit", 65 }, 66 { 67 breadth: 100, 68 start: 100, 69 state: "static", 70 type: "explicit", 71 }, 72 ], 73 }, 74 rows: { 75 lines: [ 76 { 77 breadth: 0, 78 names: ["header-start"], 79 number: 1, 80 start: 0, 81 type: "explicit", 82 }, 83 { 84 breadth: 0, 85 names: ["header-end", "sidebar-start", "content-start"], 86 number: 2, 87 start: 100, 88 type: "explicit", 89 }, 90 { 91 breadth: 0, 92 names: ["sidebar-end", "content-end"], 93 number: 3, 94 start: 200, 95 type: "explicit", 96 }, 97 ], 98 tracks: [ 99 { 100 breadth: 100, 101 start: 0, 102 state: "static", 103 type: "explicit", 104 }, 105 { 106 breadth: 100, 107 start: 100, 108 state: "static", 109 type: "explicit", 110 }, 111 ], 112 }, 113 }; 114 115 add_task(async function () { 116 const { target, walker, layout } = await initLayoutFrontForUrl( 117 MAIN_DOMAIN + "grid.html" 118 ); 119 const grids = await layout.getGrids(walker.rootNode); 120 const grid = grids[0]; 121 const { gridFragments } = grid; 122 123 is(grids.length, 1, "One grid was returned."); 124 is(gridFragments.length, 1, "One grid fragment was returned."); 125 ok(Array.isArray(gridFragments), "An array of grid fragments was returned."); 126 Assert.deepEqual( 127 gridFragments[0], 128 GRID_FRAGMENT_DATA, 129 "Got the correct grid fragment data." 130 ); 131 132 info("Get the grid container node front."); 133 134 try { 135 const nodeFront = await walker.getNodeFromActor(grids[0].actorID, [ 136 "containerEl", 137 ]); 138 ok(nodeFront, "Got the grid container node front."); 139 } catch (e) { 140 ok(false, "Did not get grid container node front."); 141 } 142 143 await target.destroy(); 144 gBrowser.removeCurrentTab(); 145 });