title: Accessing variables in browser.runtime.getBackgroundPage()
body: <p>I'm currently building a browser extension with <code>create-react-app</code> as the base, trying to use getBackgroundPage() instead of the messaging API to communicate between the background scripts (I have 3 defined) and the new tab page, but it seems like calling browser.runtime.getBackgroundPage() in the new tab page returns a Window object without any of my functions or variables from the background scripts attached as Window properties.</p>
  
  <p>The below returns a "variable not defined" error and "page.foo() is not a function".</p>
  
  <pre><code>// background_3.js
  
  var test = [];
  
  // Some stuff so webpack doesn't get rid of the unused variable.
  for (let i = 0; i &lt; 10; ++i) {
      test.push(i);
  }
  
  function foo() {
      console.log("foo");
  }
  </code></pre>
  
  <pre><code>// New Tab React page
  import browser from "webextension-polyfill";
  
  browser.runtime.getBackgroundPage()
      .then(page =&gt; {
          console.log(page.test);
          page.foo();
      });
  </code></pre>
  
  <p>Is there something I'm doing wrong? Should I just use the message API instead?</p>