From 5616fb9f65c7d616d6c5d0116fb1fceea6cdec5b Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Thu, 6 Apr 2017 16:54:32 +0200 Subject: [PATCH] Specify the tokenizer for window.open's features argument This was specified in CSSOM View but the "noopener" feature did not use the same tokenizer as the legacy features. Fixes #2474. Also specify the aliases screenx, screeny, innerwidth, innerheight for left, top, width, and height, respectively. Part of #2464. Closes https://github.com/w3c/csswg-drafts/pull/1128. The tokenizer specified here closely follows Edge. Chromium and WebKit are also very similar to Edge. Difference from Edge: U+0000 does not end the string. Difference from Chromium: U+0000 is not a separator. Difference from WebKit/Chromium/Edge: U+000C is a separator. For the input `width toolbar=450, height=450`, Edge tokenizes like `width, toolbar=450, height=450` while WebKit/Chromium like `width=450, height=450`. The Edge behavior seems better. Tests: https://github.com/w3c/web-platform-tests/pull/5306 https://github.com/w3c/web-platform-tests/pull/5390 --- source | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 111 insertions(+), 9 deletions(-) diff --git a/source b/source index 04eea66c090..6802405d81b 100644 --- a/source +++ b/source @@ -2365,6 +2365,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

The following terms are defined in the WHATWG Infra standard:

The following features and terms are defined in the CSS Syntax specifications: @@ -78574,8 +78577,8 @@ callback FrameRequestCallback = void (DOMHighResTimeStampOpens a window to show url (defaults to about:blank), and returns it. The target argument gives the name of the new window. If a window exists with that - name already, it is reused. The features argument can be - used to influence the rendering of the new window.

+ name already, it is reused. The features argument can be used to influence the + rendering of the new window.

@@ -78670,8 +78673,12 @@ callback FrameRequestCallback = void (DOMHighResTimeStamptop-level browsing context, then let new be true. Otherwise, let it be false.

-
  • Interpret features as defined in the CSSOM - View specification.

  • +
  • Let tokenizedFeatures be the result of tokenizing features.

  • + +
  • If target browsing context is a new auxiliary browsing context, + then set up browsing context features for target browsing context given + tokenizedFeatures.

  • @@ -78726,10 +78733,9 @@ callback FrameRequestCallback = void (DOMHighResTimeStamp -
  • If the result of splitting features - on commas contains the token "noopener", then disown target browsing context's opener and - return null.

  • +
  • If tokenizedFeatures contains an entry with + the key "noopener", then disown + target browsing context's opener and return null.

  • Otherwise, return the WindowProxy object of target browsing context.

  • @@ -78740,6 +78746,102 @@ callback FrameRequestCallback = void (DOMHighResTimeStamp +

    To tokenize the features + argument:

    + +
      +
    1. Let tokenizedFeatures be a new ordered map.

    2. + +
    3. Let position point at the first code point of features.

    4. + +
    5. +

      While position is not past the end of features:

      + +
        +
      1. Let name be the empty string.

      2. + +
      3. Let value be the empty string.

      4. + +
      5. Collect a sequence of code points that are feature separators from features given position. This + skips past leading separators before the name.

      6. + +
      7. Collect a sequence of code points that are not feature separators from features given position. Set + name to the collected characters, converted to ASCII lowercase.

      8. + +
      9. Set name to the result of normalizing the feature name + name.

      10. + +
      11. +

        While position is not past the end of features and the + code point at position in features is not U+003D (=):

        + +
          +
        1. If the code point at position in features is U+002C (,), or if + it is not a feature separator, then break.

        2. + +
        3. Advance position by 1.

        4. +
        + +

        This skips to the first U+003D (=) but does not skip past a U+002C (,) or a + non-separator.

        +
      12. + +
      13. +

        If the code point at position in features is a feature + separator:

        + +
          +
        1. +

          While position is not past the end of features and the code point + at position in features is a feature separator:

          + +
            +
          1. If the code point at position in features is U+002C (,), then + break.

          2. + +
          3. Advance position by 1.

          4. +
          + +

          This skips to the first non-separator but does not skip past a U+002C + (,).

          +
        2. + +
        3. Collect a sequence of code points that are not feature separators code points from features given + position. Set value to the collected code points, converted to + ASCII lowercase.

        4. +
        +
      14. + +
      15. If name is not the empty string, then set + tokenizedFeatures[name] to value.

      16. +
      +
    6. + +
    7. Return tokenizedFeatures.

    8. +
    + +

    A code point is a feature separator if it is ASCII whitespace, U+003D + (=), or U+002C (,).

    + +

    For legacy reasons, there are some aliases of some feature names. To normalize a feature name name, switch on name:

    + +
    +
    "screenx" +
    Return "left". +
    "screeny" +
    Return "top". +
    "innerwidth" +
    Return "width". +
    "innerheight" +
    Return "height". +
    Anything else +
    Return name. +
    +

    The name attribute of the Window object