Getting the contents from a window.open()'ed window after redirect
<p>I have a web application that runs in Chrome with Same-Origin Policy disabled (i.e., <code>--disable-web-security</code>). I use <code>window.open()</code> to create a new window that loads a URI that sometimes redirects. If no redirect occurs, I can read the contents of the document hosted inside the window using the <code>document</code> property when the <code>onload</code> event fires. Unfortunately, in cases where a redirect does occur, it seems that <code>onload</code> never fires, and the window object returned from <code>window.open()</code> is no longer useful.</p>

<p>Here's the code, to give you an idea of what's going on:</p>

<pre><code>var win = window.open('http://somewhere');
win.onload = function() {
  doStuffWith(win.document.body);
  win.close();
};
</code></pre>

<p>Is there any way that I can hold on to a valid <code>window</code> handle even when a redirect occurs immediately after the new window is opened?</p>

<hr>

<p>Per @CBroe's suggestion I extended my code to see if I can get at the contents of the window if I wait a little while. After the code above, I appended:</p>

<pre><code>setTimeout(function() {
  console.log(win.location);
  doStuffWith(win.document.body);
}, 5000);
</code></pre>

<p>The <code>location</code> is reported as <code>swappedout://</code> (huh!?) and the document's body is empty.</p>