| 1 | // fixtures/engines/i2.mjs — the I2 editor layout (spec 2026-11-11), in |
| 2 | // Chromium and WebKit, through the real server. |
| 3 | // |
| 4 | // Run by internal/docs/i2_engines_browser_test.go with the same |
| 5 | // DOCS_ENGINES_CONFIG as first-reveal.mjs: "simple" documents owned by |
| 6 | // the signed-in person, a fresh one per leg. |
| 7 | // |
| 8 | // 1. 1280px: the stacked header, 56px, its stack starting at 56px; the |
| 9 | // header's controls 28px; the inspector a 248px panel 12px under the |
| 10 | // header and 12px from the end, its sections a column; the lead's |
| 11 | // undo/redo drawn and the strip's not. |
| 12 | // 2. Format toggles the inspector in place (no navigation), says so in |
| 13 | // aria-expanded and the cookie, and the next page is rendered closed; |
| 14 | // closed, Tab from the header goes past the hidden controls into the |
| 15 | // document, and Escape in the document stays there (C2). |
| 16 | // 3. The header's undo/redo stay current through keyboard undo and redo, |
| 17 | // and the strip's pair says the same. |
| 18 | // 4. The sheet: centred at 1800 and 1440, moved only as far as the |
| 19 | // inspector needs at 1280, and centred again with it closed. |
| 20 | // 5. 1000px: the strip under the header, open or closed (C3), Format not |
| 21 | // drawn, the lead's pair drawn. |
| 22 | // 6. 390px: the phone (design/phone-web, P1): estilo's compact bar, one |
| 23 | // 52px row with the lead's undo/redo, Aa and •••, and no menu row; |
| 24 | // Aa opens the Format sheet, half the screen at its foot (P2). |
| 25 | // 6b. 720px, the 704-799px band: the 56px header with the menus in it |
| 26 | // and the lead's undo/redo, the strip under it, not the strip's pair. |
| 27 | // 7. 320px: no page-level horizontal overflow. |
| 28 | // 8. A short window: the inspector scrolls inside it, and a picker's list |
| 29 | // is not clipped by it. |
| 30 | // |
| 31 | // I2_SHOTS=<dir> also saves a screenshot of each leg there. |
| 32 | |
| 33 | const { chromium, webkit } = await import('playwright') |
| 34 | const config = JSON.parse(process.env.DOCS_ENGINES_CONFIG) |
| 35 | const shots = process.env.I2_SHOTS || '' |
| 36 | const pause = (ms) => new Promise((r) => setTimeout(r, ms)) |
| 37 | const near = (a, b, tol = 1) => Math.abs(a - b) <= tol |
| 38 | |
| 39 | const failures = [] |
| 40 | for (const engine of [chromium, webkit]) { |
| 41 | const name = engine.name() |
| 42 | const fail = (msg) => failures.push(`${name}: ${msg}`) |
| 43 | const browser = await engine.launch({ headless: true }) |
| 44 | const until = async (fn, ms = 4000) => { |
| 45 | const end = Date.now() + ms |
| 46 | while (Date.now() < end) { if (await fn()) return true; await pause(50) } |
| 47 | return fn() |
| 48 | } |
| 49 | |
| 50 | // A fresh context at a width, signed in, with the inspector cookie as |
| 51 | // given, on a fresh document whose editor has mounted. |
| 52 | async function open (width, height, { inspector = '' } = {}) { |
| 53 | const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1 }) |
| 54 | const cookies = config.cookies.map((c) => ({ name: c.Name, value: c.Value, url: config.origin, httpOnly: c.HttpOnly, sameSite: 'Lax' })) |
| 55 | if (inspector) cookies.push({ name: 'docs-inspector', value: inspector, url: config.origin, sameSite: 'Lax' }) |
| 56 | await context.addCookies(cookies) |
| 57 | const page = await context.newPage() |
| 58 | const url = config.origin + '/d/' + config.docs.simple.shift() |
| 59 | await page.goto(url) |
| 60 | await page.waitForSelector('[docs-text][contenteditable="true"]', { timeout: 30000 }) |
| 61 | await page.waitForFunction(() => !document.querySelector('[docs-toolbar] [data-docs-command="strong"]').disabled, null, { timeout: 15000 }) |
| 62 | await pause(300) |
| 63 | return { context, page, url } |
| 64 | } |
| 65 | const shot = async (page, leg) => { if (shots) await page.screenshot({ path: `${shots}/${name}-${leg}.png` }) } |
| 66 | // Geometry of everything the checks read, in one round trip. |
| 67 | const measure = (page) => page.evaluate(() => { |
| 68 | const box = (sel) => { |
| 69 | const el = document.querySelector(sel) |
| 70 | if (!el) return null |
| 71 | const r = el.getBoundingClientRect() |
| 72 | const drawn = typeof el.checkVisibility === 'function' ? el.checkVisibility() : r.width > 0 |
| 73 | return { x: r.left, y: r.top, w: r.width, h: r.height, r: r.right, b: r.bottom, drawn } |
| 74 | } |
| 75 | return { |
| 76 | // The page's own width: <main>'s, which is the viewport less any |
| 77 | // scrollbar or its reserved gutter (Chromium reserves one, and |
| 78 | // documentElement.clientWidth still says the whole viewport). |
| 79 | vw: document.querySelector('main').getBoundingClientRect().width, |
| 80 | cw: document.documentElement.clientWidth, |
| 81 | scrollWidth: document.documentElement.scrollWidth, |
| 82 | header: box('[estilo-bar]'), |
| 83 | stack: box('[estilo-bar-stack]'), |
| 84 | menubar: box('[estilo-menubar]'), |
| 85 | lead: box('[estilo-bar-lead] [docs-history]'), |
| 86 | leadUndo: box('[estilo-bar-lead] [data-docs-command="undo"]'), |
| 87 | stripHistory: box('[docs-bar] > [docs-history]'), |
| 88 | format: box('[data-estilo-toggle][aria-controls="docs-inspector"]'), |
| 89 | share: box('[estilo-bar-actions] a[href$="/share"]'), |
| 90 | avatar: box('[estilo-account] [estilo-avatar], [estilo-account] > summary'), |
| 91 | inspector: box('[docs-inspector]'), |
| 92 | inspectorPosition: getComputedStyle(document.querySelector('[docs-inspector]')).position, |
| 93 | toolbar: box('[docs-toolbar]'), |
| 94 | styleGroup: box('[docs-toolbar-group="style"]'), |
| 95 | textGroup: box('[docs-toolbar-group="text"]'), |
| 96 | label: box('[docs-toolbar-label]'), |
| 97 | bold: box('[docs-toolbar] [data-docs-command="strong"]'), |
| 98 | chrome: box('[docs-chrome]'), |
| 99 | sheet: box('[docs-page]'), |
| 100 | state: document.querySelector('[docs-inspector]').getAttribute('data-state'), |
| 101 | expanded: document.querySelector('[data-estilo-toggle]').getAttribute('aria-expanded'), |
| 102 | formatDisabled: document.querySelector('[data-estilo-toggle]').disabled, |
| 103 | } |
| 104 | }) |
| 105 | |
| 106 | // 1. The header and the inspector at 1280. |
| 107 | { |
| 108 | const { context, page, url } = await open(1280, 900) |
| 109 | const m = await measure(page) |
| 110 | await shot(page, '1280-open') |
| 111 | if (!near(m.header.h, 56)) fail(`1280: the header is ${m.header.h}px tall, want 56`) |
| 112 | if (!near(m.stack.x, 56)) fail(`1280: the title and menus start at ${m.stack.x}px, want 56`) |
| 113 | for (const [what, b] of [['the undo/redo pill', m.lead], ['Format', m.format], ['Share', m.share], ['the avatar', m.avatar]]) { |
| 114 | if (!b || !b.drawn || !near(b.h, 28)) fail(`1280: ${what} is ${b && b.h}px tall (drawn ${b && b.drawn}), want 28`) |
| 115 | } |
| 116 | if (m.stripHistory.drawn) fail('1280: the strip\'s undo/redo is drawn beside the header\'s') |
| 117 | if (m.formatDisabled) fail('1280: Format is still disabled with the script loaded') |
| 118 | if (m.inspectorPosition !== 'fixed' || !m.inspector.drawn) fail(`1280: the inspector is ${m.inspectorPosition}, drawn ${m.inspector.drawn}`) |
| 119 | if (!near(m.inspector.w, 248)) fail(`1280: the inspector is ${m.inspector.w}px wide, want 248`) |
| 120 | if (!near(m.inspector.y, m.header.b + 12)) fail(`1280: the inspector starts at ${m.inspector.y}, want 12px under the header at ${m.header.b}`) |
| 121 | if (!near(m.inspector.r, m.vw - 12)) fail(`1280: the inspector ends at ${m.inspector.r}, want ${m.vw - 12}`) |
| 122 | if (!(m.textGroup.y >= m.styleGroup.b + 13)) fail(`1280: the sections are not a column 14px apart: Style ends ${m.styleGroup.b}, Text starts ${m.textGroup.y}`) |
| 123 | if (!m.label.drawn) fail('1280: the inspector\'s section labels are not drawn') |
| 124 | if (!near(m.bold.h, 28)) fail(`1280: the inspector's buttons are ${m.bold.h}px, want 28`) |
| 125 | |
| 126 | // 3. The header's undo/redo through keyboard undo and redo. |
| 127 | const disabled = (where, cmd) => page.evaluate(([w, c]) => document.querySelector(`${w} [data-docs-command="${c}"]`).disabled, [where, cmd]) |
| 128 | const pair = async (where) => [await disabled(where, 'undo'), await disabled(where, 'redo')].join(',') |
| 129 | await page.click('[docs-text] p') |
| 130 | await page.keyboard.press('End') |
| 131 | await page.keyboard.type('xyz') |
| 132 | if (!(await until(async () => (await pair('[estilo-bar-lead]')) === 'false,true'))) fail(`1280: after typing the header's undo/redo are ${await pair('[estilo-bar-lead]')}, want enabled, disabled`) |
| 133 | await pause(700) |
| 134 | await page.keyboard.press('ControlOrMeta+z') |
| 135 | if (!(await until(async () => (await pair('[estilo-bar-lead]')) === 'true,false'))) fail(`1280: after a keyboard undo the header's undo/redo are ${await pair('[estilo-bar-lead]')}, want disabled, enabled`) |
| 136 | await page.keyboard.press('ControlOrMeta+Shift+z') |
| 137 | if (!(await until(async () => (await pair('[estilo-bar-lead]')) === 'false,true'))) fail(`1280: after a keyboard redo the header's undo/redo are ${await pair('[estilo-bar-lead]')}, want enabled, disabled`) |
| 138 | if ((await pair('[docs-bar]')) !== (await pair('[estilo-bar-lead]'))) fail(`1280: the strip's pair (${await pair('[docs-bar]')}) disagrees with the header's (${await pair('[estilo-bar-lead]')})`) |
| 139 | // And the header's undo button does undo. |
| 140 | await page.click('[estilo-bar-lead] [data-docs-command="undo"]', { timeout: 3000 }).catch(() => fail('1280: the header\'s Undo could not be clicked')) |
| 141 | if (!(await until(async () => !(await page.locator('[docs-text]').innerText()).includes('xyz')))) fail('1280: the header\'s Undo did not undo') |
| 142 | |
| 143 | // 2. Format: closed in place, then the tab path and Escape. |
| 144 | await page.evaluate(() => { window.__same = true }) |
| 145 | await page.click('[data-estilo-toggle]') |
| 146 | await pause(200) |
| 147 | const c = await measure(page) |
| 148 | await shot(page, '1280-closed') |
| 149 | if (page.url() !== url || !(await page.evaluate(() => window.__same === true))) fail('1280: Format navigated') |
| 150 | if (c.state !== 'closed' || c.expanded !== 'false' || c.inspector.drawn) fail(`1280: after Format the inspector is ${c.state}, aria-expanded ${c.expanded}, drawn ${c.inspector.drawn}`) |
| 151 | const cookie = (await context.cookies()).find((k) => k.name === 'docs-inspector') |
| 152 | if (!cookie || cookie.value !== 'closed' || cookie.path !== '/' || cookie.sameSite !== 'Lax' || cookie.expires < Date.now() / 1000 + 300 * 86400) fail(`1280: the cookie is ${JSON.stringify(cookie)}, want closed, path /, Lax, a year`) |
| 153 | // Closed, Tab from the account goes into the document, past every |
| 154 | // hidden control of the inspector. |
| 155 | const tabFromAccount = async () => { |
| 156 | await page.focus('[estilo-account] > summary') |
| 157 | await page.keyboard.press('Tab') |
| 158 | await pause(100) |
| 159 | return page.evaluate(() => { |
| 160 | const a = document.activeElement |
| 161 | return a.closest('[docs-text]') ? 'document' : a.closest('[docs-toolbar]') ? 'toolbar' : (a.outerHTML || '').slice(0, 80) |
| 162 | }) |
| 163 | } |
| 164 | const closedTab = await tabFromAccount() |
| 165 | if (closedTab !== 'document') fail(`1280: closed, Tab from the account reached ${closedTab}, want the document`) |
| 166 | // Escape in the document has no drawn toolbar control to go to, so |
| 167 | // it goes to Format, the way back to the inspector (review on #106), |
| 168 | // and never to a hidden control. |
| 169 | await page.click('[docs-text] p') |
| 170 | await page.keyboard.press('Escape') |
| 171 | await pause(100) |
| 172 | const escaped = await page.evaluate(() => { |
| 173 | const a = document.activeElement |
| 174 | return a.matches('[data-estilo-toggle]') ? 'Format' : a.closest('[docs-toolbar]') ? 'a hidden toolbar control' : a.closest('[docs-text]') ? 'the document' : (a.outerHTML || '').slice(0, 60) |
| 175 | }) |
| 176 | if (escaped !== 'Format') fail(`1280: closed, Escape in the document went to ${escaped}, want Format`) |
| 177 | // The sheet with the inspector closed is plainly centred. |
| 178 | if (!near(c.sheet.x + c.sheet.w / 2, c.vw / 2, 1.5)) fail(`1280 closed: the sheet's centre is ${c.sheet.x + c.sheet.w / 2}, want ${c.vw / 2}`) |
| 179 | // The next page is rendered closed, from the first byte. |
| 180 | const raw = await (await page.request.get(url)).text() |
| 181 | if (!raw.includes('data-state="closed"') || !raw.includes('aria-expanded="false" aria-controls="docs-inspector"')) fail('1280: the next page was not rendered closed') |
| 182 | // Open again: the inspector is back and Tab reaches it. |
| 183 | await page.click('[data-estilo-toggle]') |
| 184 | await pause(200) |
| 185 | const o = await measure(page) |
| 186 | if (o.state !== 'open' || o.expanded !== 'true' || !o.inspector.drawn) fail(`1280: Format again left the inspector ${o.state}, aria-expanded ${o.expanded}, drawn ${o.inspector.drawn}`) |
| 187 | const openTab = await tabFromAccount() |
| 188 | if (openTab !== 'toolbar') fail(`1280: open, Tab from the account reached ${openTab}, want the toolbar`) |
| 189 | |
| 190 | // Forced colours (review on #106), where the engine can emulate them: |
| 191 | // a pressed control keeps an outline, and the Share popover's filled |
| 192 | // controls an edge. |
| 193 | await page.emulateMedia({ forcedColors: 'active' }) |
| 194 | if (await page.evaluate(() => matchMedia('(forced-colors: active)').matches)) { |
| 195 | const pressed = await page.evaluate(() => { |
| 196 | const b = document.querySelector('[docs-inspector] [aria-pressed="true"]') |
| 197 | return b ? getComputedStyle(b).outlineStyle : 'no pressed control' |
| 198 | }) |
| 199 | if (pressed !== 'solid') fail(`forced colours: the pressed control's outline is ${pressed}, want solid`) |
| 200 | await page.click('[estilo-bar-actions] a[href$="/share"]') |
| 201 | await until(async () => (await page.locator('[docs-share-pop] [docs-share-panel]').count()) === 1) |
| 202 | const edges = await page.evaluate(() => ['[docs-share-submit]', '[docs-share-invite] select'].map((sel) => { |
| 203 | const el = document.querySelector(sel) |
| 204 | return el ? `${sel} ${getComputedStyle(el).borderTopStyle} ${getComputedStyle(el).borderTopWidth}` : `${sel} missing` |
| 205 | })) |
| 206 | for (const e of edges) if (!e.endsWith('solid 1px')) fail(`forced colours: ${e}, want a 1px border`) |
| 207 | } |
| 208 | await context.close() |
| 209 | } |
| 210 | |
| 211 | // 4. The sheet at three widths, the inspector open. |
| 212 | for (const [w, centred] of [[1800, true], [1440, true], [1280, false]]) { |
| 213 | const { context, page } = await open(w, 900) |
| 214 | const m = await measure(page) |
| 215 | const centre = m.sheet.x + m.sheet.w / 2 |
| 216 | if (centred && !near(centre, m.vw / 2, 1.5)) fail(`${w}: the sheet's centre is ${centre}, want ${m.vw / 2} (centred)`) |
| 217 | if (!centred && (!near(m.sheet.r, m.vw - (248 + 12 + 16), 1.5) || !near(m.sheet.w, 816))) fail(`${w}: the sheet is ${m.sheet.w}px wide ending at ${m.sheet.r}, want 816 ending at ${m.vw - 276}`) |
| 218 | if (m.sheet.r > m.inspector.x - 16 + 0.5) fail(`${w}: the sheet (ends ${m.sheet.r}) runs under the inspector (starts ${m.inspector.x})`) |
| 219 | await context.close() |
| 220 | } |
| 221 | |
| 222 | // 5. 1000px: the strip, open or closed. |
| 223 | for (const inspector of ['', 'closed']) { |
| 224 | const { context, page } = await open(1000, 800, { inspector }) |
| 225 | const m = await measure(page) |
| 226 | await shot(page, '1000' + (inspector ? '-closed' : '')) |
| 227 | const leg = `1000${inspector ? ' closed' : ''}` |
| 228 | if (!near(m.header.h, 56)) fail(`${leg}: the header is ${m.header.h}px, want 56`) |
| 229 | if (m.inspectorPosition === 'fixed' || !m.toolbar.drawn || !m.bold.drawn) fail(`${leg}: the strip is not drawn (inspector ${m.inspectorPosition}, toolbar drawn ${m.toolbar.drawn})`) |
| 230 | if (!(m.toolbar.y >= m.header.b - 0.5 && m.toolbar.h < 60)) fail(`${leg}: the strip is not one row under the header: ${JSON.stringify(m.toolbar)}`) |
| 231 | if (m.format.drawn) fail(`${leg}: Format is drawn with no inspector to toggle`) |
| 232 | if (m.label.drawn) fail(`${leg}: the inspector's labels are drawn in the strip`) |
| 233 | if (!m.lead.drawn || m.stripHistory.drawn) fail(`${leg}: want the header's undo/redo (drawn ${m.lead.drawn}) and not the strip's (drawn ${m.stripHistory.drawn})`) |
| 234 | await context.close() |
| 235 | } |
| 236 | |
| 237 | // 6. 390px: the phone: the compact bar (design/phone-web, P1). |
| 238 | { |
| 239 | const { context, page } = await open(390, 844) |
| 240 | const m = await measure(page) |
| 241 | await shot(page, '390') |
| 242 | const extra = await page.evaluate(() => { |
| 243 | const drawn = (s) => { const e = document.querySelector(s); return !!e && (typeof e.checkVisibility === 'function' ? e.checkVisibility() : e.getClientRects().length > 0) } |
| 244 | return { aa: drawn('[docs-aa]'), more: drawn('[docs-more] > summary'), title: drawn('[docs-title-block]') } |
| 245 | }) |
| 246 | if (!near(m.header.h, 52)) fail(`390: the compact bar is ${m.header.h}px tall, want one 52px row`) |
| 247 | if (m.menubar.drawn) fail(`390: the menus are drawn in the compact bar: ${JSON.stringify(m.menubar)}`) |
| 248 | if (!m.lead.drawn || m.stripHistory.drawn) fail(`390: want the header's undo/redo (drawn ${m.lead.drawn}) and not the strip's (drawn ${m.stripHistory.drawn})`) |
| 249 | if (!extra.aa || !extra.more || !extra.title) fail(`390: Aa ${extra.aa}, ••• ${extra.more}, the large title ${extra.title}; want all three`) |
| 250 | if (m.bold.drawn) fail('390: the formatting controls are drawn before Aa asks for them') |
| 251 | await page.click('[docs-aa]', { timeout: 3000 }).catch(() => fail('390: Aa could not be pressed')) |
| 252 | await page.waitForTimeout(300) |
| 253 | const a = await measure(page) |
| 254 | await shot(page, '390-aa') |
| 255 | // P2: Aa opens the Format sheet, the inspector as a bottom sheet. |
| 256 | const vh = await page.evaluate(() => innerHeight) |
| 257 | if (!a.bold.drawn || a.inspectorPosition !== 'fixed') fail(`390: Aa did not open the Format sheet (inspector ${a.inspectorPosition}, bold drawn ${a.bold.drawn})`) |
| 258 | if (!near(a.inspector.b, vh, 1) || !(a.inspector.h > vh * 0.4 && a.inspector.h < vh * 0.6)) fail(`390: the sheet is not half the screen at its foot: ${JSON.stringify(a.inspector)} in ${vh}`) |
| 259 | if (await page.evaluate(() => document.querySelectorAll('[estilo-menubar]').length) !== 1) fail('390: more than one menu bar') |
| 260 | await context.close() |
| 261 | } |
| 262 | |
| 263 | // 6b. 720px, the 704-799px band: the desktop header (estilo P0, compact |
| 264 | // bars only), the lead's undo/redo in it and the strip under it. |
| 265 | { |
| 266 | const { context, page } = await open(720, 900) |
| 267 | const m = await measure(page) |
| 268 | await shot(page, '720') |
| 269 | if (!near(m.header.h, 56)) fail(`720: the header is ${m.header.h}px, want 56`) |
| 270 | if (!m.menubar.drawn || !(m.menubar.y < m.header.b)) fail(`720: the menus are not in the header: ${JSON.stringify(m.menubar)}`) |
| 271 | if (!m.lead.drawn || m.stripHistory.drawn) fail(`720: want the header's undo/redo (drawn ${m.lead.drawn}) and not the strip's (drawn ${m.stripHistory.drawn})`) |
| 272 | if (!m.toolbar.drawn || !(m.toolbar.y >= m.header.b - 0.5)) fail(`720: the strip is not under the header: ${JSON.stringify(m.toolbar)}`) |
| 273 | if (m.scrollWidth > m.cw) fail(`720: the page scrolls sideways, ${m.scrollWidth} in ${m.cw}`) |
| 274 | await context.close() |
| 275 | } |
| 276 | |
| 277 | // 8. A short window (review on #106): the inspector stops 12px above |
| 278 | // the window's foot and scrolls, and a picker's list opened in it is |
| 279 | // not clipped by it. |
| 280 | { |
| 281 | const { context, page } = await open(1280, 300) |
| 282 | const g = await page.evaluate(() => { |
| 283 | const el = document.querySelector('[docs-inspector]') |
| 284 | const r = el.getBoundingClientRect() |
| 285 | return { bottom: r.bottom, vh: innerHeight, scroll: el.scrollHeight, client: el.clientHeight, anchors: CSS.supports('anchor-name: --x') } |
| 286 | }) |
| 287 | if (g.anchors && !(g.bottom <= g.vh - 12 + 0.5 && g.scroll > g.client)) fail(`300px tall: the inspector ends at ${g.bottom} in ${g.vh} (scroll ${g.scroll}, client ${g.client}); want it inside the window, scrolling`) |
| 288 | await page.click('#docs-select-font-combo') |
| 289 | await page.waitForSelector('[docs-inspector] [rst-combo]:has(#docs-select-font-combo) [rst-combo-list]:not([hidden])', { timeout: 5000 }).catch(() => {}) |
| 290 | const l = await page.evaluate(() => { |
| 291 | const list = document.querySelector('[docs-inspector] [rst-combo]:has(#docs-select-font-combo) [rst-combo-list]') |
| 292 | const box = document.querySelector('[docs-inspector]').getBoundingClientRect() |
| 293 | const r = list.getBoundingClientRect() |
| 294 | // A point of the list outside the inspector's box and inside the |
| 295 | // window, if it has one: the middle of the band where it hangs |
| 296 | // below the box (or above it), at the list's centre line. |
| 297 | const x = Math.min(innerWidth - 1, Math.max(0, (r.left + r.right) / 2)) |
| 298 | const below = [box.bottom, Math.min(r.bottom, innerHeight)] |
| 299 | const above = [Math.max(r.top, 0), box.top] |
| 300 | const outside = below[1] - below[0] > 2 ? { x, y: (below[0] + below[1]) / 2 } : above[1] - above[0] > 2 ? { x, y: (above[0] + above[1]) / 2 } : null |
| 301 | const hit = outside && document.elementFromPoint(outside.x, outside.y) |
| 302 | return { list: { t: r.top, b: r.bottom, l: r.left, r: r.right, h: r.height }, box: { t: box.top, b: box.bottom, l: box.left, r: box.right }, outside, inList: !!(hit && list.contains(hit)), position: getComputedStyle(list).position } |
| 303 | }) |
| 304 | if (!g.anchors) { /* no anchor positioning: the panel does not scroll, and the lists are its own (show.html) */ } else if (!l.outside) fail(`300px tall: the font list (${JSON.stringify(l.list)}) never leaves the inspector (${JSON.stringify(l.box)}): it is clipped by it, or select.js shrank it to the room the inspector leaves (both mean the panel is the list's clipping box)`) |
| 305 | else if (!l.inList) fail(`300px tall: the font list is clipped where it leaves the inspector (${JSON.stringify(l)})`) |
| 306 | await context.close() |
| 307 | } |
| 308 | |
| 309 | // 7. 320px: nothing overflows the page. |
| 310 | { |
| 311 | const { context, page } = await open(320, 720) |
| 312 | const m = await measure(page) |
| 313 | await shot(page, '320') |
| 314 | if (m.scrollWidth > m.cw) fail(`320: the page scrolls sideways, ${m.scrollWidth} in ${m.cw}`) |
| 315 | await context.close() |
| 316 | } |
| 317 | |
| 318 | await browser.close() |
| 319 | } |
| 320 | |
| 321 | if (failures.length) { |
| 322 | for (const f of failures) console.log('FAIL ' + f) |
| 323 | process.exit(1) |
| 324 | } |
| 325 | console.log('ok: the I2 header, inspector, Format, undo/redo, sheet centring and narrow layouts, in both engines') |
| 326 | |