<?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>14586</bug_id>
          
          <creation_ts>2007-07-11 15:23:55 -0700</creation_ts>
          <short_desc>Dynamically inserted stylesheets cannot be accessed via document.styleSheets</short_desc>
          <delta_ts>2022-07-26 00:33:17 -0700</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>523.x (Safari 3)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=56932</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andy Allcorn">hawkman</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>ap</cc>
    
    <cc>mitch074</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4991</commentid>
    <comment_count>0</comment_count>
    <who name="Andy Allcorn">hawkman</who>
    <bug_when>2007-07-11 15:23:55 -0700</bug_when>
    <thetext>When adding a stylesheet by javascript (appendChild to the head element), it cannot be accessed via document.styleSheets and therefore cannot be modified (the styles do apply).

Reproduce: Add a stylesheet using javascript and attempt to find it (or its rules) through document.styleSheets

Actual results: The browser behaves as if the stylesheet is not added (despite using its contents).

Expected results: The stylesheet can be accessed through document.getStylesheets.

Does not occur on Firefox 2.0.0.2 - it correctly makes the stylesheet accessible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4974</commentid>
    <comment_count>1</comment_count>
      <attachid>15480</attachid>
    <who name="Andy Allcorn">hawkman</who>
    <bug_when>2007-07-11 15:31:14 -0700</bug_when>
    <thetext>Created attachment 15480
Test case (simple html + css files in zip archive)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4985</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-07-11 21:57:08 -0700</bug_when>
    <thetext>Confirmed with r24226.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4953</commentid>
    <comment_count>3</comment_count>
    <who name="Andy Allcorn">hawkman</who>
    <bug_when>2007-07-12 06:11:48 -0700</bug_when>
    <thetext>Followup - although Firefox makes the stylesheet visible it is still not editable, so it partially shares this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>216364</commentid>
    <comment_count>4</comment_count>
    <who name="Mitch 74">mitch074</who>
    <bug_when>2010-04-23 03:42:12 -0700</bug_when>
    <thetext>Three years and no work done on this...

Well now, a usable test case, that hits on a similar problem (I think this bug should be renamed anyway).

Webkit doesn&apos;t populate document.styleSheets with stylesheets other than the default/preferred one (no way to access alternate stylesheets for example), so there is no way to use a Javascript stylesheet switcher. The following methods don&apos;t work:

 - inserting a new stylesheet through Javascript then enabling it
 - disabling the preferred stylesheet
 - enabling an alternate stylesheet
 - disabling (as in, object.disabled=true) the (X)HTML element that loads the preferred stylesheet (STYLE or LINK tags)

Untested: deleting the DOM node.

Test case:

http://www.arcrachatcredits.org

This website disables the stylesheet &apos;style-vert-css2.css&apos; loaded through a STYLE tag in the head if the document&apos;s body is smaller than 640x400 (and re-enables it if resized above said resolution).

The test case works on Firefox 2.0 to 3.7a5pre, IE 7 (real and emulated) to 9, Opera 10.10.

It doesn&apos;t work in Konqueror 4.2, Chromium 5.0.339, Chrome 4.1.249.1045, Safari 4.0.5 (531.22.7).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>331375</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2011-01-08 21:32:40 -0800</bug_when>
    <thetext>That&apos;s what you said in bug 38113.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>331415</commentid>
    <comment_count>6</comment_count>
    <who name="Mitch 74">mitch074</who>
    <bug_when>2011-01-09 03:15:42 -0800</bug_when>
    <thetext>I said it in bug 38113 too because I would guess the two bugs are linked: Webkit doesn&apos;t support alternate stylesheets at all (outside of disregarding them) - eventhough Firefox, IE, Opera etc. do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886470</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-24 22:01:35 -0700</bug_when>
    <thetext>We do eventually show all style sheets. It&apos;s just that it happens asynchronously.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886476</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-24 22:17:59 -0700</bug_when>
    <thetext>(In reply to Ryosuke Niwa from comment #7)
&gt; We do eventually show all style sheets. It&apos;s just that it happens
&gt; asynchronously.

Actually, this is true of all major browser engines like Gecko and Blink.

So this must have been fixed as of https://commits.webkit.org/181549@main or sometime earlier than that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886477</commentid>
    <comment_count>9</comment_count>
      <attachid>461191</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-24 22:22:18 -0700</bug_when>
    <thetext>Created attachment 461191
Sync test case

This modified test case inserts a style element with inline style and checks document.styleSheets.length. Here, all major browsers including Safari show 1 as the result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886700</commentid>
    <comment_count>10</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-25 23:21:52 -0700</bug_when>
    <thetext>Let&apos;s add this as a test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886704</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-25 23:26:16 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/2731</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886716</commentid>
    <comment_count>12</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-07-26 00:32:37 -0700</bug_when>
    <thetext>Committed 252816@main (dc0078a2b47f): &lt;https://commits.webkit.org/252816@main&gt;

Reviewed commits have been landed. Closing PR #2731 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886717</commentid>
    <comment_count>13</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-07-26 00:33:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/97591536&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>15480</attachid>
            <date>2007-07-11 15:31:14 -0700</date>
            <delta_ts>2007-07-11 15:31:14 -0700</delta_ts>
            <desc>Test case (simple html + css files in zip archive)</desc>
            <filename>stylesheets-test-case.zip</filename>
            <type>application/zip</type>
            <size>853</size>
            <attacher name="Andy Allcorn">hawkman</attacher>
            
              <data encoding="base64">UEsDBAoAAAAAALO76zYAAAAAAAAAAAAAAAAWABAAc3R5bGVzaGVldHMgdGVzdCBjYXNlL1VYDADM
WZVG0VmVRvUB9QFQSwMEFAAIAAgAvbnrNgAAAAAAAAAAAAAAAB0AEABzdHlsZXNoZWV0cyB0ZXN0
IGNhc2UvcmVkLmNzc1VYDADWWZVGJlaVRvUB9QFLyk+pVKjm4kxKTM5OL8ovzUuxUihKTbHmqgUA
UEsHCIArnnUcAAAAGgAAAFBLAwQUAAgACABou+s2AAAAAAAAAAAAAAAAJAAQAHN0eWxlc2hlZXRz
IHRlc3QgY2FzZS90ZXN0IGNhc2UuaHRtbFVYDADWWZVGRFmVRvUB9QFlUbtSwzAQ7P0VN27sDDM2
NQgXYWjTJB1DIfsuliay5JHOGP89kjEEgho99nbvtCsUD6bJhCKJjajXLROtw6XJToqgld2l926y
CDx5G8BTPDkIys3AsSDwYigoIgYlA8hxNJqwEq2POqHzeuQmg7jepYcuhINDgidA100DWa46T5Lp
xVC6lYXR9lLsHlfGVl3xMiZKwfTBdXws/sKeTEKvg9zgA6GWa0XsRfYGVZ7OCYz/qv5ra0yYRCQ8
Jv0N/pm+J95GD/vlJPuDHKjMk4v57vX+rYp2kMVnpQ2Wm+buRmL2msnYMk9222loyYM7//I1eT46
z9H4dlk9b72bQyzT4QFyuLtqraTjSqoM2Z5V7Cbq7xhE/RVszDml/glQSwcIZq/lvx0BAAD8AQAA
UEsBAhUDCgAAAAAAs7vrNgAAAAAAAAAAAAAAABYADAAAAAAAAAAAQO1BAAAAAHN0eWxlc2hlZXRz
IHRlc3QgY2FzZS9VWAgAzFmVRtFZlUZQSwECFQMUAAgACAC9ues2gCuedRwAAAAaAAAAHQAMAAAA
AAAAAABApIFEAAAAc3R5bGVzaGVldHMgdGVzdCBjYXNlL3JlZC5jc3NVWAgA1lmVRiZWlUZQSwEC
FQMUAAgACABou+s2Zq/lvx0BAAD8AQAAJAAMAAAAAAAAAABApIG7AAAAc3R5bGVzaGVldHMgdGVz
dCBjYXNlL3Rlc3QgY2FzZS5odG1sVVgIANZZlUZEWZVGUEsFBgAAAAADAAMABQEAADoCAAAAAA==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>461191</attachid>
            <date>2022-07-24 22:22:18 -0700</date>
            <delta_ts>2022-07-24 22:22:18 -0700</delta_ts>
            <desc>Sync test case</desc>
            <filename>test-case-2.html</filename>
            <type>text/html</type>
            <size>393</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPjwvaGVhZD4KPGJvZHk+ClRoZSBiYWNrZ3JvdW5kIHR1cm5zIHJlZCB0byBz
aG93IHRoZSBzdHlsZXNoZWV0IGhhcyBhcHBsaWVkLjxicj4KPHNjcmlwdD4KICAgIGNvbnN0IGVs
ZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzdHlsZScpOwogICAgZWxlbWVudC50eXBl
ID0gJ3RleHQvY3NzJzsKICAgIGVsZW1lbnQucmVsID0gJ3N0eWxlc2hlZXQnOwogICAgZG9jdW1l
bnQuaGVhZC5hcHBlbmRDaGlsZChlbGVtZW50KTsKICAgIGRvY3VtZW50LndyaXRlbG4oIlRoZSBu
dW1iZXIgb2Ygc3R5bGVzaGVldHMgcmVwb3J0ZWQgYnkgdGhlIGJyb3dzZXIgaXM6ICIgKyBkb2N1
bWVudC5zdHlsZVNoZWV0cy5sZW5ndGgpOwo8L3NjcmlwdD4KPC9ib2R5Pgo8L2h0bWw+
</data>

          </attachment>
      

    </bug>

</bugzilla>