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
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Chris Dumez
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
Chrome and Firefox are not getting the polypill for window.scrollTo, unclear why.
Chris Dumez
(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
(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)
ScrollBehavior is bug 188043.
Anyway, this bug is a website bug.