From 4257a9bf03f8ebbd6cc8b41933b6c5b619611662 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 17 May 2017 21:20:38 -0700 Subject: [PATCH] Centralize setting the active document This makes browsing context's active document a getter, returning browsing context's WindowProxy object's [[Window]] internal slot's associated Document. This removes some service worker text that was added in #1776. Reinstating that in some manner is #2687. Fixes #2657, fixes #2676. --- source | 119 +++++++++++++++++++++++---------------------------------- 1 file changed, 47 insertions(+), 72 deletions(-) diff --git a/source b/source index 46187dd95b3..fe314299914 100644 --- a/source +++ b/source @@ -77085,13 +77085,14 @@ dictionary DragEventInit : MouseEventInit {

A browsing context has a session history, which lists the Document objects that the browsing context has presented, is presenting, - or will present. At any time, one Document in each browsing context is - designated the active document. - A Document's browsing context is the browsing context - whose session history contains the Document, if any such browsing - context exists and has not been discarded.

+ or will present. A browsing context's active document is + its WindowProxy object's [[Window]] + internal slot value's associated + Document. A Document's browsing context is the + browsing context whose session history contains the + Document, if any such browsing context exists and has not been discarded.

In general, there is a 1-to-1 mapping from the Window object to the Document object, as long as the Document object has a DragEventInit : MouseEventInit { browsing context, since that browsing context was discarded.

+

To set the active document of a browsing context + browsingContext to a Document object document, optionally with + a Window object window, run these steps:

+ +
    +
  1. +

    If window is not given, let window be document's relevant global object.

    + +

    Per this standard document can be created before + window, which does not make much sense. See issue #2688.

    +
  2. + +
  3. Set browsingContext's WindowProxy object's [[Window]] internal slot value to + window.

  4. + +
  5. Set window's associated + Document to document.

  6. + +
  7. Set window's relevant settings object's execution ready flag.

  8. +
+

A browsing context can have a creator browsing context, @@ -77183,16 +77209,8 @@ dictionary DragEventInit : MouseEventInit {

  • Ensure that document has a single child html node, which itself has two empty child nodes: a head element, and a body element.

  • -
  • Set window's associated - Document to document.

  • - -
  • -

    Set browsingContext's WindowProxy object's - [[Window]] internal slot - value to window.

    - -

    The internal slot value is updated when navigations occur.

    -
  • +
  • Set the active document of browsingContext to + document.

  • Set the origin of document:

    @@ -77218,9 +77236,6 @@ dictionary DragEventInit : MouseEventInit {
  • Set the allow* flags for document.

  • -
  • Set settingsObject's execution ready flag.

  • -
  • Add document to browsingContext's session history.

  • @@ -82508,20 +82523,14 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O additionally run the following algorithm after creating the new object:

      -
    1. Let window be null.

    2. - -
    3. Let settingsObject be null.

    4. -
    5. If browsingContext's only entry in its session history is the about:blank Document that was added when browsingContext was created, and navigation is occurring with replacement enabled, and that Document has the same - origin as the new Document, then set window to the - Window object of that Document, and set settingsObject to - window's relevant settings object.

    6. + origin as the new Document, then do nothing.

    7. -

      Otherwise,

      +

      Otherwise:

      1. @@ -82530,8 +82539,7 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O with the following customizations:

          -
        • For the global object, create a new Window object and set - window to it.

        • +
        • For the global object, create a new Window object.

        • For the global this value, use browsingContext's WindowProxy object.

        • @@ -82542,18 +82550,10 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O
        • Set up a window environment settings object with realm execution - context and reservedEnvironment, if present, and set - settingsObject to the result.

        • + context and reservedEnvironment, if present.

    8. -
    9. Set window's associated - Document to the new Document.

    10. - -
    11. Set browsingContext's WindowProxy object's - [[Window]] internal slot - value to window.

    12. -
    13. Set the Document's HTTPS state to the HTTPS state of the response used to generate the document.

    14. @@ -82585,35 +82585,7 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O
    15. Implement the sandboxing for the Document.

    16. Set the allow* flags for the Document.

    17. - -
    18. Set settingsObject's execution ready flag.

    19. - -
    20. -

      If settingsObject's active service worker is not null, - then:

      - -
        -
      1. -

        If settingsObject is a secure context, - then:

        - -
          -
        1. If browsingContext has an opener browsing context and - request's client is a non-secure context, then disown browsingContext's opener.

        2. -
        -
      2. - -
      3. Otherwise, set settingsObject's active service worker to - null.

      4. -
      -
    - -
  • Make entry's Document object the - active document of the browsing context.

  • +
  • Set the active document of the browsing + context to entry's Document object.

  • @@ -90628,14 +90600,17 @@ document.body.appendChild(frame)
  • Let realm execution context be the created JavaScript execution context.

  • - -
  • Set window's associated - Document to document.

  • +

    This is not universally implemented and can perhaps be + removed; see issue #1698.

    +
  • Set up a window environment settings object with realm execution context.

  • +
  • Set the active document of document's browsing + context to document with window.

  • +
  • Replace document's singleton objects with new instances of those objects, created in window's Realm. (This includes in particular the History, ApplicationCache, and