Improve window.closed fidelity.

Have window.close() mark the window object as closing, so that we can
return a more precise result for window.closed immediately upon return.

Otherwise window.closed would only transition to |true| after the deferred
closing operation has gone ahead. This exposes internal details and timing
to scripts, which is preferably avoided.

Spec-wise, for "close a browsing context",

 https://html.spec.whatwg.org/#close-a-browsing-context

window.closed will transition to |true| at the start of step 3, with
unloading&discarding (steps 3-5) being executed asynchronously (when
the deferred close operation runs.) This implies that window.closed
will return true before |pagehide| and |unload| events have been
dispatched as part of step 3 (but _after_ |beforeunload| dispatching
and handling, step 2.) This is not correct with the spec, it should
only happen once step 5 has run, but the behavior aligns with Gecko.
It is thought to be quite unlikely that unload handlers depend on
window.closed being |false| rather than |true| when run.

R=haraken,mkwst
BUG=472379

Review URL: https://codereview.chromium.org/1053073002

git-svn-id: svn://svn.chromium.org/blink/trunk@193255 bbb929c8-8fbe-4397-9dbb-9b2b20218538
5 files changed
tree: b21e42d7a400fd75bd2484df5927593501b98eed
  1. third_party/