| ... | @@ -183,6 +183,37 @@ describe("DesktopApplicationMenu", () => { | ... | @@ -183,6 +183,37 @@ describe("DesktopApplicationMenu", () => { |
| 183 | }), | 183 | }), |
| 184 | ); | 184 | ); |
| 185 | | 185 | |
| | 186 | // Chromium pastes as plain text for the accelerator on its own. Dispatching |
| | 187 | // the action as well injects a second paste, which doubles the pasted text. |
| | 188 | it.effect("leaves the accelerator to Chromium instead of injecting a paste", () => |
| | 189 | Effect.gen(function* () { |
| | 190 | const selectedAction = yield* Deferred.make<string>(); |
| | 191 | const applicationMenuTemplate = |
| | 192 | yield* Deferred.make<readonly Electron.MenuItemConstructorOptions[]>(); |
| | 193 | |
| | 194 | yield* configureMenu(selectedAction, applicationMenuTemplate); |
| | 195 | |
| | 196 | const template = yield* Deferred.await(applicationMenuTemplate); |
| | 197 | const editMenu = template.find((item) => item.label === "Edit"); |
| | 198 | if (!Array.isArray(editMenu?.submenu)) { |
| | 199 | throw new Error("Expected Edit menu submenu to be an array."); |
| | 200 | } |
| | 201 | const pasteAsTextItem = editMenu.submenu.find((item) => item.label === "Paste as Text"); |
| | 202 | if (typeof pasteAsTextItem?.click !== "function") { |
| | 203 | throw new Error("Expected Paste as Text menu item to have a click handler."); |
| | 204 | } |
| | 205 | |
| | 206 | pasteAsTextItem.click( |
| | 207 | {} as Electron.MenuItem, |
| | 208 | {} as Electron.BrowserWindow, |
| | 209 | { |
| | 210 | triggeredByAccelerator: true, |
| | 211 | } as unknown as KeyboardEvent, |
| | 212 | ); |
| | 213 | assert.isFalse(yield* Deferred.isDone(selectedAction)); |
| | 214 | }), |
| | 215 | ); |
| | 216 | |
| 186 | // Zoom must route through DesktopWindow.zoomMain instead of the Electron | 217 | // Zoom must route through DesktopWindow.zoomMain instead of the Electron |
| 187 | // zoom roles: the roles zoom whichever webContents has focus, which breaks | 218 | // zoom roles: the roles zoom whichever webContents has focus, which breaks |
| 188 | // app zoom while an embedded preview WebContentsView holds focus. | 219 | // app zoom while an embedded preview WebContentsView holds focus. |