Bug 226972 - CSSStyleDeclaration.overscrollBehaviorX setter behaves differently from Chrome and Firefox
Summary: CSSStyleDeclaration.overscrollBehaviorX setter behaves differently from Chrom...
Status: RESOLVED DUPLICATE of bug 176454
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-14 07:38 PDT by zyscoder@gmail.com
Modified: 2021-06-15 09:57 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zyscoder@gmail.com 2021-06-14 07:38:46 PDT
Steps to reproduce:

(1) Open a tab and navigate to any URL;
(2) Run the following code in the Console of Devtools:
```
obj = getComputedStyle(new Audio());
obj.overscrollBehaviorX = '';
```
Actual results:

This code would be evaluated successfully without throwing any exceptions.

Expected results:

In my test, Chrome and Firefox would throw exceptions:
Chrome: `DOMException: Failed to set the 'overscroll-behavior-x' property on 'CSSStyleDeclaration': These styles are computed, and therefore the 'overscroll-behavior-x' property is read-only.`
Firefox: `CSS2Properties.overscrollBehaviorX setter: Can't set value for property 'overscroll-behavior-x' in computed style`
It seems better for Webkit to align with Chrome and Firefox.
Comment 1 Chris Dumez 2021-06-15 09:00:31 PDT
`obj.setProperty("overscrollBehaviorX", '');` does throw but `obj.overscrollBehaviorX = '';` does not.
Comment 2 Chris Dumez 2021-06-15 09:12:00 PDT
(In reply to Chris Dumez from comment #1)
> `obj.setProperty("overscrollBehaviorX", '');` does throw but
> `obj.overscrollBehaviorX = '';` does not.

We don't seem to have a named property setter (only a named getter), and neither does the spec:
https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface

However, Chrome has one:
    [CEReactions, CallWith=ScriptState] setter void (DOMString property, [TreatNullAs=EmptyString] DOMString propertyValue);
Comment 3 Sam Weinig 2021-06-15 09:47:29 PDT
Named properties are now handled by the generated IDL file named CSSStyleDeclaration+PropertyNames.idl. For this specific property it is:

    [CEReactions, DelegateToSharedSyntheticAttribute=propertyValueForCamelCasedIDLAttribute, CallWith=PropertyName, EnabledBySetting=overscrollBehavior] attribute [LegacyNullToEmptyString] CSSOMString overscrollBehaviorX;

This is part of the camel cased variant, so the spec for this is:

https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-camel_cased_attribute

For setting, the spec says:

Setting the camel-cased attribute attribute must invoke setProperty() with the first argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute, as second argument the given value, and no third argument. Any exceptions thrown must be re-thrown.

So it seems like something is busted with setPropertyValueForCamelCasedIDLAttribute()? I can look into this.
Comment 4 Sam Weinig 2021-06-15 09:53:21 PDT
Oh, actually, this is probably due to OverscrollBehaviorEnabled being disabled, in which case this is behaving correctly.

If OverscrollBehaviorEnabled is disable, the property case behaves as if there is nothing called obj.overscrollBehaviorX, so just the same as obj.fakeProperty = 1 would. It sets an "expando" / custom property on the object.

If OverscrollBehaviorEnabled is enabled, this will throw, as the property exists and is readonly due to the declaration being a computed style.


My guess is that chrome and Firefox have support for overscroll-behavior-x enabled by default.

I think this is behaves correctly.
Comment 5 Chris Dumez 2021-06-15 09:57:07 PDT

*** This bug has been marked as a duplicate of bug 176454 ***