Bug 226434

Summary: window.scrollTo(null) throws an exception
Product: WebKit Reporter: zyscoder <zyscoder>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: bugs-noreply, cdumez, mcatanzaro, simon.fraser
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   

zyscoder@gmail.com
Reported 2021-05-30 06:01:25 PDT
Steps to reproduce: (1) Open a tab and navigate to https://www.icann.org/; (2) Run the following code in the Console of Devtools: ``` window.scrollTo(null); ``` (3) Then this code would throw an exception. Actual results: This code would throw an exception: `TypeError: null is not an object (evaluating 'arguments[0].left')` Expected results: As https://drafts.csswg.org/cssom-view/#dom-window-scroll says, ``` If invoked with one argument, follow these substeps: - Let options be the argument. - Let x/y be the value of the left/top dictionary member of options, if present, or the viewport’s current scroll position on the x/y axis otherwise. ``` It seems reasonable to let x/y be the value of the viewport’s current scroll position on the x/y axis and no need to throw any exceptions for this code. In my test, Chrome and Firefox would not throw any exceptions when evaluating this code.
Attachments
Chris Dumez
Comment 1 2021-06-01 17:56:29 PDT
If you type window.scrollTo on icann.org, you'll notice they are using some kind of polyfill: function (){void 0!==arguments[0]&&(!0!==c(arguments[0])?g.call(t,e.body,void 0!==arguments[0].left?~~arguments[0].left:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:t.scrollY||t.pageYOffset):o.scroll.call(t,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:t.scrollY||t.pageYOffset))} = $1 They are not calling our window.scrollTo() implementation. As a matter of fact, our window.scrollTo() implementation never throws.
Chris Dumez
Comment 2 2021-06-01 17:58:00 PDT
Chrome and Firefox are not getting the polypill for window.scrollTo, unclear why.
Chris Dumez
Comment 3 2021-06-01 18:04:11 PDT
(In reply to Chris Dumez from comment #2) > Chrome and Firefox are not getting the polypill for window.scrollTo, unclear > why. I think we are getting the polyfill because of this check: if (!("scrollBehavior" in e.documentElement.style) || !0 === t.__forceSmoothScrollPolyfill__) { We seem to be failing this: "scrollBehavior" in e.documentElement.style
Chris Dumez
Comment 4 2021-06-01 18:11:55 PDT
(In reply to Chris Dumez from comment #3) > (In reply to Chris Dumez from comment #2) > > Chrome and Firefox are not getting the polypill for window.scrollTo, unclear > > why. > > I think we are getting the polyfill because of this check: > if (!("scrollBehavior" in e.documentElement.style) || !0 === > t.__forceSmoothScrollPolyfill__) { > > We seem to be failing this: "scrollBehavior" in e.documentElement.style On WebKit trunk, in the develop menu, there is an experimental feature called CSSOM View Smooth Scrolling, which is off by default. If I turn it on, then icann.org stops using the polyfill and instead calls our native window.scrollTo(). I have verified that window.scrollTo(null) doesn't throw in such case. Anyway, this is not really a but with our window.scrollTo implementation. The Website merely makes the decision NOT to use our window.scrollTo implementation because we don't support CSSOM View Smooth Scrolling. Simon may know more about CSSOM View Smooth Scrolling, I have no idea what that is or if we're close to enabling it.
Simon Fraser (smfr)
Comment 5 2021-06-01 20:28:12 PDT
ScrollBehavior is bug 188043. Anyway, this bug is a website bug.
Note You need to log in before you can comment on or make changes to this bug.