Bug 774633 - Factor nsWindowWatcher call to SetOpenerScriptPrincipal into a method on nsGlobalWindow. r=jst, a=akeybl
This doesn't change any functionality in the code. Note that the name is currently
a bit of a misnomer, but we change that in the next patch when we rip out the
arguments.
Bug 774633 - Wean SetInitialPrincipalToSubject off some parameters and clean it up. r=jst, a=akeybl
We can remove the fallback to the principal of aParent because we already push the
cx for aParent (callerContextGuard) whenever we're concerned about using its principal.
Bug 774633 - Remove dead mOpenerScriptPrincipal. r=jst, a=akeybl
This value is initialized to null and never set, so we can get rid of it.
Bug 774633 - Fold SetOpenerScriptPrincipal into SetInitialPrincipalToSubject, and make it indempotent and callable without an existing document. r=jst, a=akeybl
There's no reason it has to fail if there's no mDoc, since any document is promptly
blown away with the new about:blank document.

The indempotence is important because we want to be able to call this method
unconditionally in OpenJSWindowInternal (since we may not have gone through
RegisterTopLevelWindow) without worrying about whether we've called it already.
Bug 774633 - Move the call to SetInitialPrincipalToSubject into nsAppShellService::RegisterTopLevelWindow. r=jst, a=akeybl
This means that we get the correct principal on the window before sending notifying
any consumers about the window's creation.
Bug 774633 - Remove "is chrome window" condition for inner window reuse. r=jst, a=akeybl
WouldReuseInnerWindow also returns true if the new window is same-origin with
the old one about:blank document.

This condition exists in order to handle some sloppiness with respect to the
principals on initial about:blank documents. Chrome callers sometimes parent
chrome windows (with XUL document) to content windows. But this parenting causes
us to push the cx of the content window during window creation, meaning that
the subsequent load of chrome://foo.xul blows away the old inner window and any
expandos on it. We can handle this case more precisely by skipping the cx push
for type="chrome" windows.

Furthermore, this was also necessary to prevent the inner window from being
blown away in the call to SetOpenerScriptPrincipal once nsWindowWatcher gets
the window back from the window creator (and after it's already told consumers
about the window via "domwindowcreated"). But we fixed this nastiness in the
previous patches.

So we can remove this case. By doing so, we can prevent inner windows from ever
changing origins, which is very important for compartment security invariants.
Bug 774633 - Assert against switching origins on a compartment. r=jst, a=akeybl
Fix for bug 775543 (Passing a Worker object to console.log() results in a crash). r=bz, a=lsblakk.

--HG--
extra : rebase_source : f8b6628827f0822632f15c5e74ac07d69eab4c0e
Bug 782285 - Don't offer reader in pages with too much reading competition (r=mfinkle, a=akeybl)
Bug 784674 - Better byline fetching in Readability (r=bnicholson, a=lsblakk)
Bug 784680 - Remove utility nodes from Wordpress blog posts (r=bnicholson, a=lsblakk)
Bug 784682 - Penalize nodes with "hidden" class or id in Readability.js (r=bnicholson, a=lsblakk)