summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/contextMenu/browser_copy_image_link.js
blob: 4853006a618c30747714b254dd33c268ffd2afe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
 * Testcase for bug 1719203
 * <https://bugzilla.mozilla.org/show_bug.cgi?id=1719203>
 *
 * Load firebird.png, redirect it to doggy.png, and verify that "Copy Image
 * Link" copies firebird.png.
 */

add_task(async function () {
  // This URL will redirect to doggy.png.
  const URL_FIREBIRD =
    "http://mochi.test:8888/browser/browser/base/content/test/contextMenu/firebird.png";

  await BrowserTestUtils.withNewTab(URL_FIREBIRD, async function (browser) {
    // Click image to show context menu.
    let popupShownPromise = BrowserTestUtils.waitForEvent(
      document,
      "popupshown"
    );
    await BrowserTestUtils.synthesizeMouseAtCenter(
      "img",
      { type: "contextmenu", button: 2 },
      browser
    );
    await popupShownPromise;

    await SimpleTest.promiseClipboardChange(URL_FIREBIRD, () => {
      document.getElementById("context-copyimage").doCommand();
    });

    // Close context menu.
    let contextMenu = document.getElementById("contentAreaContextMenu");
    let popupHiddenPromise = BrowserTestUtils.waitForEvent(
      contextMenu,
      "popuphidden"
    );
    contextMenu.hidePopup();
    await popupHiddenPromise;
  });
});