Files
workinf_Blender_Wasm/tools/web/.probe61.mjs
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

53 lines
3.7 KiB
JavaScript

import { createRequire } from "node:module";
import path from "node:path";
const { chromium } = createRequire(import.meta.url)("/home/mes123456/workinf_Blender_Wasm/web/node_modules/playwright");
const browser = await chromium.launch({ headless: true, executablePath: "/usr/bin/google-chrome-stable",
args: ["--no-sandbox","--use-gl=swiftshader","--enable-unsafe-swiftshader","--enable-unsafe-webgpu","--enable-dawn-features=allow_unsafe_apis","--use-webgpu-adapter=swiftshader"] });
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
const page = await ctx.newPage();
await page.addInitScript(() => {
const reg = []; window.__w = reg;
window.Worker = new Proxy(window.Worker, { construct(t, a) { const w = Reflect.construct(t, a); reg.push({ url: String(a[0]), worker: w }); return w; } });
});
await page.goto("http://127.0.0.1:5412/?ui=web", { waitUntil: "domcontentloaded" });
await page.waitForFunction(() => document.body.innerText.includes("WASM ABI: ready"), undefined, { timeout: 120000 });
await page.getByTestId("blend-file-input").setInputFiles("/home/mes123456/workinf_Blender_Wasm/tests/files/web/hierarchy_simplify_combined.blend");
await page.waitForFunction(() => /SceneIR r\d+/.test(document.querySelector('[data-testid="engine-status"]')?.textContent ?? ""), undefined, { timeout: 120000 });
await page.waitForTimeout(3500);
const snap = () => page.evaluate(() => new Promise((resolve, reject) => {
const worker = window.__w.find(x => /web-engine\.worker/.test(x.url))?.worker;
const requestId = 'p-' + Math.random();
const timer = setTimeout(() => reject(new Error('timeout')), 30000);
const recv = ({ data }) => { if (data.requestId === requestId) { clearTimeout(timer); resolve(data); } };
worker.addEventListener('message', recv);
worker.postMessage({ requestId, command: { type: 'snapshot' } });
}));
const parents = async () => {
const r = await snap(); const s = r.result?.snapshot;
return { rev: s?.revision, p: Object.fromEntries((s?.nodes ?? []).map(n => [n.name, n.parentId ? s.nodes.find(x => x.id === n.parentId)?.name : null])) };
};
for (const name of ['Parts','Mount','RootRig']) {
const btn = page.getByRole('button', { name: `展开 ${name}`, exact: true }).first();
if (await btn.count()) { await btn.click(); await page.waitForTimeout(2200); }
}
console.log("BEFORE", JSON.stringify(await parents()));
// Drop Payload onto empty container space with and without Shift.
const drop = (name, shift) => page.evaluate(({ n, shiftKey }) => {
const row = [...document.querySelectorAll('[role="treeitem"]')].find(x => (x.getAttribute('aria-label')||'').trim() === n);
const tree = document.querySelector('.outliner-tree');
if (!row || !tree) return { error: 'missing', rows: [...document.querySelectorAll('[role=\"treeitem\"]')].map(x => (x.getAttribute('aria-label')||'').trim()).filter(Boolean) };
const dt = new DataTransfer();
row.dispatchEvent(new DragEvent('dragstart', { bubbles: true, cancelable: true, dataTransfer: dt }));
// target the container itself, not a row: dispatch directly on it
tree.dispatchEvent(new DragEvent('dragover', { bubbles: true, cancelable: true, dataTransfer: dt, shiftKey }));
const handled = !tree.dispatchEvent(new DragEvent('drop', { bubbles: true, cancelable: true, dataTransfer: dt, shiftKey }));
return { handled, payload: dt.getData('application/x-web-blender-objects') };
}, { n: name, shiftKey: shift });
console.log("DROP-NO-SHIFT", JSON.stringify(await drop('Payload', false)));
await page.waitForTimeout(5000);
console.log("AFTER-NO-SHIFT", JSON.stringify(await parents()));
console.log("DROP-SHIFT", JSON.stringify(await drop('Payload', true)));
await page.waitForTimeout(8000);
console.log("AFTER-SHIFT", JSON.stringify(await parents()));
await browser.close();