Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): typing after a click by coordinates no longer hangs a preview tab #32845

MergedEntrpi(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/32845/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 141 additions and 39 deletions.

x
0 of 2 viewed, 2 left
68 additions and 0 deletionsapps/server/src/preview/ServerBrowserPage.test.tsModified
View file
@@ -214,6 +214,25 @@
expect(await page.getByRole("textbox", { name: "parent" }).inputValue()).toBe("");
});
​
+ it("types after a click by coordinates into a shadow-root field, and refuses a field inside an editable frame", async () => {
+ await page.setContent(
+ `<div id="host"></div><div contenteditable="true"><iframe srcdoc="<input id=inner>"></iframe></div><script>document.getElementById("host").attachShadow({mode:"open"}).innerHTML = "<input id=field>";</script>`,
+ );
+ const field = page.locator("#host #field");
+ const box = (await field.boundingBox())!;
+ await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
+ await ServerBrowserPage.type(page, { text: "shadow" });
+ expect(await field.inputValue()).toBe("shadow");
+​
+ // Refused for now: focus inside a frame cannot be checked from the top document.
+ const inner = page.frameLocator("iframe").locator("#inner");
+ await inner.click();
+ await expect(ServerBrowserPage.type(page, { text: "frame" })).rejects.toMatchObject({
+ tag: "PreviewAutomationTargetNotEditableError",
+ });
+ expect(await inner.inputValue()).toBe("");
+ });
+​
it("shows dotted fields as dots wherever their value appears, keeping text values and refs", async () => {
await page.setContent(`
<table><tr><td>password:</td><td><input id="pw" type="password" aria-label="Password"></td></tr></table>
@@ -717,6 +736,55 @@
});
});