Commit db6a8e87 authored by Edgar Chen's avatar Edgar Chen Committed by echen@mozilla.com
Browse files

Bug 1967450 – Ensure listener is registered on clipboard test page before...

Bug 1967450 – Ensure listener is registered on clipboard test page before continuing the test; r=nika

Differential Revision: https://phabricator.services.mozilla.com/D250246
parent dd148290
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ function testPasteContextMenuSuppressionPasteEvent(
    await BrowserTestUtils.withNewTab(
      kContentFileUrl,
      async function (browser) {
        info(`Write data by in cross-origin frame`);
        info(`Write data in cross-origin frame`);
        const clipboardText = "X" + Math.random();
        await SpecialPowers.spawn(
          browser.browsingContext.children[1],
@@ -300,6 +300,15 @@ function testPasteContextMenuSuppressionPasteEvent(
            })();
          `);
        });
        // Input events is dispatched with higher priority, and may therefore
        // occur before the `SpecialPowers.spawn` call above is processed on the
        // remote side to register the event listener. So add a delay to ensure
        // the event listener is registered before the paste event is triggered.
        await SpecialPowers.spawn(aBrowser, [], () => {
          return new Promise(resolve => {
            SpecialPowers.executeSoon(resolve);
          });
        });

        if (aSuppress) {
          let listener = function (e) {