<?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>283645</bug_id>
          
          <creation_ts>2024-11-24 01:27:08 -0800</creation_ts>
          <short_desc>AX: content of &lt;script&gt; elements announced by VoiceOver inside containers with display: contents</short_desc>
          <delta_ts>2024-12-16 08:45:08 -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>Accessibility</component>
          <version>Safari 18</version>
          <rep_platform>All</rep_platform>
          <op_sys>macOS 15</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Swithinbank">swithinbank</reporter>
          <assigned_to name="Tyler Wilcock">tyler_w</assigned_to>
          <cc>andresg_22</cc>
    
    <cc>aroselli</cc>
    
    <cc>tyler_w</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2077379</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Swithinbank">swithinbank</who>
    <bug_when>2024-11-24 01:27:08 -0800</bug_when>
    <thetext>If an HTML&lt;script&gt; is placed inside a container which has the display: contents; CSS rule applied to it, VoiceOver unexpectedly announces the script&apos;s content when the page is viewed in Safari. 

For example, imagine  an HTML document with the following contents:

```html
&lt;div class=&quot;contents&quot;&gt;
  &lt;script&gt;
    // Should not be announced
    console.log(&quot;Hello, world&quot;);
  &lt;/script&gt;
  &lt;p&gt;Should be announced&lt;/p&gt;
&lt;/div&gt;

&lt;style&gt;
.contents {
  display: contents; 
}
&lt;/style&gt;
```

Navigating to this page in Safari using VoiceOver will announce &quot;slash slash should not be announced...&quot; and so forth even though a &lt;script&gt; element is not intended to be exposed in this way. Other browsers correctly avoid announcing the script element.

In Safari, removing the display: contents; rule stops the script from being announced, so it seems to be related to how that rule effects child elements in the accessibility tree.

Related GitHub PR where we encountered this: https://github.com/withastro/starlight/pull/2633

Versions tested (the bug occurs in both cases): 
- macOS 14.6 + Safari 17.6
- macOS 15.1 + Safari 18.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2077380</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-11-24 01:28:09 -0800</bug_when>
    <thetext>&lt;rdar://problem/140493798&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2077949</commentid>
    <comment_count>2</comment_count>
    <who name="Tyler Wilcock">tyler_w</who>
    <bug_when>2024-11-27 16:23:14 -0800</bug_when>
    <thetext>Thanks for the bug report! I cannot reproduce the issue with your HTML snippet (are you able to?), but can reproduce the issue on https://starlight.astro.build/getting-started if I remove the aria-hidden=&quot;true&quot; attributes added in https://github.com/withastro/starlight/pull/2633. I&apos;ll investigate directly on https://starlight.astro.build/getting-started and see if I can figure out what&apos;s going on.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2077999</commentid>
    <comment_count>3</comment_count>
    <who name="Tyler Wilcock">tyler_w</who>
    <bug_when>2024-11-27 22:27:21 -0800</bug_when>
    <thetext>OK, figured it out, will put a PR up tomorrow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078029</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Swithinbank">swithinbank</who>
    <bug_when>2024-11-28 01:12:29 -0800</bug_when>
    <thetext>Thank you! And sorry, I should have at least included links to something reproducible.

For the record, here are permalinks to a page exhibiting the issue just before and after we fixed it with `aria-hidden=&quot;true&quot;`:

- Broken: https://6741e7a0340c47000832d471--astro-starlight.netlify.app/getting-started/
- Fixed: https://674433563413160008f164fc--astro-starlight.netlify.app/getting-started/

The bug is visible when moving into the navigation sidebar on the left with VoiceOver. The `&lt;script&gt;` element just inside the `&lt;sl-sidebar-state-persist&gt;` gets announced in the broken version.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078063</commentid>
    <comment_count>5</comment_count>
    <who name="Tyler Wilcock">tyler_w</who>
    <bug_when>2024-11-28 07:36:39 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/37227</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078100</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-11-28 16:11:47 -0800</bug_when>
    <thetext>Committed 287159@main (db2c73f6239b): &lt;https://commits.webkit.org/287159@main&gt;

Reviewed commits have been landed. Closing PR #37227 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078105</commentid>
    <comment_count>7</comment_count>
    <who name="Tyler Wilcock">tyler_w</who>
    <bug_when>2024-11-28 16:41:58 -0800</bug_when>
    <thetext>&gt; For the record, here are permalinks to a page exhibiting the issue just before and after we fixed it with `aria-hidden=&quot;true&quot;`:
Thanks for this, and thanks again for the bug report!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078136</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Swithinbank">swithinbank</who>
    <bug_when>2024-11-29 00:50:05 -0800</bug_when>
    <thetext>Thank you for the quick response and PR!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2082046</commentid>
    <comment_count>9</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-12-16 08:45:08 -0800</bug_when>
    <thetext>Committed 283286.594@safari-7620-branch (a32d9df60636): &lt;https://commits.webkit.org/283286.594@safari-7620-branch&gt;

Reviewed commits have been landed. Closing PR #2398 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>