RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
// The built-in browser shows about:blank as a transparent surface with no frame image, and paints real pages, in both themes.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const name = "browser/blankPage";
|
||||
await runSmoke(name, async ({ browser }) => {
|
||||
const output = await outputDir(name);
|
||||
for (const theme of ["light", "dark"]) {
|
||||
const page = await openPage(browser, { viewport: { width: 1100, height: 780 } });
|
||||
await mockTauri(page, {
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "C:\\blank-page", files: { "sample.md": "# Sample\n" } }),
|
||||
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
||||
browser_request: args => {
|
||||
if (args.command === "frameAck") window.blankAcks = (window.blankAcks || 0) + 1;
|
||||
return window.browserSnapshot;
|
||||
},
|
||||
}),
|
||||
});
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText("blank-page", { exact: true }).waitFor();
|
||||
await page.evaluate(async theme => {
|
||||
(await import("/src/lib/theme/appearance.ts")).saveAppearance({ theme: "default", mode: theme });
|
||||
const { mount } = await import("/node_modules/svelte/src/index-client.js");
|
||||
const { default: Browser } = await import("/src/lib/browser/Browser.svelte");
|
||||
const client = await import("/src/lib/browser/client.ts");
|
||||
const container = document.createElement("div");
|
||||
container.id = "browser-test";
|
||||
Object.assign(container.style, { position: "fixed", inset: "50px 10px 20px", zIndex: "2000", background: "linear-gradient(120deg,#945975,#395c72)" });
|
||||
document.body.append(container);
|
||||
window.browserSnapshot = { profiles: [{ id: "user", name: "User" }], tabs: [{ id: "blank", profileId: "user", url: "about:blank", title: "", loading: false }], bookmarks: [], settings: {} };
|
||||
client.state.set(window.browserSnapshot);
|
||||
mount(Browser, { target: container, props: { initial: { tabId: "blank" }, onSessionChange() {}, async newTab() {} } });
|
||||
window.browserClient = client;
|
||||
}, theme);
|
||||
const surface = page.locator("#browser-test .surface");
|
||||
await page.locator('#browser-test [data-browser-state="ready"]').waitFor();
|
||||
await page.evaluate(() => window.browserClient.frames.get("blank")({ tabId: "blank", frameId: 1, width: 10, height: 10, mime: "image/png", data: "AA==" }));
|
||||
assert.equal(await surface.evaluate(node => getComputedStyle(node).backgroundColor), "rgba(0, 0, 0, 0)");
|
||||
assert.equal(await surface.locator("img").count(), 0);
|
||||
assert.equal(await page.evaluate(() => window.blankAcks), 1);
|
||||
await page.screenshot({ path: path.join(output, `${theme}-blank-browser.png`) });
|
||||
await page.evaluate(() => {
|
||||
window.browserSnapshot.tabs[0].url = "https://example.com/minimal";
|
||||
window.browserClient.state.set({ ...window.browserSnapshot });
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 10;
|
||||
canvas.height = 10;
|
||||
const context = canvas.getContext("2d");
|
||||
context.fillStyle = "white";
|
||||
context.fillRect(0, 0, 10, 10);
|
||||
window.browserClient.frames.get("blank")({ tabId: "blank", frameId: 2, width: 10, height: 10, mime: "image/png", data: canvas.toDataURL().split(",")[1] });
|
||||
});
|
||||
await surface.locator("img").waitFor();
|
||||
assert.notEqual(await surface.evaluate(node => getComputedStyle(node).backgroundColor), "rgba(0, 0, 0, 0)");
|
||||
assert.deepEqual(page.errors, []);
|
||||
await page.close();
|
||||
console.log(`PASS: ${theme} blank and painted browser pages`);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user