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

Add a test to verify finding fragment id in non UTF8 document #24412

Merged
merged 1 commit into from Jul 2, 2020

Conversation

rwlbuis
Copy link
Contributor

@rwlbuis rwlbuis commented Jul 1, 2020

No description provided.

Copy link
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

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

Can you link to the part of the spec this is testing? Is it a recent change?

<div id="&#x586f" style="position:absolute; top:100px;"></div>
<div style="height:200em;"></div>
<script>
var steps = [{
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this style is copied from sibling tests which have more than one step. With just one step, I find it quite hard to follow with all the indirection.

Can you try flattening it into a simple single-page test, be something like this?

setup({ single_test: true });
assert_equals(location.hash, "", "Page must be loaded with no hash");
location.hash = '%89g';
setTimeout(() => {
  assert_equals( document.scrollingElement.scrollTop, 0 );
  done();
}, 1);

I think that's all the test is doing, but I haven't tested my suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I tested it and it works, so I pushed that new version. Initially I thought perhaps we will add more subtests so I kept the multiple tests approach, but I guess we can introduce it later if needed.

@wpt-pr-bot wpt-pr-bot temporarily deployed to wpt-preview-24412 July 2, 2020 07:55 Inactive
@rwlbuis
Copy link
Contributor Author

rwlbuis commented Jul 2, 2020

Can you link to the part of the spec this is testing? Is it a recent change?

This is related to https://html.spec.whatwg.org/multipage/browsing-the-web.html#scroll-to-fragid:the-indicated-part-of-the-document-6. See also whatwg/html#2902.

In general this comes from my fix in https://bugs.webkit.org/show_bug.cgi?id=83930, i.e. make scroll frag id behavior according to spec in WebKit. I think the change is a bit older but WebKit did not get around to fixing it. The fix works but we found out the test anchor-frames-gbk.html would have a different behavior (since it uses a non UTF8 document), hence this test which should replace it (anchor-frames-gbk.html is used in chromium too btw).

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Thanks for writing this!

<div style="height:200em;"></div>
<script>
setup({ single_test: true });
assert_equals(location.hash, "", "Page must be loaded with no hash");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also assert that document.characterSet is GBK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

<body>
<div></div>
<div id="&#x586f" style="position:absolute; top:100px;"></div>
<div style="height:200em;"></div>
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want 200vh or some such?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done. BTW scroll-frag-percent-encoded.html uses 200em.

setup({ single_test: true });
assert_equals(location.hash, "", "Page must be loaded with no hash");
location.hash = '%89g';
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised this passes the lint check. Using an async_test wrapper and t.step_timeout seems slightly preferable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if a lint checker can catch this. Anyway, fixed.

Copy link
Member

Choose a reason for hiding this comment

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

As far as I know unless this directory is in lint.ignore (I guess it might be given your other comment) the literal string setTimeout will trip it.

Copy link
Member

Choose a reason for hiding this comment

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

It's because lint.ignore has SET TIMEOUT: html/browsers/browsing-the-web/scroll-to-fragid/*.

@rwlbuis rwlbuis merged commit 7e6dcb9 into master Jul 2, 2020
@rwlbuis rwlbuis deleted the scroll_frag_non_utf8 branch July 2, 2020 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants