title: SetBypassCSP on new tab in Puppeteer
body: <p>I'm opening the following html page in Puppeteer:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!-- head --&gt;
  
  &lt;body&gt;
      &lt;a class="btn-tab" href="html_simple.html" target="_blank"&gt;new tab&lt;/a&gt;
  &lt;/body&gt;
  
  &lt;!-- more web --&gt;
  </code></pre>
  
  <p>Clicking on the button will open a new tab. </p>
  
  <p>In my javascript code I have the following:</p>
  
  <pre><code>const context = page.browserContext();
  
  
  context.on('targetcreated', async (target) =&gt; {
      const newPage = await target.page();
      if (newPage) {
          await newPage.setBypassCSP(true);
      }
  });
  </code></pre>
  
  <p>However, when opening the new page, the CSP bypass is still disabled (throws a content security error when loading some scripts). I assume that this is because the <code>targetcreated</code> event is thrown after the new page navigation, and, as the Puppeteer docs states:</p>
  
  <blockquote>
    <p>NOTE CSP bypassing happens at the moment of CSP initialization rather then evaluation. Usually this means that page.setBypassCSP should be called before navigating to the domain.</p>
  </blockquote>
  
  <p>Which seems to be the case, as executing <code>page.reload()</code> and <code>setBypassCSP</code> before loading these scripts seems to work.</p>
  
  <p>My question is how to set bypassCSP to true on a tab opened by a web? Is there an event before loading content or global setup in Puppeteer that allows me to do it?</p>