Artifact viewer: full screen view; HTML scrolls, pans and zooms; links open safely
Full screen button in the viewer's bottom bar opens a root full-screen route with the same bar and top bar; exit by the bar, Close, Escape or back. It renders the already fetched bytes, never the system browser. The external Open action is now labelled Open in browser. Native web views claim their gestures (vertical drags inline, every pointer in full screen) so the page swipe no longer starves them. On the web, full screen adds zoom buttons that scale the live sandboxed frame. Links: in-page anchors scroll, http(s)/mailto open outside, everything else is inert. Capture kit: --touch, swipe=, pinch=, tabs=; html=1 fixture artifact.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// enable semantics, find targets by semantics label / identifier / point,
|
||||
// click, type, screenshot and film.
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
import { enableTouch, pinch, swipe } from './touch.mjs';
|
||||
|
||||
/** Parses `label:Text`, `key:id`, `xy:10,20`, `10,20` or bare `Text` (a label). */
|
||||
export function parseTarget(target) {
|
||||
@@ -45,7 +46,7 @@ const LABELS = `(() => [...document.querySelectorAll('flt-semantics, [aria-label
|
||||
rect: [r.left, r.top, r.width, r.height].map(Math.round) }; })
|
||||
.filter((n) => (n.label || n.key) && n.rect[2] > 0 && n.rect[3] > 0))()`;
|
||||
|
||||
export function flutterPage(browser, log) {
|
||||
export function flutterPage(browser, log, { touch = false } = {}) {
|
||||
const { send } = browser;
|
||||
let viewport = { width: 880, height: 1000 };
|
||||
const errors = [];
|
||||
@@ -110,6 +111,9 @@ export function flutterPage(browser, log) {
|
||||
await until(() => evaluate("Boolean(document.querySelector('flt-semantics-placeholder'))"), 'Flutter to start', 30000);
|
||||
await evaluate("document.querySelector('flt-semantics-placeholder')?.click()");
|
||||
await until(() => evaluate("document.querySelectorAll('flt-semantics').length > 0"), 'the semantics tree', 15000);
|
||||
// Touch starts once semantics is on: the placeholder's click does not
|
||||
// turn semantics on under touch emulation.
|
||||
if (touch) await enableTouch(send, viewport);
|
||||
await delay(800);
|
||||
},
|
||||
async click(target, timeout) {
|
||||
@@ -181,6 +185,10 @@ export function flutterPage(browser, log) {
|
||||
if (!hold) await mouse('mouseReleased', at.x + dx, at.y + dy, { buttons: 0, clickCount: 1 });
|
||||
return { from: at, to: { x: at.x + dx, y: at.y + dy } };
|
||||
},
|
||||
/** One-finger touch swipe from [target] by dx/dy (needs `--touch true`). */
|
||||
swipe: async (target, moves) => swipe(send, await locate(target), moves),
|
||||
/** Two-finger touch pinch at [target] by [scale] (needs `--touch true`). */
|
||||
pinch: async (target, scale) => pinch(send, await locate(target), scale),
|
||||
evaluate,
|
||||
/** Screencasts [ms] after clicking [target]; frames are `{ data, ms }` relative to the click. */
|
||||
async film(target, ms) {
|
||||
|
||||
Reference in New Issue
Block a user