chromium/chrome/test/data/extensions/api_test/app_background_page/common/b.html

<script src="common.js"></script>
<h1 id="status">Page B</h1>
<div style="display:none" id="pageToScriptTunnel"></div>
<div style="display:none" id="scriptToPageTunnel"></div>

<script>
var backgroundWindow;

window.onload = function() {
  setupScriptTunnel();
  backgroundWindow = window.open('', 'bg');
  setStatus('background page retrieved');
  backgroundWindow.onPageBLoaded(window);
}

function onBackgroundPageResponded() {
  if (!backgroundWindow.checkAndIncrementCounter(1)) {
    setStatus('counter has unexpected value');
    return;
  }
  
  setStatus('background responded');
  notifyBackgroundPageResponded();
  backgroundWindow.onPageBUnloading();
  window.close();
}
</script>