diff --git a/source b/source index 85c5a318b60..d04c990b5df 100644 --- a/source +++ b/source @@ -2950,13 +2950,19 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • automatic semicolon insertion
  • early error
  • Directive Prologue +
  • JavaScript execution context
  • +
  • JavaScript execution context stack
  • +
  • running JavaScript execution context
  • Use Strict Directive
  • The Pattern production
  • The FunctionBody production
  • The FunctionCreate abstract operation
  • +
  • The GetActiveScriptOrModule abstract operation
  • The HostPromiseRejectionTracker abstract operation
  • The InitializeHostDefinedRealm abstract operation
  • The NewObjectEnvironment abstract operation
  • +
  • The ParseScript abstract operation
  • +
  • The ScriptEvaluation abstract operation
  • The ToBoolean abstract operation
  • The Abstract Equality Comparison algorithm
  • The Strict Equality Comparison algorithm @@ -49913,8 +49919,8 @@ You cannot submit this form when the field is incorrect. data-x="event-input">input at the select element, and then fire a simple event that bubbles named change at the select element, using the user interaction task source as the task - source. If the stack of script settings objects was not empty when the user agent was - to send select update notifications, then the resulting JavaScript execution context stack was not empty when the user agent + was to send select update notifications, then the resulting input and change events must not be trusted.

    @@ -59119,12 +59125,11 @@ dictionary RelatedEventInit : EventInit { that are also "parser-inserted", to let the parser know when to execute the script.

    -

    The last few pieces of state are the script block's - type, the script block's character - encoding, and the script block's - fallback character encoding. They are determined when the script is prepared, based on - the attributes on the element at that time, and the - script element's node document.

    +

    The last few pieces of state are the script block's + character encoding, and the + script block's fallback character encoding. They are determined when the script is + prepared, based on the attributes on the element at that time, and the script + element's node document.

    When a script element that is not marked as being "parser-inserted" experiences one of the events listed in the following list, the user agent must immediately @@ -59220,19 +59225,18 @@ dictionary RelatedEventInit : EventInit { -

    ...let the script block's type for this - script element be "text/javascript".

    +

    ...let the script block's type for this script element be + "text/javascript".

    Otherwise, if the script element has a type attribute, let the - script block's type for this script element be the value of that attribute - with any leading or trailing sequences of space characters - removed.

    + data-x="attr-script-type">type
    attribute, let the script block's type for + this script element be the value of that attribute with any leading or trailing + sequences of space characters removed.

    Otherwise, the element has a non-empty language - attribute; let the script block's type for this - script element be the concatenation of the string "text/" - followed by the value of the language attribute.

    + attribute; let the script block's type for this script element be the + concatenation of the string "text/" followed by the value of the language attribute.

    @@ -59240,13 +59244,9 @@ dictionary RelatedEventInit : EventInit { conforming, and is always ignored if there is a type attribute present.

    -
  • - -
  • - -

    If the user agent does not support the scripting language given by the script block's type for this script element, - then the user agent must abort these steps at this point. The script is not executed.

    +

    If the script block's type for this script element is not + "text/javascript", then the user agent must abort these steps at this + point. No script is executed.

  • @@ -59601,8 +59601,7 @@ dictionary RelatedEventInit : EventInit {
    -
    If the script is from an external file and the script - block's type is a text-based language
    +
    If the script is from an external file
    @@ -59626,12 +59625,7 @@ dictionary RelatedEventInit : EventInit {
  • -

    If the specification for the script block's - type gives specific rules for decoding files in that format to Unicode, follow - them, using character encoding as the character encoding specified by - higher-level protocols, if necessary.

    - -

    Otherwise, decode the file to Unicode, using character +

    Decode the file to Unicode, using character encoding as the fallback encoding.

    The decode algorithm overrides character @@ -59643,19 +59637,7 @@ dictionary RelatedEventInit : EventInit {

  • -
    If the script is from an external file and the script - block's type is an XML-based language
    - -
    - -

    The external file is the script source. When it is later executed, it must be - interpreted in a manner consistent with the specification defining the language given by - the script block's type.

    - -
    - -
    If the script is inline and the script block's - type is a text-based language
    +
    If the script is inline
    @@ -59664,16 +59646,6 @@ dictionary RelatedEventInit : EventInit {
    -
    If the script is inline and the script block's - type is an XML-based language
    - -
    - -

    The child nodes of the script element at the time the element's - "already started" flag was last set are the script source.

    - -
    -
    @@ -59717,10 +59689,9 @@ dictionary RelatedEventInit : EventInit {
  • Create a script, using the script - block's source, the URL from which the script was obtained, the script block's type as the scripting language, and - the environment settings object of the script element's - node document's Window object.

    + block's source, the URL from which the script was obtained, and the + environment settings object of the script element's node + document's Window object.

    If the script came from a resource that was fetched in the steps above, and the resource was CORS-cross-origin, then pass the muted errors flag to the @@ -59890,15 +59861,6 @@ o............A....e

    Scripting languages
    -
    - -

    A user agent is said to support the scripting language if each component of the script block's type is an ASCII - case-insensitive match for the corresponding component in the MIME type string - of a scripting language that the user agent implements.

    - -
    -

    A JavaScript MIME type is a MIME type string that is one of the following and refers to JavaScript:

    @@ -59928,7 +59890,8 @@ o............A....e

    User agents may support other MIME types for other languages, but must not support other MIME types for the languages in the list - above. User agents are not required to support the languages listed above.

    + above. User agents are not required to support JavaScript. The processing model for languages + other than JavaScript is outside the scope of this specification.

    The following MIME types (with or without parameters) must not be interpreted as scripting languages:

    @@ -77557,6 +77520,9 @@ dictionary DragEventInit : MouseEventInit { navigations occur.

  • +
  • Save the JavaScript execution context created as realm execution + context.

  • +
  • Do not obtain any source texts for scripts or modules.

  • @@ -77608,7 +77574,7 @@ dictionary DragEventInit : MouseEventInit { Document to document.

  • Set up a browsing context environment settings object with - window.

  • + realm execution context.

    @@ -81696,9 +81662,9 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O
  • Create a script, using script source as the script - source, address as the script source URL, JavaScript as the scripting - language, and the environment settings object of the Window object of - the active document of the browsing context being navigated.

    + source, address as the script source URL, and the environment settings + object of the Window object of the active document of the + browsing context being navigated.

    Let result be the return value of the code entry-point of this script. If an exception was thrown, let result be void instead. (The result will be void also if 1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O

  • Set window's associated Document to the new Document.

  • + +
  • Let settings object be the environment settings object + created for the browsing context.

  • + +
  • Set settings object's global object to + window.

  • @@ -85772,13 +85744,8 @@ interface NavigatorOnLine {
    -

    A code entry-point represents a block of executable code that the script exposes to other - scripts and to the user agent. Typically, the code corresponding to the code entry-point is - executed immediately after the script is parsed, but for event handlers, it is called each time - the handler is invoked.

    - -

    In JavaScript script blocks, this corresponds to the execution - context of the global code.

    +

    A code entry-point is either a string containing a block of executable code to be evaluated, + or a JavaScript function object. The latter case is used for event handlers.

    @@ -85809,29 +85776,17 @@ interface NavigatorOnLine {
    -
    A script execution environment for each language supported by the user agent
    +
    A realm execution context
    -

    The characteristics of the script execution environment depend on the language, and are not - defined by this specification.

    - -

    In JavaScript, the script execution environment consists of the interpreter, - the stack of execution contexts, the global code and function code and the - Function objects resulting, and so forth.

    - -
    - -
    A global object
    -
    - -

    An object that provides the APIs that can be called by the code in scripts that use this - settings object.

    - -

    This is typically a Window object or a - WorkerGlobalScope object. When a global object is an empty object, it - can't do anything that interacts with the environment.

    - +

    A JavaScript execution context shared by all + scripts that use this settings object, i.e. all scripts in a given + realm. When we jump to a code-entry point, this execution context becomes the + top of the JavaScript execution context stack, on top of which another execution + context specific to the script in question is pushed. (This setup ensures ParseScript and EvaluateScript knows which realm to use.)

    A responsible browsing context
    @@ -85932,6 +85887,14 @@ interface NavigatorOnLine { implementations are free to limit its size, e.g. by removing old entries from it when new ones are added.

    +

    A JavaScript execution context's global object is its Realm component's [[globalObject]] field. An environment + settings object's global object is the global object of its realm execution context.

    + +

    This is typically a Window object or a + WorkerGlobalScope object.

    +

    The relevant settings object for a global object o is the environment settings object whose global object is o. (There is always a 1:1 mapping of global objects to environment settings objects.)

    @@ -85939,39 +85902,34 @@ interface NavigatorOnLine {

    The relevant settings object for a script s is the settings object of s.

    +

    The script corresponding to the running execution context is the + script in the [[HostDefined]] slot of the running JavaScript execution + context's ScriptOrModule.

    Script settings for browsing contexts

    When the user agent is required to set up a browsing context environment settings - object, given a window, it must run the following steps:

    + object, given a JavaScript execution context execution context, it + must run the following steps:

    1. Let url be a copy of the address of the Document with which window associated.

    2. +
    3. Let window be execution context's global object.

    4. +
    5. Let settings object be a new environment settings object whose algorithms are defined as follows:

      -
      The script execution environments
      +
      The realm execution context
      -

      When the environment settings object is created, for each language supported by the - user agent, create an appropriate execution environment as defined by the relevant - specification.

      - -

      When a script execution environment is needed, return the appropriate one from - those created when the environment settings object was created.

      - -
      - -
      The global object
      -
      - -

      Return window.

      +

      Return execution context.

      @@ -86053,64 +86011,86 @@ interface NavigatorOnLine {
      Calling scripts
      -

      Each unit of related similar-origin browsing contexts has a stack of script - settings objects, which must be initially empty. When a new environment settings - object is pushed onto this stack, the specified environment settings object - is to be added to the stack; when the environment settings object on this stack that was - most recently pushed onto it is to be popped from the stack, it must be removed. Entries on - this stack can be labeled as candidate entry - settings objects.

      -

      When a user agent is to jump to a code entry-point for a script s, the user agent must run the following steps:

        -
      1. Let context be the settings object of s.

      2. +
      3. Let settings be the settings object of s.

      4. -
      5. Prepare to run a callback with context as the - environment settings object. If this returns "do not run" then abort these - steps.

      6. +
      7. Assert: s's code entry-point is a string of source text; this + algorithm should never be reached when it is a function.

      8. -
      9. Make the appropriate script execution environment specified by context execute the s's code - entry-point.

      10. +
      11. Prepare to run a callback with settings. If this returns "do not + run" then abort these steps.

      12. + +
      13. Let result be ParseScript(s's + code entry-point, s).

      14. + +
      15. If result is a List of errors, report the exception given by the + first element in result for the script s, and go to the step labeled + cleanup.

      16. + +
      17. Let status be ScriptEvaluation(result).

      18. -
      19. Clean up after running a callback.

      20. +
      21. If status is an abrupt completion, report the exception given by + result.[[value]] for the script s.

      22. + +
      23. Cleanup: Clean up after running a callback with + settings.

      24. + +
      25. If result exists and is not an abrupt completion, return + result.[[value]]. Otherwise, script execution was unsuccessful, either because an + error occurred during parsing, or an exception occurred during evaluation, or because it was + aborted prematurely.

      The steps to prepare to run a callback with an environment settings object - o are as follows. They return either "run" or "do not run".

      + settings are as follows. They return either "run" or "do not run".

        -
      1. If the global object specified by o is a +

      2. If the global object specified by settings is a Window object whose Document object is not fully active, then return "do not run" and abort these steps.

      3. If scripting is disabled for the - responsible browsing context specified by o, then return "do + responsible browsing context specified by settings, then return "do not run" and abort these steps.

        -
      4. Push o onto the stack of script settings objects, and - label it as a candidate entry settings object.

      5. +
      6. Label settings as a candidate entry settings object.

      7. + +
      8. Assert: the JavaScript execution context stack is currently empty.

      9. + +
      10. Push settings's realm execution context onto the JavaScript + execution context stack; it is now the running JavaScript execution + context.

      11. Return "run".

      -

      The steps to clean up after running a callback are as follows:

      +

      The steps to clean up after running a callback with an environment settings + object settings are as follows. are as follows:

        -
      1. Pop the current incumbent settings object from the stack of script - settings objects.

      2. +
      3. Stop labeling settings as a candidate entry settings + object.

      4. + +
      5. Assert: settings's realm execution context is the running + JavaScript execution context.

      6. + +
      7. Remove settings's realm execution context from the + JavaScript execution context stack.

      8. -
      9. If the stack of script settings objects is now empty, run the global +

      10. If the JavaScript execution context stack is now empty, run the global script clean-up jobs. (These cannot run scripts.)

      11. -
      12. If the stack of script settings objects is now empty, perform a +

      13. If the JavaScript execution context stack is now empty, perform a microtask checkpoint. (If this runs scripts, these algorithms will be invoked reentrantly.)

      14. @@ -86120,26 +86100,35 @@ interface NavigatorOnLine { can be invoked reentrantly in an indirect manner, e.g. if a script dispatches an event which has event listeners registered.

        -

        When a JavaScript SourceElements production is to be evaluated, the settings - object of the script corresponding to that - SourceElements must be pushed onto the stack of script settings objects before - the evaluation begins, and popped when the evaluation ends (regardless of whether it's an abrupt - completion or not).

        +

        A JavaScript execution context's settings object is the + settings object of the script in the [[HostDefined]] slot in the + ScriptOrModule component of the given JavaScript execution context.

        -

        The entry settings object is the most-recently added environment settings - object in the stack of script settings objects that is labeled as a - candidate entry settings object. If the stack is empty, or has no entries labeled as - such, then there is no entry settings object. It is used to obtain, amongst other - things, the API base URL to resolve relative - URLs used in scripts running in that unit of related - similar-origin browsing contexts.

        +

        The entry settings object is the settings object of the topmost entry in the JavaScript execution + context stack whose settings object is labeled as a candidate entry settings object.

        -

        The incumbent settings object is the environment settings object in the - stack of script settings objects that was most-recently added (i.e. the last one on - the stack). If the stack is empty, then there is no incumbent settings object. It is - used in some security checks.

        +

        The incumbent settings object is determined as follows:

        + +
          +
        1. Let scriptOrModule be the result of JavaScript's GetActiveScriptOrModule() abstract + operation.

        2. +
        3. If scriptOrModule is null, abort these steps; there is no + incumbent settings object.

        4. +
        5. Return the settings object of the script in + scriptOrModule's [[HostDefined]] internal slot.

        6. +
        + +
        +

        The entry settings object is used to obtain, amongst other things, the API + base URL to resolve relative + URLs used in scripts running in that unit of related + similar-origin browsing contexts.

        -

        The Web IDL specification also uses these algorithms.

        +

        The incumbent settings object is used in some security checks.

        +
        @@ -86165,10 +86154,12 @@ interface NavigatorOnLine { While the hello() function is running, the entry settings object is that of the outer file (a/a.html), and the incumbent settings object is that of the inner file (b/b.html). The assign() method uses - the entry settings object to resolve the URL, so we end up loading a/c.html, but it uses the incumbent settings object to establish - the source browsing context, from which the referrer is established, so the `b/b.html).

        + +

        The assign() method uses the entry settings + object to resolve the URL, so we end up loading a/c.html, but it + uses the incumbent settings object to establish the source browsing + context, from which the referrer is established, so the `Referer` header sent with the request for a/c.html specifies the inner file's URL (the one ending with b/b.html).

        @@ -86197,9 +86188,9 @@ interface NavigatorOnLine {
        Creating scripts

        When the specification says that a script is to be created, given some script source, a script source URL, its - scripting language, an environment settings object, and optionally a muted - errors flag, the user agent must run the following steps:

        + data-x="create a script">created, given some script source, a script source URL, an + environment settings object, and optionally a muted errors flag, the user + agent must run the following steps:

          @@ -86210,30 +86201,17 @@ interface NavigatorOnLine { context passed to this algorithm, then abort these steps, as if the script source described a program that did nothing but return void.

          -
        1. Obtain the appropriate script execution environment for the given scripting - language from the environment settings object provided.

        2. - -
        3. Parse/compile/initialise the source of the script using the script execution - environment, as appropriate for the scripting language, and thus obtain script's code entry-point.

        4. +
        5. Set script's code entry-point to the supplied script + source.

        6. Let script's settings object be the environment settings object provided.

        7. -
        8. If the muted errors flag was set, then set script's muted errors flag.

        9. - -
        10. +
        11. If the muted errors flag was set, then set script's muted + errors flag.

        12. -

          If all the steps above succeeded (in particular, if the script was compiled successfully), - Jump to script's code - entry-point.

          - -

          Otherwise, report the error for script, with the - problematic position (line number and column number), using the global object - specified by the environment settings object as the target. If the error is still not handled after this, then the error may be reported to - a developer console.

          - - +
        13. Jump to script's code + entry-point.

        @@ -86371,10 +86349,6 @@ interface NavigatorOnLine { data-x="concept-error-nothandled">not handled after this, then the error may be reported to the user.

        -

        When an exception is thrown during the execution of one of the scripts associated with a - Document, and the exception is not caught, the user agent must report the - exception.

        -
        The ErrorEvent interface
        @@ -86498,15 +86472,8 @@ dictionary ErrorEventInit : EventInit {
          -
        1. -

          Let script be the script corresponding - to the running execution context.

          - -
          The exact mechanism for correlating ECMAScript's notion of execution contexts - and HTML's notion of scripts is not yet well-defined. See - Bugzilla bug 25981 for - tentative ideas.
          -
        2. +
        3. Let script be the script corresponding to the running execution + context.

        4. If script has muted errors, terminate these steps.

        5. @@ -86993,10 +86960,10 @@ dictionary PromiseRejectionEventInit : EventInit {
        6. Let task source be task's task source.

        7. -
        8. Let old stack of script settings objects be a copy of the stack - of script settings objects.

        9. +
        10. Let old stack be a copy of the JavaScript execution context + stack.

        11. -
        12. Empty the stack of script settings objects.

        13. +
        14. Empty the JavaScript execution context stack.

        15. Run the global script clean-up jobs.

        16. @@ -87019,8 +86986,8 @@ dictionary PromiseRejectionEventInit : EventInit { source task source. Wait until this new task runs before continuing these steps.

          -
        17. Replace the stack of script settings objects with the old - stack of script settings objects.

        18. +
        19. Replace the JavaScript execution context stack with the old + stack.

        20. Return to the caller.

        21. @@ -87123,7 +87090,6 @@ dictionary PromiseRejectionEventInit : EventInit { -

          Events

          Event handlers
          @@ -87470,9 +87436,6 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEvent created for the Window object with which document is currently associated.

          -
        22. Obtain the script execution environment for JavaScript from script settings.

        23. - -
        24. If body is not parsable as FunctionBody @@ -87506,8 +87469,7 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEvent

        25. -

          Using the script execution environment obtained above, let - function be the result of calling Let function be the result of calling FunctionCreate, with arguments:

          @@ -88288,6 +88250,9 @@ interface WindowBase64 {
        26. For the global this value, use the current browsing context's associated WindowProxy.

        27. +
        28. Save the JavaScript execution context created as realm execution + context.

        29. +
        30. Do not obtain any source texts for scripts or modules.

        31. @@ -88295,8 +88260,8 @@ interface WindowBase64 {
        32. Set window's associated Document to the Document.

        33. -
        34. Set up a browsing context environment settings object with - top-level execution context.

        35. +
        36. Set up a browsing context environment settings object with realm + execution context.

        37. @@ -88810,9 +88775,8 @@ interface WindowTimers { object.

        38. Create a script using script source as the script source, - the URL where script source can be found, scripting - language as the scripting language, and settings object as the - environment settings object.

        39. + the URL where script source can be found, and settings + object as the environment settings object.

        @@ -95449,21 +95413,22 @@ interface WorkerGlobalScope : EventTarget { operation with the following customizations:

          -
        • -

          For the global object, if is shared is true, create a new - SharedWorkerGlobalScope object. Otherwise, create a new - DedicatedWorkerGlobalScope object. Let worker global scope be the - created object.

          +
        • For the global object, if is shared is true, create a new + SharedWorkerGlobalScope object. Otherwise, create a new + DedicatedWorkerGlobalScope object. Let worker global scope be the + created object.

        • -

          Set up a worker environment settings object with worker global - scope, and let settings object be the result.

          - +
        • Save the JavaScript execution context created as realm execution + context.

        • Do not obtain any source texts for scripts or modules.

        +
      15. Set up a worker environment settings object with realm execution + context, and let settings object be the result.

      16. +
      17. Associate worker with worker global scope.

      18. Create a new MessagePort object whose WorkerGlobalScope : EventTarget {

      19. Create a new WorkerLocation object and associate it with worker global scope.

        -
      20. - -

        Let script be a new script.

        - -

        Obtain the appropriate script execution environment for the scripting language - language from settings object.

        - -

        Parse/compile/initialise source using that script execution - environment, as appropriate for language, and thus obtain a code - entry-point. If the script was not compiled successfully, let the code - entry-point be a no-op script, and act as if a corresponding uncaught script error had - occurred.

        - -

        Let script's settings object be settings object.

        - -
      21. -
      22. Closing orphan workers: Start monitoring the worker such that no sooner than @@ -95542,13 +95490,19 @@ interface WorkerGlobalScope : EventTarget {

      23. -
      24. + +
      25. Let script be a new script with + code entry-point source and settings object settings + object.

      26. + +
      27. Jump to the script's code entry-point, and let that run until it - either returns, fails to catch an exception, or gets prematurely aborted by the "kill a - worker" or "terminate a worker" algorithms defined below.

        + data-x="concept-script">script's code entry-point.

        +

        In addition to the usual possibilities of returning a value or failing due to + an exception, this could be prematurely aborted by the "kill a worker" or + "terminate a worker" algorithms defined below.

      28. Enable outside port's port message queue.

      29. @@ -95728,7 +95682,8 @@ interface AbstractWorker {
        Script settings for workers

        When the user agent is required to set up a worker environment settings object, - given a worker global scope, it must run the following steps:

        + given a JavaScript execution context execution context, it must run the + following steps:

          @@ -95741,6 +95696,9 @@ interface AbstractWorker {
        1. Let worker event loop be a newly created event loop.

        2. +
        3. Let worker global scope be execution context's + global object.

        4. +
        5. Let settings object be a new environment settings object whose algorithms @@ -95748,18 +95706,10 @@ interface AbstractWorker {

          -
          The script execution environments
          +
          The realm execution context
          -

          When the environment settings object is created, for each language supported by the - user agent, create an appropriate execution environment as defined by the relevant - specification.

          - -

          When a script execution environment is needed, return the appropriate one from - those created when the environment settings object was created.

          - -

          Currently, workers only support JavaScript, so only a JavaScript execution - environment is actually needed here.

          +

          Return execution context.

          @@ -96183,7 +96133,7 @@ interface SharedWorker : EventTarget {
        6. Create a script using source as the script source, the - URL from which source was obtained, language as the scripting language, and settings object as + URL from which source was obtained, and settings object as the environment settings object.

          If response is CORS-cross-origin, pass the muted errors @@ -104749,7 +104699,8 @@ document.body.appendChild(text);

          An end tag whose tag name is "script"
          -

          If the stack of script settings objects is empty, perform a microtask checkpoint.

          +

          If the JavaScript execution context stack is empty, perform a microtask + checkpoint.

          Let script be the current node (which will be a script element).