Commit d86a582b authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1741797 - [devtools] Fix colorpicker click listener signature r=nchevobbe

parent 4fc02f6f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -42,5 +42,22 @@ add_task(async function() {
  await waitForElementAttributeSet("root", "hidden", helper);
  ok(true, "The eyedropper is now hidden");

  info("Check that the clipboard still contains the copied color");
  is(SpecialPowers.getClipboardData("text/unicode"), "#ff0000");

  info("Replace the clipboard content with another text");
  SpecialPowers.clipboardCopyString("not-a-color");
  is(SpecialPowers.getClipboardData("text/unicode"), "not-a-color");

  info("Click on the page again, check the clipboard was not updated");
  await BrowserTestUtils.synthesizeMouseAtCenter(
    "body",
    {},
    gBrowser.selectedBrowser
  );
  // Wait 500ms because nothing is observable when the test is successful.
  await wait(500);
  is(SpecialPowers.getClipboardData("text/unicode"), "not-a-color");

  finalize();
});
+9 −8
Original line number Diff line number Diff line
@@ -162,14 +162,15 @@ class EyeDropper {
    // Start listening for user events.
    const { pageListenerTarget } = this.highlighterEnv;
    this.#pageEventListenersAbortController = new AbortController();
    const config = {
      signal: this.#pageEventListenersAbortController.signal,
    };
    pageListenerTarget.addEventListener("mousemove", this, config);
    pageListenerTarget.addEventListener("click", this, true, config);
    pageListenerTarget.addEventListener("keydown", this, config);
    pageListenerTarget.addEventListener("DOMMouseScroll", this, config);
    pageListenerTarget.addEventListener("FullZoomChange", this, config);
    const signal = this.#pageEventListenersAbortController.signal;
    pageListenerTarget.addEventListener("mousemove", this, { signal });
    pageListenerTarget.addEventListener("click", this, {
      signal,
      useCapture: true,
    });
    pageListenerTarget.addEventListener("keydown", this, { signal });
    pageListenerTarget.addEventListener("DOMMouseScroll", this, { signal });
    pageListenerTarget.addEventListener("FullZoomChange", this, { signal });

    // Show the eye-dropper.
    this.getElement("root").removeAttribute("hidden");