Skip to content

Should 'true' count as truthy in parsing windowFeatures booleans? #7399

Closed

Description

@mfreed7

The parse a boolean feature spec says:

If value is the empty string, then return true.
If value is "yes", then return true.
Let parsed be the result of parsing value as an integer.
If parsed is an error, then set it to 0.
Return false if parsed is 0, and true otherwise.

...which means that something like window.open('about:blank','','popup=true') interprets the popup=true to mean popup is false. Not very intuitive.

Should we add "true" as a value that results in true?

This was brought up as a bug against Chromium related to the implementation of the new popup standardization work.

Activity

  1. added
    agenda+
    on Dec 8, 2021
  2. annevk commented on Dec 9, 2021

    @annevk
    Member

    This hasn't been a problem for the other features thus far, e.g., noopener. @zcorpan probably knows the answer here.

  3. zcorpan commented on Dec 9, 2021

    @zcorpan
    Member

    See #2600 -- the spec matched what browsers did for the legacy booleans.

    I don't mind supporting true.

    Do people expect popup=popup to also mean true?

  4. zcorpan commented on Dec 9, 2021

    @zcorpan
    Member
  5. cdumez commented on Dec 9, 2021

    @cdumez

    WebKit already allows "1" / "on" / "yes". I don't mind adding support for "true" too if other browser engines do the same.
    "true" seems like a logical value for a boolean.

    I don't really like the idea of popup=popup meaning true though.

  6. zcorpan commented on Dec 17, 2021

    @zcorpan
    Member

    "on" wasn't specified in #4079 . Testing with http://software.hixie.ch/utilities/js/live-dom-viewer/saved/9908 webkit/chromium/gecko do not support it.

    log: noopener=0: [object Window]
    log: noopener=1: null
    log: noopener=on: [object Window]
    log: noopener=yes: null
    log: noopener=true: [object Window]
    log: noopener=noopener: [object Window]
    
  7. added a commit that references this issue on Dec 17, 2021
    1f74334
  8. cdumez commented on Dec 17, 2021

    @cdumez

    "on" wasn't specified in #4079 . Testing with http://software.hixie.ch/utilities/js/live-dom-viewer/saved/9908 webkit/chromium/gecko do not support it.

    log: noopener=0: [object Window]
    log: noopener=1: null
    log: noopener=on: [object Window]
    log: noopener=yes: null
    log: noopener=true: [object Window]
    log: noopener=noopener: [object Window]
    

    Indeed, it looks like I was wrong, we allow "on" only for some features: center, resizable, status, scroll. For noopener, it seems we allow "yes" and any numeric value other than 0 (not sure why noopener is not treated like our other boolean features).

  9. annevk commented on Dec 20, 2021

    @annevk
    Member

    The one concern I have here is if we do want to switch to using a dictionary for "cool window features" (such as noopener, noreferrer, and popup) this seems a lot less worth it.

  10. domenic commented on Jan 11, 2022

    @domenic
    Member

    Here is my proposal for "switching to a dictionary for cool window features": #7485

    I don't really want to block small improvements everyone is on-board with in favor of larger changes though, so take it with a grain of salt...

  11. removed
    agenda+
    on Feb 3, 2022
  12. zcorpan commented on Feb 18, 2022

    @zcorpan
    Member

    @mfreed7 @cdumez do you still think this is a worthwhile change, considering there's now a proposed modern API (#7485)?

  13. cdumez commented on Feb 18, 2022

    @cdumez

    This is a very small amount of work to treat 'true' as truthy so I don't mind doing it, even if there is modern API proposal.

  14. mfreed7 commented on Feb 21, 2022

    @mfreed7
    ContributorAuthor

    This is a very small amount of work to treat 'true' as truthy so I don't mind doing it, even if there is modern API proposal.

    +1 - I support this. The modern syntax is nice, but I think it can coexist with this small change to the old syntax.

  15. domenic commented on Feb 27, 2022

    @domenic
    Member

    Great, so what's required now before landing #7425 is web platform tests.

    Per the triage meeting, as a bonus, it'd be great if we also made sure the web platform tests were comprehensive for "on" / "off", "yes" / "no", and non-zero numeric values as well, since it sounds like there's probably some divergence from the spec there, and perhaps interop issues.

  16. 2 remaining items

  17. mfreed7 commented on Mar 1, 2022

    @mfreed7
    ContributorAuthor

    @mfreed7 great! This file (used by noopener and noreferrer tests) may be of interest in addition to the test for popup

    html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/resources/tokenization-noopener-noreferrer.js

    We can land the spec change when there's a CL in review with tests.

    Thanks for the pointer. I thought about adding another set of cases there for =true but ended up just writing a fresh test that looks at just values for noopener, noreferrer, and popup. (The other boolean window features seem like overkill to test, and a bit nebulous given our recent changes to how popups work.)

    One question did come out of my new test though. What do we think about these?

      noreferrer=true    // With the new PR, this will result in noreferrer being *true*
      noreferrer="true"  // The quotes cause a parse error, and noreferrer is *false*
      noreferrer='true'  // Same here, *false*

    Currently, the rules, and browsers, treat quotation marks as a parse error and the quoted values are interpreted as false. But akin to the rationale for making property=true enable property, I would think we'd similarly want to make property="true" work as well? Perhaps there's more context for why we don't allow quotes here, whereas we're pretty lenient on quotes most other places in the web platform?

  18. zcorpan commented on Mar 1, 2022

    @zcorpan
    Member

    I think they should continue to be false. If you start allowing quotation marks you make the features tokenizer more complicated, at least if you want it to make sense, e.g.:

    noopener=", popup=1, "
    

    Does this have popup=1 as a feature, or no?

  19. mfreed7 commented on Mar 2, 2022

    @mfreed7
    ContributorAuthor

    I think they should continue to be false. If you start allowing quotation marks you make the features tokenizer more complicated, at least if you want it to make sense, e.g.:

    noopener=", popup=1, "
    

    Does this have popup=1 as a feature, or no?

    Right - that's a great point. Ok, I agree with you, quotes should parse as false.

    Ok, quick and dirty tests have been added here: web-platform-tests/wpt#33029
    Comments appreciated. I will wait to land them until I've sent an intent to ship for Chromium, and the spec has landed.

  20. added a commit that references this issue on Mar 7, 2022
    ca752b0
  21. added a commit that references this issue on Jun 3, 2022
    3cfea94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions