<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>243539</bug_id>
          
          <creation_ts>2022-08-04 06:20:20 -0700</creation_ts>
          <short_desc>Correct getComputedStyle() for invalid pseudo-elements</short_desc>
          <delta_ts>2023-12-31 09:33:48 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari 15</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 12</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=265237</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=264103</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>266862</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Anne van Kesteren">annevk</assigned_to>
          <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>karlcow</cc>
    
    <cc>marc.hoyois</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1888845</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-08-04 06:20:20 -0700</bug_when>
    <thetext>Hi Team,

Another test case from Chrome Bugs, where all browsers are different and I just wanted to share the latest share of Safari 15.6 on macOS 12.5:

Test Case - https://jsfiddle.net/rdb1jz8n/show

Chrome Bug - https://bugs.chromium.org/p/chromium/issues/detail?id=1197620

*** STEPS TO REPRODUCE ***

1) Run Test Case
2) Go to Console [Safari Developer Tools] and Run following:

getComputedStyle(document.getElementById(&quot;a&quot;), &quot;selection&quot;).color
getComputedStyle(document.getElementById(&quot;a&quot;), &quot;:selection&quot;).color

&lt;&gt; EXPECTED RESULTS:

&quot;rgb(0, 0, 0)&quot;
&quot;rgb(0, 0, 0)&quot;

&lt;&gt; ACTUAL RESULTS:

&quot;rgb(255, 0, 0)&quot;
&quot;rgb(255, 0, 0)&quot;

_________

All other browsers output:

Firefox Nightly 105 -&gt; &quot;rgb(0, 0, 0)&quot; &amp; &quot;&quot; (for first and second case respectively)
Chrome Canary 105 -&gt; &quot;rgb(255, 0, 0)&quot; for both and matching Safari right now

______

Appreciate if we can align with web-spec and fix this across all browsers. If it is duplicate then please mark and if it is fixed upstream then please also mark duplicate in reference to other.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889359</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-08-06 05:27:25 -0700</bug_when>
    <thetext>*** Bug 67157 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1890565</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-08-11 06:21:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/98504661&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1918373</commentid>
    <comment_count>3</comment_count>
      <attachid>463998</attachid>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-11 20:24:59 -0800</bug_when>
    <thetext>Created attachment 463998
wpt test case

According to the specification Firefox seems to do the right thing here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1918374</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-11 20:26:52 -0800</bug_when>
    <thetext>The spec is https://w3c.github.io/csswg-drafts/cssom/#dom-window-getcomputedstyle</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1918378</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-11 20:41:50 -0800</bug_when>
    <thetext>The code doesn&apos;t check in the first place if the pseudo-element starts with `:` before trying to remove them.
https://searchfox.org/wubkat/source/Source/WebCore/css/CSSComputedStyleDeclaration.cpp#49-59</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1918392</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-11 23:30:27 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/7468</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1918412</commentid>
    <comment_count>7</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-12 00:41:57 -0800</bug_when>
    <thetext>see Also https://github.com/web-platform-tests/wpt/pull/37452
for the WPT test.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1918680</commentid>
    <comment_count>8</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-12 17:11:13 -0800</bug_when>
    <thetext>There is a discussion going on https://github.com/web-platform-tests/wpt/pull/37452#discussion_r1046510669

Basically all browsers have issues currently, but Blink and WebKit right now should really validate the `::pseudoId`

&lt;style&gt;
#pseudo-invalid::marker {
  color: rgb(0 128 0);
}
#pseudo-invalid {
  color: rgb(255 0 0)
}
&lt;/style&gt;
&lt;!-- dot is green, text is red --&gt;
  &lt;ul&gt;&lt;li id=&quot;pseudo-invalid&quot;&gt;Item&lt;/li&gt;&lt;/ul&gt;



getComputedStyle(document.getElementById(&quot;li&quot;), &quot;marker&quot;).color

EXPECTED: &apos;&apos;               
ACTUAL: 
Safari   &apos;rgb(0, 128, 0)&apos;
Firefox  &apos;rgb(255, 0, 0)&apos;      
Chrome   &apos;rgb(0, 128, 0)&apos;

getComputedStyle(document.getElementById(&quot;li&quot;), &quot;:marker&quot;).color

EXPECTED: &apos;&apos;               
ACTUAL: 
Safari   &apos;rgb(0, 128, 0)&apos;
Firefox  &apos;&apos;      
Chrome   &apos;rgb(0, 128, 0)&apos;

getComputedStyle(document.getElementById(&quot;li&quot;), &quot;foobar&quot;).color

EXPECTED: &apos;&apos;               
ACTUAL: 
Safari   &apos;rgb(255, 0, 0)&apos;
Firefox  &apos;rgb(255, 0, 0)&apos;      
Chrome   &apos;rgb(255, 0, 0)&apos;

getComputedStyle(document.getElementById(&quot;li&quot;), &quot;:foobar&quot;).color

EXPECTED: &apos;&apos;               
ACTUAL: 
Safari   &apos;rgb(255, 0, 0)&apos;
Firefox  &apos;&apos;      
Chrome   &apos;rgb(255, 0, 0)&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1919077</commentid>
    <comment_count>9</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-14 00:48:58 -0800</bug_when>
    <thetext>Another difference.

data:text/html,&lt;li style=&quot;color:red&quot;&gt;item&lt;/li&gt;

window.getComputedStyle(document.querySelector(&apos;li&apos;), &quot;::marker&quot;).color

Safari:  &apos;rgb(255, 0, 0)&apos;
Firefox: &apos;rgb(255, 0, 0)&apos;
Chrome:  &apos;rgb(255, 0, 0)&apos; 

window.getComputedStyle(document.querySelector(&apos;li&apos;), &quot;:marker&quot;).color

Safari:  &apos;rgb(255, 0, 0)&apos;
Firefox: &apos;&apos;
Chrome:  &apos;rgb(255, 0, 0)&apos; 

window.getComputedStyle(document.querySelector(&apos;li&apos;), &quot;marker&quot;).color

Safari:  &apos;rgb(255, 0, 0)&apos;
Firefox: &apos;rgb(255, 0, 0)&apos;
Chrome:  &apos;rgb(255, 0, 0)&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1919084</commentid>
    <comment_count>10</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-12-14 01:23:24 -0800</bug_when>
    <thetext>https://w3c.github.io/csswg-drafts/cssom/#ref-for-dom-window-getcomputedstyle

The getComputedStyle(elt, pseudoElt) method must run these steps:

1. Let doc be elt’s node document.
2. Let obj be elt.
3. If pseudoElt is provided, is not the empty string, and starts with a colon, then:
   3.1 Parse pseudoElt as a &lt;pseudo-element-selector&gt;, and let type be the result.
   3.2 If type is failure, or is an ::slotted() or ::part() pseudo-element, let obj be null.
   3.3 Otherwise let obj be the given pseudo-element of elt.
       Note: CSS2 pseudo-elements should match both the double 
       and single-colon versions. That is, both :before 
       and ::before should match above.
4. Let decls be an empty list of CSS declarations.
5. If obj is not null, and elt is connected, part of the flat tree, and its shadow-including root has a browsing context which either doesn’t have a browsing context container, or whose browsing context container is being rendered, set decls to a list of all longhand properties that are supported CSS properties, in lexicographical order, with the value being the resolved value computed for obj using the style rules associated with doc. Additionally, append to decls all the custom properties whose computed value for obj is not the guaranteed-invalid value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001788</commentid>
    <comment_count>11</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-24 01:41:10 -0800</bug_when>
    <thetext>Given that isn&apos;t https://github.com/web-platform-tests/wpt/commit/c5a4bf6cbedee8b11c36a0bd499ffa16e917d618 wrong?

Why should it return the color of the element when the pseudo-element argument is invalid?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001790</commentid>
    <comment_count>12</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-24 01:53:38 -0800</bug_when>
    <thetext>Oh wait, it&apos;s correct because of the requirement that the argument needs to start with a colon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002142</commentid>
    <comment_count>13</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-28 07:55:02 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/22259</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002353</commentid>
    <comment_count>14</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-12-31 09:33:46 -0800</bug_when>
    <thetext>Committed 272543@main (080d12dea41b): &lt;https://commits.webkit.org/272543@main&gt;

Reviewed commits have been landed. Closing PR #22259 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>463998</attachid>
            <date>2022-12-11 20:24:59 -0800</date>
            <delta_ts>2022-12-11 20:24:59 -0800</delta_ts>
            <desc>wpt test case</desc>
            <filename>marker-syntax-computed-style.html</filename>
            <type>text/html</type>
            <size>1670</size>
            <attacher name="Karl Dubost">karlcow</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCjxoZWFkPgogICAgPG1ldGEgY2hhcnNl
dD0iVVRGLTgiIC8+CiAgICA8bGluayByZWw9ImF1dGhvciIgdGl0bGU9IkthcmwgRHVib3N0IiBo
cmVmPSJodHRwczovL2dpdGh1Yi5jb20va2FybGNvdyIgLz4KICAgIDxsaW5rIHJlbD0iaGVscCIg
aHJlZj0iaHR0cHM6Ly93M2MuZ2l0aHViLmlvL2Nzc3dnLWRyYWZ0cy9jc3MtcHNldWRvLyNtYXJr
ZXItcHNldWRvIiAvPgogICAgPGxpbmsgcmVsPSJoZWxwIiBocmVmPSJodHRwczovL3czYy5naXRo
dWIuaW8vY3Nzd2ctZHJhZnRzL2Nzcy12YXJpYWJsZXMvI2RlZmluaW5nLXZhcmlhYmxlcyIgLz4K
ICAgIDxzY3JpcHQgc3JjPSIvcmVzb3VyY2VzL3Rlc3RoYXJuZXNzLmpzIj48L3NjcmlwdD4KICAg
IDxzY3JpcHQgc3JjPSIvcmVzb3VyY2VzL3Rlc3RoYXJuZXNzcmVwb3J0LmpzIj48L3Njcmlw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aG91bGQgbm90IHJldHVybiB0aGUgY29sb3Igb2YgbWFya2Vy
YCk7CiAgICAgICAgdGVzdCgoKSA9PiB7CiAgICAgICAgICAgIGxldCBsaSA9IGRvY3VtZW50LnF1
ZXJ5U2VsZWN0b3IoJ2xpJyk7CiAgICAgICAgICAgIGxldCBtYXJrZXJTdHlsZSA9IGdldENvbXB1
dGVkU3R5bGUobGksICdtYXJrZXInKTsKICAgICAgICAgICAgYXNzZXJ0X2VxdWFscyhtYXJrZXJT
dHlsZS5jb2xvciwgInJnYigyNTUsIDAsIDApIiwgInRoZSByZXR1cm5lZCB2YWx1ZSBpcyB0aGUg
b25lIG9mIGxpLiIpOwogICAgICAgIH0sIGBnZXRDb21wdXRlZFN0eWxlKCkgZm9yIGludmFsaWQg
bWFya2VyIHJldHVybnMgdGhlIHZhbHVlIGZvciB0aGUgZWxlbWVudGApOwogICAgPC9zY3JpcHQ+
CjwvYm9keT4KCjwvaHRtbD4=
</data>

          </attachment>
      

    </bug>

</bugzilla>