Bug 45778

Summary: CSSStyleDeclaration.prototype.setProperty does not set priority correctly
Product: WebKit Reporter: Nikita Vasilyev <me>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, ap, ian, jasonliuwebkit, jchaffraix, koivisto, marc.hoyois, mitz, phnixwxz, rniwa, simon.fraser, wangxianzhu, zalan
Priority: P3 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
CSSStyleDeclaration.prototype.setProperty
none
test case of ignored setProperty()
none
Patch
ap: review-
patch
simon.fraser: review-
Patch
ap: review-
Safari 15.5 matches other browsers none

Description Nikita Vasilyev 2010-09-14 13:23:58 PDT
Created attachment 67597 [details]
CSSStyleDeclaration.prototype.setProperty

The reduction fails in WebKit and Opera.

3 FAIL 
Expected: '' 
Actual: 'important'

4 FAIL 
Expected: '' 
Actual: 'important'

5 FAIL 
Expected: '' 
Actual: 'important'

Works well in Firefox 4.0b5.
Comment 1 Xianzhu Wang 2010-11-06 03:54:35 PDT
Created attachment 73169 [details]
test case of ignored setProperty()

For the failing cases, setProperty() sets neither priority nor property value.
A setProperty() call will be ignored if
a) the property has 'important' priority before the call;
and
b) the third parameter of the call is omitted, null or empty string
Comment 2 Jason Liu 2011-06-03 01:36:10 PDT
Created attachment 95873 [details]
Patch

Root cause: setProperty will fail when the style is !important.
Comment 3 Alexey Proskuryakov 2011-06-03 08:52:07 PDT
Comment on attachment 95873 [details]
Patch

+        Fixed bug https://bugs.webkit.org/show_bug.cgi?id=45778.

Please see existing entries in ChangeLog for preferred format. There should be bug title and bug URL.

+        No new tests. (OOPS!)

A test is definitely needed for a fix like this, please add it.
Comment 4 Jason Liu 2011-06-06 22:42:03 PDT
Created attachment 96207 [details]
patch

patch
Comment 5 Simon Fraser (smfr) 2011-06-06 22:51:03 PDT
Comment on attachment 96207 [details]
patch

Looks like your patch is backwards. It's removing code.
Comment 6 Jason Liu 2011-06-06 23:20:38 PDT
Created attachment 96211 [details]
Patch

Patch
Comment 7 Ryosuke Niwa 2011-09-14 20:47:54 PDT
Comment on attachment 96211 [details]
Patch

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

> LayoutTests/css1/font_properties/font_style_setProperty.html:4
> +<TITLE>CSS1 Test Suite: change value of an important property by setting JS property</TITLE>

Is this really a part of CSS1 test suite?  Could you tell us where you copied it from?
Comment 8 Jason Liu 2011-10-12 02:29:18 PDT
(In reply to comment #7)
> (From update of attachment 96211 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=96211&action=review
> 
> > LayoutTests/css1/font_properties/font_style_setProperty.html:4
> > +<TITLE>CSS1 Test Suite: change value of an important property by setting JS property</TITLE>
> 
> Is this really a part of CSS1 test suite?  Could you tell us where you copied it from?

I wrote it by myself.
Is there anything wrong?
Thanks for your help.
Comment 9 Alexey Proskuryakov 2011-10-12 08:37:53 PDT
Comment on attachment 96211 [details]
Patch

LayoutTests/css1 is a location for official CSS 1 test suite. This new test should be added to fast/dom/CSSStyleDeclaration directory.

It should also be a text-only test, so that all platforms could share results without trouble. You can read back resulting style with getComputedStyle(). I recommend that you re-create the test using make-new-script-test script, which will add boilerplate for this style of test:

make-new-script-test fast/dom/CSSStyleDeclaration/setProperty-important.html

Sorry about slow review turnaround.
Comment 10 Marc Hoyois 2013-07-12 11:46:58 PDT
> A setProperty() call will be ignored if
> a) the property has 'important' priority before the call;
> and
> b) the third parameter of the call is omitted, null or empty string

This is still an issue in the latest WebKit…
The current behavior does not respect the algorithm for setProperty described here: http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
Comment 11 Ahmad Saleem 2022-06-23 16:29:06 PDT
Created attachment 460468 [details]
Safari 15.5 matches other browsers

I took a test case from the patch and changed it into following JSFiddle:

Link - https://jsfiddle.net/vsx91qgy/show

As seen in the attached screenshot, all browsers have same output and only difference from expected result is on d5 <div>.

I am not sure whether the above behavior is aligned with the web-spec or not (as mentioned in Comment 10) but since it is matching all behavior, should we consider it as "RESOLVED INVALID" or "RESOLVED CONFIGURATION CHANGED"? If web-spec have been updated and it is intended output then can we consider it - "RESOLVED INVALID"? In case, if web-spec need clarity, can it be raised by someone separately? Thanks!