Change farm password to 1722
This commit is contained in:
1 parent
c957a0ffe3
commit
2efe74998c
7 files changed
+790
-8
No files matched your search
@@ -62,7 +62,7 @@ semua 8 browser langsung terhubung otomatis (tanpa login per cell).
|
|||||||
## Login: satu password untuk seluruh farm
|
## Login: satu password untuk seluruh farm
|
||||||
|
|
||||||
- **Satu login, bukan 8.** Grid dikunci satu password (defaultnya sama
|
- **Satu login, bukan 8.** Grid dikunci satu password (defaultnya sama
|
||||||
dengan password Neko: `pendol1722`). Setelah login, sesi berlaku
|
dengan password Neko: `1722`). Setelah login, sesi berlaku
|
||||||
7 hari (cookie `farm_auth`, httpOnly).
|
7 hari (cookie `farm_auth`, httpOnly).
|
||||||
- **Cell auto-connect.** Manager login sendiri ke tiap instance Neko
|
- **Cell auto-connect.** Manager login sendiri ke tiap instance Neko
|
||||||
(`POST /api/login` dengan user `pend`) dan menyisipkan token sesi ke
|
(`POST /api/login` dengan user `pend`) dan menyisipkan token sesi ke
|
||||||
|
|||||||
@@ -76,9 +76,9 @@
|
|||||||
<button id="refreshBtn" type="button">Refresh</button>
|
<button id="refreshBtn" type="button">Refresh</button>
|
||||||
<button id="startAllBtn" type="button" class="primary">Start semua</button>
|
<button id="startAllBtn" type="button" class="primary">Start semua</button>
|
||||||
<button id="stopAllBtn" type="button">Stop semua</button>
|
<button id="stopAllBtn" type="button">Stop semua</button>
|
||||||
<button id="syncBtn" type="button" title="Saat ON, kendalikan 1 browser dan semua browser lain ikut (klik, scroll, ketik).">Sinkron: OFF</button>
|
<button id="syncBtn" type="button" title="Saat ON, kendalikan 1 browser dan semua browser lain ikut (klik, scroll, ketik, paste).">Sinkron: OFF</button>
|
||||||
</header>
|
</header>
|
||||||
<p class="note"><b>Cara pakai:</b> login sekali dengan password farm — semua browser langsung terhubung otomatis. Tiap cell adalah browser Chromium sendiri (profil, cookie, dan IP terpisah). Settings mengubah User-Agent & proxy, lalu browser restart otomatis. <b>Sinkron:</b> nyalakan tombol di atas, lalu klik/ketik di satu browser — semua browser lain ikut melakukan hal yang sama. Browser yang terakhir kamu sentuh jadi Master (badge kuning).</p>
|
<p class="note"><b>Cara pakai:</b> login sekali dengan password farm — semua browser langsung terhubung otomatis. Tiap cell adalah browser Chromium sendiri (profil, cookie, dan IP terpisah). Settings mengubah User-Agent & proxy, lalu browser restart otomatis. <b>Sinkron:</b> nyalakan tombol di atas, lalu klik/ketik/paste di satu browser — semua browser lain ikut melakukan hal yang sama. Browser yang terakhir kamu sentuh jadi Master (badge kuning).</p>
|
||||||
<div class="banner" id="banner"></div>
|
<div class="banner" id="banner"></div>
|
||||||
<main class="grid" id="grid"></main>
|
<main class="grid" id="grid"></main>
|
||||||
|
|
||||||
@@ -367,10 +367,14 @@
|
|||||||
|
|
||||||
function handler(e) { onCellInput(id, e); }
|
function handler(e) { onCellInput(id, e); }
|
||||||
|
|
||||||
// Mouse + wheel + keyboard: exactly the events the Overlay listens
|
// Mouse + wheel + keyboard + paste: the events the Overlay listens
|
||||||
// to. (The Overlay uses mouse events, not pointer events, so we
|
// to. (The Overlay uses mouse events, not pointer events, so we
|
||||||
// mirror mouse events — a PointerEvent would be ignored by it.)
|
// mirror mouse events — a PointerEvent would be ignored by it.)
|
||||||
['mousemove', 'mousedown', 'wheel', 'keydown', 'keyup'].forEach(function (type) {
|
// Paste is mirrored too: the Overlay reads the pasted text from the
|
||||||
|
// paste event's clipboardData (see mirrorInput), and a Ctrl+V
|
||||||
|
// keydown alone never pastes — the Overlay swallows the 'v' key and
|
||||||
|
// waits for the paste event.
|
||||||
|
['mousemove', 'mousedown', 'wheel', 'keydown', 'keyup', 'paste'].forEach(function (type) {
|
||||||
input.addEventListener(type, handler, false);
|
input.addEventListener(type, handler, false);
|
||||||
});
|
});
|
||||||
// mouseup can happen outside the textarea (the Overlay itself
|
// mouseup can happen outside the textarea (the Overlay itself
|
||||||
@@ -419,7 +423,77 @@
|
|||||||
if (!master || !master.inputEl) return;
|
if (!master || !master.inputEl) return;
|
||||||
var type = e.type;
|
var type = e.type;
|
||||||
if (type !== 'mousemove' && type !== 'mousedown' && type !== 'mouseup' &&
|
if (type !== 'mousemove' && type !== 'mousedown' && type !== 'mouseup' &&
|
||||||
type !== 'wheel' && type !== 'keydown' && type !== 'keyup') return;
|
type !== 'wheel' && type !== 'keydown' && type !== 'keyup' &&
|
||||||
|
type !== 'paste') return;
|
||||||
|
|
||||||
|
// Paste: Neko's Overlay reads the pasted text from the paste event's
|
||||||
|
// clipboardData (client/core/src/overlay.ts: it listens for 'paste'
|
||||||
|
// on the textarea and calls onPaste(clipboardData.getData('text/plain')),
|
||||||
|
// which sets the remote clipboard via preparePaste and then sends a
|
||||||
|
// Ctrl+V keystroke). A mirrored Ctrl+V keydown alone never pastes —
|
||||||
|
// the Overlay swallows the 'v' key — so the text itself has to be
|
||||||
|
// carried over: read it once from the master's paste event and
|
||||||
|
// dispatch an equivalent paste into every follower's textarea, so
|
||||||
|
// each follower's Overlay processes it exactly like a real paste.
|
||||||
|
// (The synthetic events have isTrusted=false, so each follower's own
|
||||||
|
// grid listener ignores them — no feedback loop.)
|
||||||
|
if (type === 'paste') {
|
||||||
|
var text = '';
|
||||||
|
try {
|
||||||
|
text = (e.clipboardData && e.clipboardData.getData('text/plain')) || '';
|
||||||
|
} catch (err) { text = ''; }
|
||||||
|
// Empty clipboard (no text, or no clipboard permission): do
|
||||||
|
// nothing rather than dispatching an empty paste that would make
|
||||||
|
// followers send preparePaste('') + Ctrl+V to their remotes.
|
||||||
|
if (!text) return;
|
||||||
|
Object.keys(cells).forEach(function (fid) {
|
||||||
|
if (fid === masterId) return;
|
||||||
|
var f = cells[fid];
|
||||||
|
if (!f || !f.inputEl) return;
|
||||||
|
if (!f._browser || f._browser.status !== 'running') return;
|
||||||
|
try {
|
||||||
|
var fwin = f.inputEl.ownerDocument.defaultView;
|
||||||
|
if (!fwin) return;
|
||||||
|
var dt = null;
|
||||||
|
try {
|
||||||
|
if (typeof fwin.DataTransfer === 'function') {
|
||||||
|
dt = new fwin.DataTransfer();
|
||||||
|
dt.setData('text/plain', text);
|
||||||
|
}
|
||||||
|
} catch (err) { dt = null; }
|
||||||
|
if (!dt) {
|
||||||
|
// No DataTransfer in this engine: a minimal clipboardData-like
|
||||||
|
// object. Neko only calls getData('text/plain').
|
||||||
|
dt = {
|
||||||
|
getData: function (t) { return t === 'text/plain' ? text : ''; },
|
||||||
|
setData: function () {},
|
||||||
|
types: ['text/plain'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var ev = null;
|
||||||
|
try {
|
||||||
|
if (typeof fwin.ClipboardEvent === 'function') {
|
||||||
|
ev = new fwin.ClipboardEvent('paste', {
|
||||||
|
bubbles: true, cancelable: true, clipboardData: dt,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) { ev = null; }
|
||||||
|
if (!ev) ev = new fwin.Event('paste', { bubbles: true, cancelable: true });
|
||||||
|
// Make sure the dispatched event actually carries the text even
|
||||||
|
// when the ClipboardEvent constructor ignored the clipboardData
|
||||||
|
// init: shadow the prototype getter on the instance.
|
||||||
|
try {
|
||||||
|
var got = (ev.clipboardData && ev.clipboardData.getData)
|
||||||
|
? ev.clipboardData.getData('text/plain') : null;
|
||||||
|
if (got !== text) Object.defineProperty(ev, 'clipboardData', { value: dt });
|
||||||
|
} catch (err) { /* ignore */ }
|
||||||
|
f.inputEl.dispatchEvent(ev);
|
||||||
|
} catch (err) {
|
||||||
|
// A follower that is not ready must never break the grid.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Throttle mousemove mirroring (~60fps) so a fast drag does not
|
// Throttle mousemove mirroring (~60fps) so a fast drag does not
|
||||||
// flood the followers with synthetic events. Clicks, wheel and keys
|
// flood the followers with synthetic events. Clicks, wheel and keys
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ const CONFIG_PATH = path.join(__dirname, 'config.json');
|
|||||||
const GENERATE_SCRIPT = path.join(__dirname, '..', 'scripts', 'generate.js');
|
const GENERATE_SCRIPT = path.join(__dirname, '..', 'scripts', 'generate.js');
|
||||||
// Single password for the whole farm: the grid login AND every Neko
|
// Single password for the whole farm: the grid login AND every Neko
|
||||||
// instance's password. Must match FARM_PASSWORD in scripts/install.sh.
|
// instance's password. Must match FARM_PASSWORD in scripts/install.sh.
|
||||||
const FARM_PASSWORD = process.env.FARM_PASSWORD || 'pendol1722';
|
const FARM_PASSWORD = process.env.FARM_PASSWORD || '1722';
|
||||||
const NEKO_LOGIN_USER = 'pend';
|
const NEKO_LOGIN_USER = 'pend';
|
||||||
const TOKEN_TTL_MS = 55 * 60 * 1000; // Neko tokens are re-fetched every 55 min
|
const TOKEN_TTL_MS = 55 * 60 * 1000; // Neko tokens are re-fetched every 55 min
|
||||||
const SESSION_TTL_MS = 7 * 24 * 60 * 60 * 1000; // farm login lasts 7 days
|
const SESSION_TTL_MS = 7 * 24 * 60 * 60 * 1000; // farm login lasts 7 days
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ set -euo pipefail
|
|||||||
# ---- settings (change FARM_PASSWORD before first run if you want) ----
|
# ---- settings (change FARM_PASSWORD before first run if you want) ----
|
||||||
FARM_ROOT="/opt/farm"
|
FARM_ROOT="/opt/farm"
|
||||||
APP_DIR="/opt/browser-farm"
|
APP_DIR="/opt/browser-farm"
|
||||||
FARM_PASSWORD="pendol1722"
|
FARM_PASSWORD="1722"
|
||||||
NEKO_IMAGE="m1k1o/neko:chromium"
|
NEKO_IMAGE="m1k1o/neko:chromium"
|
||||||
VPS_IP="49.128.191.144"
|
VPS_IP="49.128.191.144"
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|||||||
Generated
+342
@@ -0,0 +1,342 @@
|
|||||||
|
{
|
||||||
|
"name": "sync-test",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "sync-test",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"jsdom": "^31.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@exodus/bytes": {
|
||||||
|
"version": "1.16.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz",
|
||||||
|
"integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@noble/hashes": "^1.8.0 || ^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@noble/hashes": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/bcp-47": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-wsv86UuNFuPnVieKLyECTT+CP1WSAHeoIg5P3xu2kA9Z+7fVPoKt7dxzSeEhtJel0AI+NW3fIW3KtTKQKUCngg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-alphabetical": "^2.0.0",
|
||||||
|
"is-alphanumerical": "^2.0.0",
|
||||||
|
"is-decimal": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/bcp-47-match": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/data-urls": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-mimetype": "^5.0.0",
|
||||||
|
"whatwg-url": "^17.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.14.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/decimal.js": {
|
||||||
|
"version": "10.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",
|
||||||
|
"integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/entities": {
|
||||||
|
"version": "9.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz",
|
||||||
|
"integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/html-encoding-sniffer": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@exodus/bytes": "^1.15.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.13.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-alphabetical": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-alphanumerical": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-alphabetical": "^2.0.0",
|
||||||
|
"is-decimal": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-decimal": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-potential-custom-element-name": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/jsdom": {
|
||||||
|
"version": "31.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz",
|
||||||
|
"integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@exodus/bytes": "^1.16.0",
|
||||||
|
"bcp-47": "^2.1.2",
|
||||||
|
"bcp-47-match": "^2.0.3",
|
||||||
|
"data-urls": "^8.0.0",
|
||||||
|
"decimal.js": "^10.6.0",
|
||||||
|
"html-encoding-sniffer": "^7.0.0",
|
||||||
|
"is-potential-custom-element-name": "^1.0.1",
|
||||||
|
"lru-cache": "^11.5.3",
|
||||||
|
"parse5": "^8.1.0",
|
||||||
|
"parse5-parser-stream": "^8.1.0",
|
||||||
|
"saxes": "^6.0.0",
|
||||||
|
"tough-cookie": "^6.0.2",
|
||||||
|
"undici": "^8.12.3",
|
||||||
|
"w3c-xmlserializer": "^6.0.0",
|
||||||
|
"webidl-conversions": "^8.0.1",
|
||||||
|
"whatwg-mimetype": "^5.0.0",
|
||||||
|
"whatwg-url": "^17.3.0",
|
||||||
|
"xml-name-validator": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@napi-rs/canvas": "^1.0.13"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@napi-rs/canvas": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lru-cache": {
|
||||||
|
"version": "11.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.4.tgz",
|
||||||
|
"integrity": "sha512-B8nJCTi8JuSaDBg0tBdnImV6j5O2CXaqKfdj24ZTCFbyivN8KZ2Z+RL3aHjwJAfLutD9cNnObG4SIgW4gMufiw==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/parse5": {
|
||||||
|
"version": "8.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz",
|
||||||
|
"integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"entities": "^9.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/parse5-parser-stream": {
|
||||||
|
"version": "8.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz",
|
||||||
|
"integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"parse5": "^8.1.1"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/punycode": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/saxes": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"xmlchars": "^2.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v12.22.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tldts": {
|
||||||
|
"version": "7.6.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts/-/tldts-7.6.4.tgz",
|
||||||
|
"integrity": "sha512-wp+ZdvQyov404xynNcjbXoJyeGM28W/aCwMmry/rJ+Y0SsObukJYkWwuxWGbNpIjeqMaEbNUtXPNtPPfI5cTFA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts-core": "^7.6.4"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"tldts": "bin/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tldts-core": {
|
||||||
|
"version": "7.6.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.6.4.tgz",
|
||||||
|
"integrity": "sha512-QywQ9lgQyZMuc3NVlqmuxHOhlwirSdvgD/vDLvX8dZYcYgy1cdri5rY/TXDHcF4J3VBSdJLcJNIJI6zGJ7jE+w==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/tough-cookie": {
|
||||||
|
"version": "6.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz",
|
||||||
|
"integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts": "^7.0.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tr46": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"punycode": "^2.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.14.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/undici": {
|
||||||
|
"version": "8.14.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici/-/undici-8.14.0.tgz",
|
||||||
|
"integrity": "sha512-MqM6wqORYo0jb1WFUwFKZTFWFz6VeBMPj9op5Hq+RvlrQjISQCyLEfx5+/iqOLWC/LL1HliJ5t0NP1BgYpXeVQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22.19.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/w3c-xmlserializer": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"xml-name-validator": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/webidl-conversions": {
|
||||||
|
"version": "8.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",
|
||||||
|
"integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-mimetype": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-url": {
|
||||||
|
"version": "17.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz",
|
||||||
|
"integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@exodus/bytes": "^1.16.0",
|
||||||
|
"tr46": "^7.0.0",
|
||||||
|
"webidl-conversions": "^8.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.14.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/xml-name-validator": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/xmlchars": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "sync-test",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"jsdom": "^31.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,351 @@
|
|||||||
|
'use strict';
|
||||||
|
// Paste-mirroring functional test for the Browser Farm grid.
|
||||||
|
// Loads the REAL manager/public/index.html in jsdom, stubs the manager
|
||||||
|
// API, injects a fake Neko overlay (wrap div holding a <canvas> and a
|
||||||
|
// transparent <textarea>, exactly like the Neko client) into each cell
|
||||||
|
// iframe, then proves:
|
||||||
|
// T1 a paste in the master dispatches a paste with the SAME text into
|
||||||
|
// all 7 followers (read back the way Neko's Overlay reads it:
|
||||||
|
// e.clipboardData.getData('text/plain')), with no feedback loop
|
||||||
|
// T2 the pasted-into cell becomes Master
|
||||||
|
// T3 paste mirroring stops when Sync is OFF
|
||||||
|
// T4 an empty / missing clipboardData pastes nothing into followers
|
||||||
|
// T5 (regression) keydown mirroring still works
|
||||||
|
// T6 fallback path: a follower whose window lacks ClipboardEvent and
|
||||||
|
// DataTransfer still receives the text
|
||||||
|
//
|
||||||
|
// jsdom (v31) does not implement ClipboardEvent or DataTransfer, so the
|
||||||
|
// test polyfills them on every window (top + each iframe) to simulate a
|
||||||
|
// real Chrome. The grid code itself does not depend on the polyfill: it
|
||||||
|
// falls back to a plain Event + a clipboardData-like object when the
|
||||||
|
// constructors are missing.
|
||||||
|
//
|
||||||
|
// Run: node paste-sync-test.js (from this directory)
|
||||||
|
// Exit code 0 = all assertions passed, 1 = at least one failed.
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { JSDOM } = require('jsdom');
|
||||||
|
|
||||||
|
const HTML_PATH = path.join(__dirname, '..', 'manager', 'public', 'index.html');
|
||||||
|
|
||||||
|
let pass = 0;
|
||||||
|
let fail = 0;
|
||||||
|
const failures = [];
|
||||||
|
function check(name, cond, detail) {
|
||||||
|
if (cond) {
|
||||||
|
pass++;
|
||||||
|
console.log(' PASS ' + name);
|
||||||
|
} else {
|
||||||
|
fail++;
|
||||||
|
failures.push(name);
|
||||||
|
console.log(' FAIL ' + name + (detail ? ' (' + detail + ')' : ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// jsdom marks every synthetic event isTrusted=false and the flag is
|
||||||
|
// non-configurable, so a real user event cannot be faked by defining the
|
||||||
|
// property on the event. Instead, override the Event.prototype getter to
|
||||||
|
// consult a set of events the test marks as trusted. The grid's own
|
||||||
|
// synthetic events are never in the set, so they still read false —
|
||||||
|
// which is exactly how the loop-prevention check behaves in a real
|
||||||
|
// browser.
|
||||||
|
const trustedEvents = new WeakSet();
|
||||||
|
function installTrustedEvents(win) {
|
||||||
|
try {
|
||||||
|
Object.defineProperty(win.Event.prototype, 'isTrusted', {
|
||||||
|
get: function () {
|
||||||
|
return trustedEvents.has(this);
|
||||||
|
},
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
} catch (e) { /* already overridden */ }
|
||||||
|
}
|
||||||
|
function markTrusted(ev) {
|
||||||
|
trustedEvents.add(ev);
|
||||||
|
return ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minimal ClipboardEvent / DataTransfer, enough to stand in for Chrome's.
|
||||||
|
// Neko's Overlay only calls clipboardData.getData('text/plain').
|
||||||
|
function installClipboardPolyfill(win) {
|
||||||
|
if (typeof win.DataTransfer !== 'function') {
|
||||||
|
win.DataTransfer = class DataTransfer {
|
||||||
|
constructor() {
|
||||||
|
this._data = {};
|
||||||
|
}
|
||||||
|
setData(type, value) {
|
||||||
|
this._data[type] = String(value);
|
||||||
|
}
|
||||||
|
getData(type) {
|
||||||
|
return this._data[type] || '';
|
||||||
|
}
|
||||||
|
get types() {
|
||||||
|
return Object.keys(this._data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeof win.ClipboardEvent !== 'function') {
|
||||||
|
win.ClipboardEvent = class ClipboardEvent extends win.Event {
|
||||||
|
constructor(type, init) {
|
||||||
|
super(type, init);
|
||||||
|
this.clipboardData = (init && init.clipboardData) || null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sleep(ms) {
|
||||||
|
return new Promise((r) => setTimeout(r, ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
const BROWSERS = [];
|
||||||
|
for (let i = 1; i <= 8; i++) {
|
||||||
|
BROWSERS.push({
|
||||||
|
id: 'b' + i,
|
||||||
|
name: 'Browser ' + i,
|
||||||
|
uaKey: 'chrome_win',
|
||||||
|
uaLabel: 'Chrome Windows',
|
||||||
|
proxy: { type: 'direct' },
|
||||||
|
httpPort: 18080 + i,
|
||||||
|
udpStart: 52000 + (i - 1) * 100,
|
||||||
|
udpEnd: 52000 + (i - 1) * 100 + 99,
|
||||||
|
status: 'running',
|
||||||
|
token: 'tok-b' + i,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const html = fs.readFileSync(HTML_PATH, 'utf8');
|
||||||
|
|
||||||
|
const dom = new JSDOM(html, {
|
||||||
|
url: 'http://localhost/',
|
||||||
|
runScripts: 'dangerously',
|
||||||
|
pretendToBeVisual: true,
|
||||||
|
beforeParse(window) {
|
||||||
|
installClipboardPolyfill(window);
|
||||||
|
installTrustedEvents(window);
|
||||||
|
// Stub the manager API: authenticated, one UA preset, 8 running
|
||||||
|
// browsers with tokens (so every cell auto-connects).
|
||||||
|
window.fetch = (url) => {
|
||||||
|
if (url === '/api/me') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve({ authenticated: true }) });
|
||||||
|
}
|
||||||
|
if (url === '/api/ua-presets') {
|
||||||
|
return Promise.resolve({
|
||||||
|
json: () => Promise.resolve({ presets: { chrome_win: { label: 'Chrome Windows', ua: 'x' } } }),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (url === '/api/browsers') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve({ browsers: BROWSERS }) });
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error('unexpected fetch: ' + url));
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const win = dom.window;
|
||||||
|
const doc = win.document;
|
||||||
|
|
||||||
|
// Wait for checkAuth -> startGrid -> loadPresets -> refresh to build the cells.
|
||||||
|
await sleep(300);
|
||||||
|
const cells = {};
|
||||||
|
for (let i = 1; i <= 8; i++) {
|
||||||
|
const id = 'b' + i;
|
||||||
|
const iframe = doc.querySelector('#cell-' + id + ' iframe');
|
||||||
|
if (!iframe) throw new Error('cell ' + id + ' did not build');
|
||||||
|
cells[id] = { iframe };
|
||||||
|
}
|
||||||
|
check('grid builds 8 cells', Object.keys(cells).length === 8);
|
||||||
|
|
||||||
|
// Inject a fake Neko overlay into each iframe and record what Neko
|
||||||
|
// would receive: a 'paste' listener that reads clipboardData exactly
|
||||||
|
// like Overlay.onPaste does, plus counters for loop detection.
|
||||||
|
for (let i = 1; i <= 8; i++) {
|
||||||
|
const id = 'b' + i;
|
||||||
|
const iframe = cells[id].iframe;
|
||||||
|
const idoc = iframe.contentDocument;
|
||||||
|
const iwin = idoc.defaultView;
|
||||||
|
installClipboardPolyfill(iwin);
|
||||||
|
installTrustedEvents(iwin);
|
||||||
|
// The iframe's document is stuck in 'loading' with no root element
|
||||||
|
// (jsdom never fetches the /bN/ URL). Initialise it with a minimal
|
||||||
|
// skeleton so the fake overlay has a <body> to live in; the pending
|
||||||
|
// navigation does not replace the document afterwards (verified).
|
||||||
|
idoc.open();
|
||||||
|
idoc.write('<!DOCTYPE html><html><head></head><body></body></html>');
|
||||||
|
idoc.close();
|
||||||
|
const wrap = idoc.createElement('div');
|
||||||
|
const canvas = idoc.createElement('canvas');
|
||||||
|
const ta = idoc.createElement('textarea');
|
||||||
|
wrap.appendChild(canvas);
|
||||||
|
wrap.appendChild(ta);
|
||||||
|
idoc.body.appendChild(wrap);
|
||||||
|
cells[id].ta = ta;
|
||||||
|
cells[id].iwin = iwin;
|
||||||
|
cells[id].nekoPastes = []; // texts the fake Neko handler read
|
||||||
|
cells[id].pasteCount = 0; // every paste event seen on this textarea
|
||||||
|
cells[id].keys = []; // keydown keys seen on this textarea
|
||||||
|
ta.addEventListener('paste', (e) => {
|
||||||
|
cells[id].pasteCount++;
|
||||||
|
const t = e.clipboardData ? e.clipboardData.getData('text/plain') : '';
|
||||||
|
cells[id].nekoPastes.push(t);
|
||||||
|
});
|
||||||
|
ta.addEventListener('keydown', (e) => {
|
||||||
|
cells[id].keys.push(e.key);
|
||||||
|
});
|
||||||
|
// Trigger the grid's pollForInput (it runs on iframe load).
|
||||||
|
iframe.dispatchEvent(new win.Event('load'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The grid polls every 500ms for the Neko input; give it time to find
|
||||||
|
// the injected textareas and attach the Sync listeners.
|
||||||
|
await sleep(900);
|
||||||
|
|
||||||
|
const syncBtn = doc.getElementById('syncBtn');
|
||||||
|
function setSync(on) {
|
||||||
|
if ((syncBtn.textContent === 'Sinkron: ON') !== on) syncBtn.click();
|
||||||
|
}
|
||||||
|
function masterBadgeVisible(id) {
|
||||||
|
const b = doc.querySelector('#cell-' + id + ' .badge.master');
|
||||||
|
return b && b.style.display !== 'none';
|
||||||
|
}
|
||||||
|
// Dispatch a paste the way a real user paste arrives: a trusted
|
||||||
|
// ClipboardEvent carrying the text in a DataTransfer.
|
||||||
|
function dispatchTrustedPaste(id, text, opts) {
|
||||||
|
const c = cells[id];
|
||||||
|
const o = opts || {};
|
||||||
|
let dt = null;
|
||||||
|
if (o.noClipboardData !== true) {
|
||||||
|
dt = new c.iwin.DataTransfer();
|
||||||
|
if (text) dt.setData('text/plain', text);
|
||||||
|
}
|
||||||
|
const ev = new c.iwin.ClipboardEvent('paste', {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
clipboardData: dt,
|
||||||
|
});
|
||||||
|
// A real user paste is trusted; mark it so the grid's isTrusted
|
||||||
|
// gate lets it through (jsdom cannot fake the flag directly).
|
||||||
|
markTrusted(ev);
|
||||||
|
c.ta.dispatchEvent(ev);
|
||||||
|
}
|
||||||
|
function dispatchTrustedKey(id, key, code, keyCode) {
|
||||||
|
const c = cells[id];
|
||||||
|
const ev = new c.iwin.KeyboardEvent('keydown', {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
key,
|
||||||
|
code,
|
||||||
|
ctrlKey: false,
|
||||||
|
shiftKey: false,
|
||||||
|
altKey: false,
|
||||||
|
metaKey: false,
|
||||||
|
});
|
||||||
|
// A real user keypress is trusted; mark it so the grid's isTrusted
|
||||||
|
// gate lets it through (jsdom cannot fake the flag directly).
|
||||||
|
try {
|
||||||
|
Object.defineProperty(ev, 'keyCode', { value: keyCode });
|
||||||
|
Object.defineProperty(ev, 'which', { value: keyCode });
|
||||||
|
} catch (e) { /* ignore */ }
|
||||||
|
markTrusted(ev);
|
||||||
|
c.ta.dispatchEvent(ev);
|
||||||
|
}
|
||||||
|
function followerPastes() {
|
||||||
|
const out = {};
|
||||||
|
for (let i = 2; i <= 8; i++) out['b' + i] = cells['b' + i].nekoPastes.slice();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- T1: paste in the master reaches all 7 followers with the same text ----
|
||||||
|
console.log('T1: paste mirrors to all followers');
|
||||||
|
setSync(true);
|
||||||
|
check('Sync ON', syncBtn.textContent === 'Sinkron: ON');
|
||||||
|
dispatchTrustedPaste('b1', 'hello paste');
|
||||||
|
await sleep(50);
|
||||||
|
check('master (b1) got its own paste', JSON.stringify(cells.b1.nekoPastes) === JSON.stringify(['hello paste']), 'got ' + JSON.stringify(cells.b1.nekoPastes));
|
||||||
|
let allSame = true;
|
||||||
|
let allOnce = true;
|
||||||
|
for (let i = 2; i <= 8; i++) {
|
||||||
|
const c = cells['b' + i];
|
||||||
|
if (JSON.stringify(c.nekoPastes) !== JSON.stringify(['hello paste'])) allSame = false;
|
||||||
|
if (c.pasteCount !== 1) allOnce = false;
|
||||||
|
}
|
||||||
|
check('all 7 followers received the same text', allSame, JSON.stringify(followerPastes()));
|
||||||
|
check('no feedback loop (each follower saw exactly 1 paste)', allOnce,
|
||||||
|
Object.keys(followerPastes()).map((k) => k + ':' + cells[k].pasteCount).join(' '));
|
||||||
|
|
||||||
|
// ---- T2: the pasted-into cell becomes Master ----
|
||||||
|
console.log('T2: master selection');
|
||||||
|
check('b1 is Master after pasting', masterBadgeVisible('b1'));
|
||||||
|
check('b2 is not Master', !masterBadgeVisible('b2'));
|
||||||
|
|
||||||
|
// ---- T3: Sync OFF stops paste mirroring ----
|
||||||
|
console.log('T3: Sync OFF stops mirroring');
|
||||||
|
setSync(false);
|
||||||
|
check('Sync OFF', syncBtn.textContent === 'Sinkron: OFF');
|
||||||
|
dispatchTrustedPaste('b1', 'second paste');
|
||||||
|
await sleep(50);
|
||||||
|
let noneNew = true;
|
||||||
|
for (let i = 2; i <= 8; i++) {
|
||||||
|
if (JSON.stringify(cells['b' + i].nekoPastes) !== JSON.stringify(['hello paste'])) noneNew = false;
|
||||||
|
}
|
||||||
|
check('followers received nothing new while OFF', noneNew, JSON.stringify(followerPastes()));
|
||||||
|
check('master still got its own paste while OFF',
|
||||||
|
JSON.stringify(cells.b1.nekoPastes) === JSON.stringify(['hello paste', 'second paste']),
|
||||||
|
'got ' + JSON.stringify(cells.b1.nekoPastes));
|
||||||
|
|
||||||
|
// ---- T4: empty / missing clipboardData pastes nothing ----
|
||||||
|
console.log('T4: empty clipboard does nothing');
|
||||||
|
setSync(true);
|
||||||
|
dispatchTrustedPaste('b1', ''); // empty DataTransfer: getData -> ''
|
||||||
|
await sleep(50);
|
||||||
|
let stillOnlyFirst = true;
|
||||||
|
for (let i = 2; i <= 8; i++) {
|
||||||
|
if (JSON.stringify(cells['b' + i].nekoPastes) !== JSON.stringify(['hello paste'])) stillOnlyFirst = false;
|
||||||
|
}
|
||||||
|
check('empty text pastes nothing into followers', stillOnlyFirst, JSON.stringify(followerPastes()));
|
||||||
|
dispatchTrustedPaste('b1', 'ignored', { noClipboardData: true }); // clipboardData null
|
||||||
|
await sleep(50);
|
||||||
|
let stillOnlyFirst2 = true;
|
||||||
|
for (let i = 2; i <= 8; i++) {
|
||||||
|
if (JSON.stringify(cells['b' + i].nekoPastes) !== JSON.stringify(['hello paste'])) stillOnlyFirst2 = false;
|
||||||
|
}
|
||||||
|
check('null clipboardData pastes nothing into followers', stillOnlyFirst2, JSON.stringify(followerPastes()));
|
||||||
|
|
||||||
|
// ---- T5 (regression): keydown mirroring still works ----
|
||||||
|
console.log('T5: keydown mirroring regression');
|
||||||
|
dispatchTrustedKey('b1', 'a', 'KeyA', 65);
|
||||||
|
await sleep(50);
|
||||||
|
let keysOk = true;
|
||||||
|
for (let i = 2; i <= 8; i++) {
|
||||||
|
if (JSON.stringify(cells['b' + i].keys) !== JSON.stringify(['a'])) keysOk = false;
|
||||||
|
}
|
||||||
|
check('keydown mirrors to all 7 followers', keysOk,
|
||||||
|
Object.keys(cells).map((k) => k + ':' + JSON.stringify(cells[k].keys)).join(' '));
|
||||||
|
|
||||||
|
// ---- T6: fallback when a follower window lacks ClipboardEvent/DataTransfer ----
|
||||||
|
console.log('T6: fallback without ClipboardEvent/DataTransfer');
|
||||||
|
delete cells.b8.iwin.ClipboardEvent;
|
||||||
|
delete cells.b8.iwin.DataTransfer;
|
||||||
|
dispatchTrustedPaste('b1', 'fallback text');
|
||||||
|
await sleep(50);
|
||||||
|
check('b8 (no ClipboardEvent/DataTransfer) still received the text',
|
||||||
|
JSON.stringify(cells.b8.nekoPastes) === JSON.stringify(['hello paste', 'fallback text']),
|
||||||
|
'got ' + JSON.stringify(cells.b8.nekoPastes));
|
||||||
|
let othersOk = true;
|
||||||
|
for (let i = 2; i <= 7; i++) {
|
||||||
|
if (JSON.stringify(cells['b' + i].nekoPastes) !== JSON.stringify(['hello paste', 'fallback text'])) othersOk = false;
|
||||||
|
}
|
||||||
|
check('other followers still received the text', othersOk, JSON.stringify(followerPastes()));
|
||||||
|
|
||||||
|
// ---- summary ----
|
||||||
|
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
||||||
|
if (failures.length) console.log('failed: ' + failures.join(', '));
|
||||||
|
dom.window.close();
|
||||||
|
process.exit(fail ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((e) => {
|
||||||
|
console.error('TEST CRASHED: ' + (e && e.stack ? e.stack : e));
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user