title: Global function declared in background page does not get called via evaluateHandle
body: <p>I have a global function in background page like so:</p>
  
  <pre class="lang-js prettyprint-override"><code>window.myfn = function(){
      return new Promise((resolve, reject) =&gt; { stuff; });
  };
  </code></pre>
  
  <p>I am using Jest and Puppeteer. Consider this in my <code>test.js</code> file:</p>
  
  <pre class="lang-js prettyprint-override"><code>async function getBackgroundPage() {
      const targets = await browser.targets(),
          backgroundPageTarget = targets.find(
              target =&gt; target.type() === "background_page",
          ),
          backgroundPage = await backgroundPageTarget.page();
  
      return backgroundPage;
  }
  
  async function sendUpdate() {
      const bgPage = await getBackgroundPage(),
          argString = `() =&gt; window.myfn()`;
      await bgPage.evaluateHandle(argString);
      await sleep(30000);
  }
  </code></pre>
  
  <p><code>getBackgroundPage</code> is literally copied from the <a href="https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageevaluatehandlepagefunction-args" rel="nofollow noreferrer">docs</a>, so I hope it's correct. However, <code>sendUpdate()</code> does not work as expected. Ideally, <code>window.myfn</code> should be called but actually it is never called. I know this because:</p>
  
  <ol>
  <li>I put several <code>console.log</code>s in it, so if it was called there should have been some log output.</li>
  <li>The 30second sleep gives me enough time to goto <code>chrome://extensions</code>, and open the background page console via Inspect Views, and I could not find any log outputs there.</li>
  </ol>
  
  <p>There are no errors in both the background page, and the Jest console. What is the problem then? Why is that global function not being called?</p>