-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Specify the tokenizer for window.open's features argument #2476
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of nits, looks reasonable overall.
source
Outdated
|
||
<li> | ||
<p>For each <var>token</var> of <var>tokens</var>:</p> | ||
<ol> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline before <ol>
.
source
Outdated
<li><p>Let <var>map</var> be a new <span>ordered map</span>.</p></li> | ||
|
||
<li> | ||
<p>For each <var>token</var> of <var>tokens</var>:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link "For each".
source
Outdated
|
||
<li><p>Let <var>position</var> point at the first character of <var>input</var>.</p></li> | ||
|
||
<li><p><span>Skip ASCII whitespace</span>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to pass this parameters these days.
source
Outdated
<li> | ||
<p>For each <var>token</var> of <var>tokens</var>:</p> | ||
<ol> | ||
<li><p>Let <var>input</var> be <var>token</var>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
source
Outdated
|
||
<li><p><span>Skip ASCII whitespace</span>. | ||
|
||
<li><p><span>Collect a sequence of code points</span> that are not <span>ASCII |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be passed more arguments.
source
Outdated
<var>name</var>.</p></li> | ||
|
||
<li><p>If <var>tokenizedFeatures</var>[<var>name</var>] <span data-x="map | ||
exists">exists</span>, then continue.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you can't overwrite existing values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This matches Gecko but not WebKit or Chromium.
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4986
What does Edge do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edge overwrites, but does not appear to support left (I ended up overwriting width).
source
Outdated
<li><p>If <var>tokenizedFeatures</var>[<var>name</var>] <span data-x="map | ||
exists">exists</span>, then continue.</p></li> | ||
|
||
<li><p><span>Skip ASCII whitespace</span>.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing arguments again.
source
Outdated
whitespace</span> nor U+003D (=). Let <var>name</var> be the collected characters, | ||
<span>converted to ASCII lowercase</span>.</p></li> | ||
|
||
<li><p>Set <var>name</var> to the result of <span>normalizing the feature name</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm maybe the name shouldn't be normalized during tokenization.
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4987
Gecko picks the "left" value in both cases. Chromium and WebKit pick the last one specified.
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4988
Here Chromium and WebKit still pick the last one specified and use 0. Gecko has different result for the two cases...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor nit.
source
Outdated
<li><p>Let <var>tokenizedFeatures</var> be a new <span>ordered map</span>.</p></li> | ||
|
||
<li> | ||
<p>For each <var>token</var> of <var>tokens</var>:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"For each" should be a link to https://infra.spec.whatwg.org/#list-iterate
See whatwg/html#2476 Also change the behavior for left=foo to act as if left=0 to align with the behavior of at least WebKit and Chromium.
@zcorpan I was thinking making test coverage better in this area of the spec (7.3.1) — I'm not sure how the process typically works but would you like me to help out with writing tests for this? |
@lyzadanger that would be awesome! Thanks! I think this could be automated by checking https://drafts.csswg.org/cssom-view/#dom-window-screenx et al. Although the features for window.open needs to be defined in terms of https://drafts.csswg.org/cssom-view/#web-exposed-screen-area as well so they match up (and to fix the privacy leak for window.open). (Edit: w3c/csswg-drafts@7e04f5c ) Another problem is that doing anything with features is optional (other than |
@zcorpan Sounds good. Just finishing up some travel; will get on this tomorrow (Friday). |
source
Outdated
<var>position</var>.</p></li> | ||
|
||
<li><p>If <var>position</var> is not past the end of <var>token</var> and the character at | ||
<var>position</var> is U+003D (=), then advance <var>position</var> by 1.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm there is a bug here. If it's not past the end and the character is not =
, we shouldn't collect a value. Maybe it would be better to split on the first =
and then trim leading and trailing whitespace from name and value?
I looked at the code in Chromium and reverse-engineered Edge. It appears there is almost perfect interop between Edge and Chromium and WebKit in how to tokenize. The only difference seems to be handling of U+0000 (Edge cuts the value at the first U+0000, Chromium treats it as a separator like space, WebKit treats it as a non-separator like x). I'll specify Chromium's tokenizer. For example |
What does Chrome do for U+0001? I don't see why we'd treat U+0000 as a separator. |
It's a non-separator. Happy to spec WebKit-like instead on that point. Another interesting bit is U+000C, which only Gecko treats as a separator character. Likely it is Web-compatible to treat it as a separator so this is more consistent with everything else. |
I found a case that is not interoperable between Edge and WebKit/Chromium, see ca2aa5d Implementation of the proposed spec with a few tests: |
source
Outdated
|
||
<ol> | ||
<li><p>If the code point at <var>position</var> in <var>features</var> is U+002C (,), or if | ||
it is not a <span>window features separator</span>, then break.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break to
- While position is not past the end of features:
(line 78754)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, per https://infra.spec.whatwg.org/#iteration-break -- @annevk @domenic should we xref these terms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean no. It breaks the nearest iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is
While position is not past the end of features and the code point at position in features is not U+003D (=):
??
In that case, does this imply that any ','
characters between the name
and the first instance of '='
are ignored? e.g. the case:
'noopener ,=foo,'
How does that tokenize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log: noopener ,=foo,
log: {
"noopener": "",
"foo": ""
}
I could step through the spec but maybe it's simpler to step through the JS implementation with some browser's devtools? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, good idea (I'm new to the part of this that involves prototyping implementation via JS). I'll walk through that more carefully and do some of my own tests against it there. In the end, I want to be sure that the spec language is in accordance to the implementation (obviously :) ). More soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr I think things are fine as-is.
My confusion was that, at this point in the spec, we are nested a few levels deep, but if I evaluate those levels, it's while (a) > while (b) > if
. The break
statement in that if
conditional will return control to while (a)
, which is as it should be, but I had to think more programmatically than I was initially. 👍 and thanks for your patience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO yes we should xref those terms. We're taking an incremental approach to introducing infra into HTML, so it's good to use this opportunity to introduce it here.
source
Outdated
</li> | ||
|
||
<li><p><span>Collect a sequence of code points</span> that are not <span data-x="window | ||
features separator">window features separators</span> code points from <var>features</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to anything after the last non-separator code point in value
? e.g. in the case 'noopener=yes yes,foo=bar'
, I believe you end up with ('noopener', 'yes')
for the first tokenized feature, but what happens to the other 'yes'
? It seems like this might put you into the next loop of tokenization with some remaining characters before the next ','
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...or does this tokenize to:
- name
'noopener'
, value'yes'
- name
'yes'
, value''
- name
'foo'
, value'bar'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Added that case in http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5001 to confirm. (Also fixed a typo asciiLowercase
-> asciiLowerCase
from 4998.)
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 w3c/csswg-drafts#1128. The tokenizer specified here closely follows Chromium and WebKit. Difference from Chromium: U+0000 is not a separator. Difference from WebKit and Chromium: U+000C is a separator.
Specifically, 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.
dcc2580
to
e74dc9a
Compare
I've cleaned up the history and rebased to resolve conflicts. I left the like-Edge change as a separate commit to make it clearer what the difference is from like-Chromium and -WebKit. |
When you land you'll squash these I assume? (The second commit doesn't seem to have enough context on its own.) |
Yes |
Tests for @annevk can you do another round of editorial review? It's possible I made a mistake when rewriting history and resolving conflicts. I'll file browser bugs tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the annotated nit, I also noticed that you had one dfn where you use "window features", but the other dfns just have feature(s). It might be nice to make that consistent, but since these terms are only for internal usage I'm okay either way.
source
Outdated
</ol> | ||
|
||
<p>A code point is a <dfn>window features separator</dfn> if it is one of <span>ASCII | ||
whitespace</span>, U+003D (=), or U+002C (,).</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/one of//
Fixed nit and renamed to "feature separator" |
See whatwg/html#2476 Also change the behavior for left=foo to act as if left=0 to align with the behavior of at least WebKit and Chromium. Tests: web-platform-tests/wpt#5306 web-platform-tests/wpt#5390
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 w3c/csswg-drafts#1128.
This needs updates in cssom-view as well.
Maybe the aliases should be a separate commit... or maybe they should be in cssom-view still, not sure.