glidercli 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bin/glider.js +84 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,6 +172,7 @@ Copy `config/domains.template.json` into `~/.glider/config/domains.json` to seed
|
|
|
172
172
|
| `glider connect` | attach relay to browser |
|
|
173
173
|
| `glider status` | server, extension, tabs |
|
|
174
174
|
| `glider goto` / `eval` / `click` / `type` | page ops |
|
|
175
|
+
| `glider frozen` / `thaw` | detect / un-throttle a hidden (macrotask-frozen) tab in place |
|
|
175
176
|
| `glider screenshot` | PNG capture |
|
|
176
177
|
| `glider explore` | crawl + HAR |
|
|
177
178
|
| `glider resolve` | host → local warch intel (`--json`) |
|
package/bin/glider.js
CHANGED
|
@@ -1546,6 +1546,83 @@ async function cmdFrozen(opts = []) {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
1548
1548
|
|
|
1549
|
+
// Thaw a macrotask-frozen tab WITHOUT touching the OS window.
|
|
1550
|
+
//
|
|
1551
|
+
// Chrome throttles/pauses macrotasks (setTimeout, fetch, XHR, workers, and MSAL
|
|
1552
|
+
// token refresh) on any tab whose window is minimized or fully occluded --
|
|
1553
|
+
// document.visibilityState reports 'hidden' and `glider frozen` exits 1. Neither
|
|
1554
|
+
// Page.bringToFront nor Target.activateTarget un-hide a minimized window, so the
|
|
1555
|
+
// tab stays frozen. Emulation.setFocusEmulationEnabled + Page.setWebLifecycleState
|
|
1556
|
+
// ('active') flip the renderer to a focused/active lifecycle state and un-throttle
|
|
1557
|
+
// it in place -- async fires again within a couple hundred ms, no window restore
|
|
1558
|
+
// needed. Reverse of `glider frozen` (which only detects). Idempotent.
|
|
1559
|
+
async function cmdThaw(opts = []) {
|
|
1560
|
+
let sessionId = null;
|
|
1561
|
+
let all = false;
|
|
1562
|
+
let verify = false;
|
|
1563
|
+
for (let i = 0; i < opts.length; i++) {
|
|
1564
|
+
const a = opts[i];
|
|
1565
|
+
if (a === '--session' || a === '--sessionId') sessionId = opts[++i];
|
|
1566
|
+
else if (a === '--all') all = true;
|
|
1567
|
+
else if (a === '--verify') verify = true;
|
|
1568
|
+
else if (a === '--help') {
|
|
1569
|
+
console.log('Usage: glider thaw [--session <id>] [--all] [--verify]');
|
|
1570
|
+
console.log(' Un-throttle a macrotask-frozen (hidden/minimized) tab in place so');
|
|
1571
|
+
console.log(' setTimeout/fetch/XHR/workers + token refresh resume -- no window restore.');
|
|
1572
|
+
console.log(' --all thaw every attached tab');
|
|
1573
|
+
console.log(' --verify re-check visibility + async liveness after thawing');
|
|
1574
|
+
console.log(' Reverse of `glider frozen` (detect). Idempotent.');
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
if (!await ensureConnected()) process.exit(1);
|
|
1579
|
+
|
|
1580
|
+
let sessions;
|
|
1581
|
+
if (all) {
|
|
1582
|
+
const raw = await httpGet('/targets');
|
|
1583
|
+
sessions = (Array.isArray(raw) ? raw : []).map((t) => t.sessionId).filter(Boolean);
|
|
1584
|
+
if (!sessions.length) { log.warn('No targets to thaw'); return; }
|
|
1585
|
+
} else {
|
|
1586
|
+
sessions = [sessionId || activeSessionId || null];
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
const results = [];
|
|
1590
|
+
for (const sid of sessions) {
|
|
1591
|
+
const p1 = { method: 'Emulation.setFocusEmulationEnabled', params: { enabled: true } };
|
|
1592
|
+
const p2 = { method: 'Page.setWebLifecycleState', params: { state: 'active' } };
|
|
1593
|
+
if (sid) { p1.sessionId = sid; p2.sessionId = sid; }
|
|
1594
|
+
try {
|
|
1595
|
+
await httpPost('/cdp', p1);
|
|
1596
|
+
await httpPost('/cdp', p2);
|
|
1597
|
+
const entry = { sessionId: sid || activeSessionId || '(pinned)', thawed: true };
|
|
1598
|
+
if (verify) {
|
|
1599
|
+
const vp = { method: 'Runtime.evaluate', params: { expression: `document.visibilityState`, returnByValue: true } };
|
|
1600
|
+
if (sid) vp.sessionId = sid;
|
|
1601
|
+
const vr = await httpPost('/cdp', vp);
|
|
1602
|
+
entry.visibilityState = vr?.result?.value;
|
|
1603
|
+
const ap = { method: 'Runtime.evaluate', params: { expression: `new Promise(r=>setTimeout(()=>r('ALIVE'),250))`, returnByValue: true, awaitPromise: true } };
|
|
1604
|
+
if (sid) ap.sessionId = sid;
|
|
1605
|
+
const ar = await httpPost('/cdp', ap);
|
|
1606
|
+
entry.asyncAlive = ar?.result?.value === 'ALIVE';
|
|
1607
|
+
}
|
|
1608
|
+
results.push(entry);
|
|
1609
|
+
} catch (e) {
|
|
1610
|
+
results.push({ sessionId: sid || '(pinned)', thawed: false, error: e.message });
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
if (jsonOutput) {
|
|
1615
|
+
emitJson(true, all ? { thawed: results } : results[0]);
|
|
1616
|
+
} else {
|
|
1617
|
+
for (const r of results) {
|
|
1618
|
+
if (!r.thawed) { log.fail(`thaw failed (${r.sessionId}): ${r.error}`); continue; }
|
|
1619
|
+
let extra = '';
|
|
1620
|
+
if (verify) extra = ` - visibilityState=${r.visibilityState} asyncAlive=${r.asyncAlive}`;
|
|
1621
|
+
log.ok(`thawed ${r.sessionId}${extra}`);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1549
1626
|
// List cookies for a URL (including HttpOnly) via extension chrome.cookies.getAll bridge.
|
|
1550
1627
|
// Primitive: extension_ws_bridge (background.js exposes method:'getCookies').
|
|
1551
1628
|
// Note: this reads via the CRX cookies API - HttpOnly cookies (ESTSAUTH, s.SessID etc.)
|
|
@@ -2483,7 +2560,8 @@ ${YELLOW}DOMAIN EXTENSIONS:${NC}
|
|
|
2483
2560
|
console.log(` ${GREEN}${'pdf'.padEnd(16)}${NC} ${DIM}[PATH] [--landscape] [--margin N] [--scale F]${NC}`);
|
|
2484
2561
|
console.log(` ${GREEN}${'mock'.padEnd(16)}${NC} ${DIM}<url-glob> --status N --body FILE | mock clear${NC}`);
|
|
2485
2562
|
console.log(` ${GREEN}${'a11y'.padEnd(16)}${NC} ${DIM}Accessibility.getFullAXTree (snapshot --a11y flag equivalent)${NC}`);
|
|
2486
|
-
console.log(` ${GREEN}${'frozen'.padEnd(16)}${NC} ${DIM}
|
|
2563
|
+
console.log(` ${GREEN}${'frozen'.padEnd(16)}${NC} ${DIM}detect if tab is macrotask-frozen (hidden); exit 1 = frozen${NC}`);
|
|
2564
|
+
console.log(` ${GREEN}${'thaw'.padEnd(16)}${NC} ${DIM}un-throttle a frozen/hidden tab in place (--all --verify); aka unfreeze/wake${NC}`);
|
|
2487
2565
|
console.log('');
|
|
2488
2566
|
}
|
|
2489
2567
|
|
|
@@ -3963,6 +4041,11 @@ async function main() {
|
|
|
3963
4041
|
case 'frozen':
|
|
3964
4042
|
await cmdFrozen(args.slice(1));
|
|
3965
4043
|
break;
|
|
4044
|
+
case 'thaw':
|
|
4045
|
+
case 'unfreeze':
|
|
4046
|
+
case 'wake':
|
|
4047
|
+
await cmdThaw(args.slice(1));
|
|
4048
|
+
break;
|
|
3966
4049
|
case 'cookies':
|
|
3967
4050
|
if (args.slice(1).some(a => a === '--set' || a === '--delete')) {
|
|
3968
4051
|
await cmdCookieWrite(args.slice(1));
|
package/package.json
CHANGED