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

RFC 71: Support adding URI fragments for reftests #71

Closed
wants to merge 3 commits into from

Conversation

lilles
Copy link
Member

@lilles lilles commented Nov 16, 2020

No description provided.

rfcs/reftest_variants.md Outdated Show resolved Hide resolved

## Details

A text fragment url for highlighting text in a page can be done with fragments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is text-fragments the only motivating use case here? It would be a stronger proposal with more use cases than just a WCIG spec with (afaict) limited vendor interest.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is text-fragments the only motivating use case here? It would be a stronger proposal with more use cases than just a WCIG spec with (afaict) limited vendor interest.

The highlight styling is in a CSSWG draft which is what I was writing tests for:

https://drafts.csswg.org/css-pseudo-4/#selectordef-target-text

I don't know about any other use cases atm, assuming the meta support wouldn't be more convenient than:

<script>window.location.hash = "#target";</script>

for other fragments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one could set window.location.hash for other fragments, but that's not really intuitive (e.g. subtleties like screenshot timing -- Does this trick delay load? / Is reftest-wait needed?), and the semantics are not exactly the same.

The proposed implementation here seems pretty straightforward and is a natural generalization of the existing variants system, so I think the convenience/intuitiveness alone is well worth the effort, let alone the specific use case unblocked by it.


## Risks

* There is a question what it means to have multiple variants for ref-tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this proposal needs to answer these questions. In particular the question around the behaviour of refs with variants is one reason we didn't support reftests with variants before now.

I don't have a strong sense of what the answer should be, but there are at least several possibilities:

  • ref urls are unaffected. This means that all variants of the test need to have identical rendering so it's probably only useful for the case where there's a single variant but it happens to contain a query or fragment part.
  • ref urls always get the same variant as the test. This means the ref has to do some work to ensure the rendering is correct given the variant. This might not work in cases where it's hard to adjust the reference rendering without relying on the feature that's being tested.
  • The variant syntax is extended to allow different behaviour for refs and tests. This is the most complex option, but also the one with the most flexibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have strong opinions here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear I don't think you have to answer this question, but I do think getting agreement on a design is essential to progressing the RFC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the first two are both reasonable. I'd slightly prefer the first, which is more in line with the principle of keeping refs as simple as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option 1 is the easiest (and we can lint for a reftest only having 1 variant if we want), but it definitely abuses the variant notation for a purpose that isn't a variant at all (it's just some stuff to stick on the URL).

I'm not sure I see the problem for option 2. I agree that each reference would have to handle the variant (if there are multiple) to produce the correct matching (or mismatching) rendering. However I think that's a specific case of a general problem for any solution that wants to support variants for reftests - i.e. once reftests have variants then the set of listed references cannot be all correct by default (or the variants are usless).

For option 3, I think we need to identify the actual desirable behavior if we want to do that. For example, is it that you want to list multiple refs, but only have some apply for each variant? (And should those refs that apply get passed the variant too?). We could borrow from fuzzy-reftests for that:

<meta name="variant" content="ref-1.html:?1-100">
<meta name="variant" content="ref-2.html:?101-200">
<meta name="variant" content="ref-3.html:?201-300">
<meta name="variant" content="ref-4.html,ref-5.html:?301-400">

But this seems complex and it's hard for me to imagine use cases for it.

Overall I think I'm ok with supporting option 1 as a known 'hack' of the variant syntax for now... again it's hard to tell if that will cause backwards compat problem when we don't know what conditions option 3 would actually be trying to satisfy. (And I don't have a good suggestion for it!)

Looking forward to @jgraham 's thoughts, which I'm sure will be much better than mine :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose #2 is probably OK.

The problem I had in mind is if you had some feature that caused the browser to change the default rendering on the basis of the hash or something. e.g. if some #magic=text causes all instances of text to render in yellow. Then it would be useful to not pass that to the ref since you don't actually want the feature to be used on the reference page at all. If you pass it in anyway you rely on the override CSS on the reference page to ensure that the feature itself isn't affecting rendering.

If we wanted to worry about that we could have seperate ref meta items or could do something like <meta name=variant content="ref=//?1-100"> where if the content starts with ref= that gets applied to the ref and we use something like // as the seperator (I'm not sure what the best choice there is).

I guess if we aren't worried about the scenario where default rendering may also be applied to the ref, we should implement option 2 and consider extending this later if we run into problems. It seems pretty forward-compatible to do it like that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem I had in mind is if you had some feature that caused the browser to change the default rendering on the basis of the hash or something. e.g. if some #magic=text causes all instances of text to render in yellow. Then it would be useful to not pass that to the ref since you don't actually want the feature to be used on the reference page at all. If you pass it in anyway you rely on the override CSS on the reference page to ensure that the feature itself isn't affecting rendering.

Ah yes, that makes sense. But I also agree that we can revisit the idea if needed to account for this sort of scenario.

@lilles - can you own updating the RFC to encompass the behavior from option 2?

@stephenmcgruer
Copy link
Contributor

@jgraham and I discussed this RFC today (apologies for the delay). We agree that the multiple variants problem needs some thought; both of us have committed to think about it and get back to this issue. Please ping me if there isn't an update by next week :)

@lilles
Copy link
Member Author

lilles commented Dec 4, 2020

Thanks for the update

@lilles
Copy link
Member Author

lilles commented Dec 11, 2020

@jgraham and I discussed this RFC today (apologies for the delay). We agree that the multiple variants problem needs some thought; both of us have committed to think about it and get back to this issue. Please ping me if there isn't an update by next week :)

Ping?

@zcorpan
Copy link
Member

zcorpan commented Sep 10, 2021

I had forgotten that variant doesn't work for reftests, and tried to use it in web-platform-tests/wpt@5c13141

In this case the ref is the same for all variants.

zcorpan added a commit to bocoup/wpt that referenced this pull request Sep 10, 2021
zcorpan added a commit to bocoup/wpt that referenced this pull request Oct 12, 2021
zcorpan added a commit to bocoup/wpt that referenced this pull request Nov 19, 2021
zcorpan added a commit to bocoup/wpt that referenced this pull request Nov 22, 2021
zcorpan added a commit to bocoup/wpt that referenced this pull request Nov 23, 2021
foolip pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 16, 2021
* added elements
* Fix test to apply background-color to all elements and fix expectations
* Test all properties that disable native appearance, and include <a>
* Test properties that do not disable native appearance
* Test 'revert' keyword does not result in the fallback appearance
* Generate tests instead of using non-supported 'variant'
* Update pass condition for meter and progress

See web-platform-tests/rfcs#71

See w3c/csswg-drafts#6537 (comment)

Co-authored-by: Simon Pieters <zcorpan@gmail.com>
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 24, 2021
Automatic update from web-platform-tests
HTML: Compute kind of widget (#30267)

* added elements
* Fix test to apply background-color to all elements and fix expectations
* Test all properties that disable native appearance, and include <a>
* Test properties that do not disable native appearance
* Test 'revert' keyword does not result in the fallback appearance
* Generate tests instead of using non-supported 'variant'
* Update pass condition for meter and progress

See web-platform-tests/rfcs#71

See w3c/csswg-drafts#6537 (comment)

Co-authored-by: Simon Pieters <zcorpan@gmail.com>
--

wpt-commits: 34974b0e244cf597e08f08e75f3fccb6d52aec8f
wpt-pr: 30267
@foolip foolip changed the title RFC: Support adding URI fragments for reftests RFC 71: Support adding URI fragments for reftests Jul 5, 2022
@gsnedders
Copy link
Member

@mrego said in web-platform-tests/wpt#26364 (comment):

It seems it's possible to write tests for ::target-text with location.href (see https://github.com/web-platform-tests/wpt/blob/master/css/css-highlight-api/painting/custom-highlight-painting-below-target-text.html).

So I guess one question is whether we still have any need for this feature?

@lilles
Copy link
Member Author

lilles commented Aug 2, 2022

It should no longer be necessary for my original use case, at least.

@foolip
Copy link
Member

foolip commented Aug 3, 2022

Let's go ahead and close this since the original motivation is no longer there. If someone else wants to drive it, feel free to clone into a new RFC to resolve the remaining issues.

@foolip foolip closed this Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants