Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mfreed7 opened this issue Dec 8, 2021 · 17 comments · Fixed by #7425
Closed

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

mfreed7 opened this issue Dec 8, 2021 · 17 comments · Fixed by #7425

Comments

@mfreed7
Copy link
Contributor

mfreed7 commented Dec 8, 2021

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.

@mfreed7 mfreed7 added the agenda+ To be discussed at a triage meeting label Dec 8, 2021
@annevk
Copy link
Member

annevk commented Dec 9, 2021

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

@zcorpan
Copy link
Member

zcorpan commented Dec 9, 2021

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?

@zcorpan
Copy link
Member

zcorpan commented Dec 9, 2021

cc @cdumez

@cdumez
Copy link

cdumez commented Dec 9, 2021

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.

@zcorpan
Copy link
Member

zcorpan commented Dec 17, 2021

"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]

@cdumez
Copy link

cdumez commented Dec 17, 2021

"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).

@annevk
Copy link
Member

annevk commented Dec 20, 2021

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.

@domenic
Copy link
Member

domenic commented Jan 11, 2022

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...

@zcorpan
Copy link
Member

zcorpan commented Feb 18, 2022

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

@cdumez
Copy link

cdumez commented Feb 18, 2022

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.

@mfreed7
Copy link
Contributor Author

mfreed7 commented Feb 21, 2022

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.

@domenic
Copy link
Member

domenic commented Feb 27, 2022

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.

@mfreed7
Copy link
Contributor Author

mfreed7 commented Feb 28, 2022

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.

I'm happy to tackle the WPT enhancements as part of implementing this change in Chromium, assuming we can land #7425 to make that easier for me.

@zcorpan
Copy link
Member

zcorpan commented Feb 28, 2022

@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.

@mfreed7
Copy link
Contributor Author

mfreed7 commented Mar 1, 2022

@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?

@zcorpan
Copy link
Member

zcorpan commented Mar 1, 2022

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?

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 2, 2022
Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
@mfreed7
Copy link
Contributor Author

mfreed7 commented Mar 2, 2022

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.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 3, 2022
Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 3, 2022
Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

The I2S is here:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 4, 2022
Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

The I2S is here:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3495659
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#977722}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 4, 2022
Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

The I2S is here:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3495659
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#977722}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Mar 22, 2022
…dowFeatures, a=testonly

Automatic update from web-platform-tests
Add "true" to truthy values list for windowFeatures

Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

The I2S is here:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3495659
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#977722}

--

wpt-commits: 2026041556d8c61e167d0a0d3d0bbbeaf99dcd70
wpt-pr: 33029
aosmond pushed a commit to aosmond/gecko that referenced this issue Mar 26, 2022
…dowFeatures, a=testonly

Automatic update from web-platform-tests
Add "true" to truthy values list for windowFeatures

Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

The I2S is here:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3495659
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#977722}

--

wpt-commits: 2026041556d8c61e167d0a0d3d0bbbeaf99dcd70
wpt-pr: 33029
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
Prior to this CL, window.open(url, '', 'noopener=true') would treat
'noopener=true' as if noopener is false. This is currently per-spec [1]
but there is a desire [2][3] to change that.

The I2S is here:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ePJ4GE6VzVc/m/urs3-4rHDAAJ

[1] https://html.spec.whatwg.org/multipage/window-object.html#concept-window-open-features-parse-boolean
[2] whatwg/html#7425
[3] whatwg/html#7399

Fixed: 1277613
Change-Id: I5b3a7e985a9bb392c2150846b50369cfcd9b05fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3495659
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#977722}
NOKEYCHECK=True
GitOrigin-RevId: 0c49a8d7e96bbad1102c934687836d3795073603
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

6 participants