title: Bypass "user gesture" requirement when testing "beforeunload" dialogue in Cypress
body: <p>I am trying to write a Cypress test to validate that a <code>beforeunload</code> dialogue appears when a user tries to navigate away from an incomplete form. </p>
  
  <p>When a user tries to leave a page after interacting with a form,  my site activates a <code>beforeunload</code> dialogue to warn them unsaved data may be lost. Everything works fine when I test the behavior manually but When I try to write a test in Cypress I get </p>
  
  <p><code>'[Intervention] Blocked attempt to show a 'beforeunload' confirmation panel for a frame that never had a user gesture since its load. https://www.chromestatus.com/feature/5082396709879808'</code>.</p>
  
  <p>This is after typing in various fields and simulating <code>click()</code> events. It seams that JS does not trigger a true "user gesture" . I understand why Chrome does this but I would hope there would still be a way to write tests. I've found workarounds for a similar problem with video playback @ <a href="https://github.com/cypress-io/cypress/issues/2376" rel="noreferrer">https://github.com/cypress-io/cypress/issues/2376</a>. But this does not seam to work for "beforeunload". None of the flags I found here seam to work <a href="https://peter.sh/experiments/chromium-command-line-switches/" rel="noreferrer">https://peter.sh/experiments/chromium-command-line-switches/</a></p>
  
  <pre><code>    on('before:browser:launch', (browser = {}, args) =&gt; {
        if (browser.name === 'chrome') {
          // Mac/Linux
          args.push('--disable-gesture-requirement-for-presentation')
        }
        return args
      })
  </code></pre>
  
  <p>Hoping there might be a work around. Can I either simulate an actual "gesture" in Cypress or disable the requirement in Chrome? Any help is greatly appreciated.</p>