WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
218757
Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
https://bugs.webkit.org/show_bug.cgi?id=218757
Summary
Simplify mainframe tests tiled-drawing/scrolling/scroll-snap
Martin Robinson
Reported
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.
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
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Martin Robinson
Comment 1
2020-11-10 09:32:12 PST
Created
attachment 413707
[details]
Patch
Simon Fraser (smfr)
Comment 2
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
Martin Robinson
Comment 3
2020-11-11 04:20:55 PST
Created
attachment 413809
[details]
Patch
Martin Robinson
Comment 4
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.
Simon Fraser (smfr)
Comment 5
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()?
Martin Robinson
Comment 6
2020-11-12 03:36:07 PST
Created
attachment 413924
[details]
Patch
Martin Robinson
Comment 7
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.
EWS
Comment 8
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]
.
Radar WebKit Bug Importer
Comment 9
2020-11-12 04:19:21 PST
<
rdar://problem/71322154
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug