1
0
Fork 0
firefox/browser/base/content/test/contextMenu/browser_save_image.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

47 lines
1.2 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const MockFilePicker = SpecialPowers.MockFilePicker;
add_setup(async function () {
MockFilePicker.init(window.browsingContext);
registerCleanupFunction(async () => {
MockFilePicker.cleanup();
});
});
add_task(async function test_save_image_canvas() {
await BrowserTestUtils.withNewTab(
"data:text/html;charset=utf-8,<canvas></canvas>",
async browser => {
let menu = document.getElementById("contentAreaContextMenu");
let popupShown = BrowserTestUtils.waitForEvent(menu, "popupshown");
let filePicker = waitForFilePicker();
BrowserTestUtils.synthesizeMouseAtCenter(
"canvas",
{ type: "contextmenu", button: 2 },
browser
);
await popupShown;
menu.activateItem(menu.querySelector("#context-saveimage"));
await filePicker;
}
);
});
function waitForFilePicker() {
return new Promise(resolve => {
MockFilePicker.showCallback = () => {
MockFilePicker.showCallback = null;
ok(true, "Saw the file picker");
resolve();
};
});
}