From 3c047b5a35da7af9cffef2a654a944e33be256cc Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 19 Feb 2016 14:16:53 -0500 Subject: [PATCH] Fix fetching module scripts with circular imports As pointed out by @jonco3 in IRC, the current fetching logic will recurse infinitely if a module imports itself (directly or indirectly). This fixes that by keeping track of all ancestors being fetched and not re-fetching them. Also, the "fetch a module script tree" and "fetch a single module script" algorithms don't always complete with _new_ module scripts, if they end up getting their result from the module map. So this removes the word "new" in their preludes. --- source | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/source b/source index 58429cfd4fa..09f1fb610e6 100644 --- a/source +++ b/source @@ -84318,10 +84318,13 @@ interface NavigatorOnLine {

To fetch a module script tree given a url, a credentials mode, - and a settings object, run these steps. The algorithm will asynchronously complete - with either null (on failure) or a new module script (on success).

+ a settings object, and an optional ancestor list, run these steps. The + algorithm will asynchronously complete with either null (on failure) or a module + script (on success).

    +
  1. If ancestor list is not given, let it be an empty list.

  2. +
  3. Fetch a single module script given url, credentials mode, and settings object.

    @@ -84333,16 +84336,17 @@ interface NavigatorOnLine { these steps.

  4. Otherwise, result is a module script. Fetch the descendants of result.

  5. + descendants of a module script">Fetch the descendants of result using an + ancestor list obtained by appending url to ancestor list.

  6. When fetching the descendants of a module script asynchronously completes with descendants result, asynchronously complete this algorithm with descendants result.

-

To fetch the descendants of a module script module script, run these - steps. The algorithm will asynchronously complete with either null (on failure) or with - module script (on success).

+

To fetch the descendants of a module script module script, using a given + ancestor list, run these steps. The algorithm will asynchronously complete with either + null (on failure) or with module script (on success).

  1. Let record be module script's NavigatorOnLine {

-
  • Otherwise, add url to urls.

  • +
  • Otherwise, if url is not in ancestor list, add url to + urls.

  • For each url in urls, fetch a module script tree given url, module script's credentials mode, and - module script's settings object.

    + data-x="concept-module-script-credentials-mode">credentials mode, module + script's settings object, and ancestor list.

    If any of the fetch a module script tree invocations asynchronously complete with null, the user agent may terminate any or @@ -84395,7 +84400,7 @@ interface NavigatorOnLine {

    To fetch a single module script, given a url, a credentials mode, and a settings object, run these steps. The algorithm will asynchronously - complete with either null (on failure) or a new module script (on success).

    + complete with either null (on failure) or a module script (on success).

    1. Let module map be settings's module map.

    2. @@ -116518,6 +116523,7 @@ INSERT INTERFACES HERE John Stockton, John-Mark Bell, Johnny Stenback, + Jon Coppeard, Jon Ferraiolo, Jon Gibbins, Jon Perlow,