Bug 218757 - Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
Summary: Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Martin Robinson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-11-10 08:51 PST by Martin Robinson
Modified: 2020-11-12 04:19 PST (History)
2 users (show)

See Also:


Attachments
Patch (53.14 KB, patch)
2020-11-10 09:32 PST, Martin Robinson
no flags Details | Formatted Diff | Diff
Patch (53.84 KB, patch)
2020-11-11 04:20 PST, Martin Robinson
no flags Details | Formatted Diff | Diff
Patch (53.77 KB, patch)
2020-11-12 03:36 PST, Martin Robinson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Robinson 2020-11-10 08:51:53 PST
The mainframe tests in this directory have a lot of repeated code that could be simplified to make the tests a lot more readable.
Comment 1 Martin Robinson 2020-11-10 09:32:12 PST
Created attachment 413707 [details]
Patch
Comment 2 Simon Fraser (smfr) 2020-11-10 09:46:56 PST
Comment on attachment 413707 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=413707&action=review

> LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:41
> +    var startPosX = targetElement.offsetLeft + 20;
> +    var startPosY = targetElement.offsetTop + 20;

This isn't going to work for something in side positioned elements. You need getBoundingClientRect().

> LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:60
> +function delay(time) {
> +    return new Promise(resolve => setTimeout(resolve, time));
> +}

This is the same as UIHelper.delayFor()

> LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:62
> +function shortScrollShouldSnapBack(targetElement, direction) {

Brace on new line.

> LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:70
> +function scrollGlideShouldScrollTo(targetElement, direction, expectedValue) {

Brace on new line.

> LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html:36
> +            delay(0)
> +                .then(() => scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth"))
> +                .then(() => delay(0))
> +                .then(() => shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL))
> +                .finally(finishJSTest);

I much prefer async/await
Comment 3 Martin Robinson 2020-11-11 04:20:55 PST
Created attachment 413809 [details]
Patch
Comment 4 Martin Robinson 2020-11-11 04:27:25 PST
(In reply to Simon Fraser (smfr) from comment #2)
> Comment on attachment 413707 [details]

Thanks for the review.

> > LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:41
> > +    var startPosX = targetElement.offsetLeft + 20;
> > +    var startPosY = targetElement.offsetTop + 20;
> 
> This isn't going to work for something in side positioned elements. You need
> getBoundingClientRect().

Okay. I've updated the code to use getBoundingClientRect(), but not when dealing with the root element. The offsets for that element are affected by the root scroll offset.

> > LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:60
> > +function delay(time) {
> > +    return new Promise(resolve => setTimeout(resolve, time));
> > +}
> 
> This is the same as UIHelper.delayFor()

I've replaced all the calls to `delay` with a call to `UIHelper.delayFor()`.

> > LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:62
> > +function shortScrollShouldSnapBack(targetElement, direction) {
> 
> Brace on new line.

Fixed.

> > LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:70
> > +function scrollGlideShouldScrollTo(targetElement, direction, expectedValue) {
> 
> Brace on new line.

Fixed.
 
> > LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html:36
> > +            delay(0)
> > +                .then(() => scrollGlideShouldScrollTo(document.scrollingElement, HORIZONTAL, "window.innerWidth"))
> > +                .then(() => delay(0))
> > +                .then(() => shortScrollShouldSnapBack(document.scrollingElement, HORIZONTAL))
> > +                .finally(finishJSTest);
> 
> I much prefer async/await

I've modified the code to use async and wait everywhere.
Comment 5 Simon Fraser (smfr) 2020-11-11 09:08:37 PST
Comment on attachment 413809 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=413809&action=review

> LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:69
> +    return new Promise((resolve, reject) => {
> +        eventSender.callAfterScrollingCompletes(resolve);
> +    })

UIHelper.waitForScrollCompletion()?
Comment 6 Martin Robinson 2020-11-12 03:36:07 PST
Created attachment 413924 [details]
Patch
Comment 7 Martin Robinson 2020-11-12 03:38:00 PST
(In reply to Simon Fraser (smfr) from comment #5)
> Comment on attachment 413809 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=413809&action=review
> 
> > LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/mainframe-scroll-snap-test.js:69
> > +    return new Promise((resolve, reject) => {
> > +        eventSender.callAfterScrollingCompletes(resolve);
> > +    })
> 
> UIHelper.waitForScrollCompletion()?

Oh. Nice catch. I've started using this here.
Comment 8 EWS 2020-11-12 04:18:33 PST
Committed r269730: <https://trac.webkit.org/changeset/269730>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 413924 [details].
Comment 9 Radar WebKit Bug Importer 2020-11-12 04:19:21 PST
<rdar://problem/71322154>