<?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>284973</bug_id>
          
          <creation_ts>2024-12-19 13:37:57 -0800</creation_ts>
          <short_desc>@media (prefers-color-scheme: dark) inside iframe not matching when the iframe itself has style.colorScheme = &apos;dark&apos;</short_desc>
          <delta_ts>2026-05-09 18:52:14 -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>Layout and Rendering</component>
          <version>Safari Technology Preview</version>
          <rep_platform>All</rep_platform>
          <op_sys>iOS 26</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=309611</see_also>
    
    <see_also>https://github.com/web-platform-tests/wpt/pull/58920</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=311766</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=311812</see_also>
          <bug_file_loc>https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io</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="Cetin Sert">cetin.sert</reporter>
          <assigned_to name="Kiet Ho">kiet.ho</assigned_to>
          <cc>akeerthi</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cetin.sert</cc>
    
    <cc>jacob</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>ntim</cc>
    
    <cc>rajsite</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2083099</commentid>
    <comment_count>0</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2024-12-19 13:37:57 -0800</bug_when>
    <thetext>When embedding a webpage inside an &lt;iframe&gt; and setting the iframe’s style to color-scheme: dark, other browsers correctly treat the framed document as if it supports and prefers a dark color scheme. As a result, @media (prefers-color-scheme: dark) rules inside the iframe correctly apply. However, in Safari (WebKit), the @media (prefers-color-scheme: dark) inside the iframe does not match, despite the iframe being explicitly set to color-scheme: dark. Neither adding a &lt;meta name=color-scheme content=&quot;dark light&quot;&gt; inside the iframe’s content nor other workarounds produce the expected behavior.

Interactive playground with minimal reproduction:
https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io

Works in latest stable Chrome/Edge (131), Firefox (133).
Doesn&apos;t work in Safari (18.2)!

Code
&lt;iframe style=color-scheme:dark srcdoc=&quot;
    &lt;style&gt;
      body { 
        font-family: system-ui;
        display: grid;
        place-items: center;
        height: 100dvh;
        margin: 0;
      }
      
      /* ↓ doesn&apos;t work in Safari */
      @media (prefers-color-scheme: dark) {
        body {
          background: #222;
          color: #fff;
        }
      }
    &lt;/style&gt;
    &lt;h2&gt;I&apos;m an iframe!&lt;/h2&gt;
&quot;&gt;
&lt;/iframe&gt;

This breaks output color scheme toggling on RTCode.io and potentially other playgrounds!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2083683</commentid>
    <comment_count>1</comment_count>
    <who name="Aditya Keerthi">akeerthi</who>
    <bug_when>2024-12-23 13:44:40 -0800</bug_when>
    <thetext>(this is because WebKit has not implemented the resolution in https://github.com/w3c/csswg-drafts/issues/7493 yet)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2083758</commentid>
    <comment_count>2</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2024-12-23 22:52:09 -0800</bug_when>
    <thetext>@Apple, see – https://github.com/w3c/csswg-drafts/issues/7493#issuecomment-1201691078
Looking forward to seeing your swift progress on this!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2084000</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-12-26 13:38:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/142072593&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2100137</commentid>
    <comment_count>4</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2025-03-03 19:13:52 -0800</bug_when>
    <thetext>Hope to see this in the next release!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135041</commentid>
    <comment_count>5</comment_count>
    <who name="Jacob Bandes-Storch">jacob</who>
    <bug_when>2025-08-07 16:04:45 -0700</bug_when>
    <thetext>Just ran into this as well. Would love to see this fixed – any update yet? 🙏</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2188795</commentid>
    <comment_count>6</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-03-10 12:41:46 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/60290</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2195991</commentid>
    <comment_count>7</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-04-01 13:48:28 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/58920</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196370</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-02 13:47:49 -0700</bug_when>
    <thetext>Committed 310465@main (34fc452fa59f): &lt;https://commits.webkit.org/310465@main&gt;

Reviewed commits have been landed. Closing PR #60290 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209361</commentid>
    <comment_count>9</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2026-05-09 11:13:56 -0700</bug_when>
    <thetext>Thank you everyone!

Is this in 26.4 or a future version!?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209365</commentid>
    <comment_count>10</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-05-09 11:32:18 -0700</bug_when>
    <thetext>This is available in STP 242 and newer, see this release note: https://developer.apple.com/documentation/safari-technology-preview-release-notes/stp-release-242

I don&apos;t know which iOS/macOS version would include this, sorry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209397</commentid>
    <comment_count>11</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2026-05-09 16:10:25 -0700</bug_when>
    <thetext>In STP Release 243 (WebKit 22625.1.15.19.1), this has improved a bit but your fix requires a reload of the host document in Safari, while other browser engines just work with host document reloads!

---

1. Open https://wk.rt.ht/bug/iframe/prefers-color-scheme/
2. Press the &quot;Toggle iframe color-scheme&quot; button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens)

---

1. Open https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
2. Press the &quot;Toggle iframe color-scheme&quot; button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens)
3. Press F5 to reload the host document too (Safari → ⚠️ updates on host document reload)
Safari → does not work)

---

Can you re-open this issue and redo your fix?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209398</commentid>
    <comment_count>12</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2026-05-09 16:11:46 -0700</bug_when>
    <thetext>Reopened due to the above issue!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209399</commentid>
    <comment_count>13</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2026-05-09 16:13:21 -0700</bug_when>
    <thetext>In STP Release 243 (WebKit 22625.1.15.19.1), this has improved a bit but your fix requires a reload of the host document in Safari, while other browser engines just work with host document reloads!

---

1. Open https://wk.rt.ht/bug/iframe/prefers-color-scheme/
2. Press the &quot;Toggle iframe color-scheme&quot; button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens)

---

1. Open https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
2. Press the &quot;Toggle iframe color-scheme&quot; button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens)
3. Press F5 to reload the host document too (Safari → ⚠️ updates only on host document reload)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209400</commentid>
    <comment_count>14</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2026-05-09 16:33:34 -0700</bug_when>
    <thetext>In STP Release 243 (WebKit 22625.1.15.19.1), this has improved a bit but your fix requires a reload of the host document in Safari, while other browser engines just work withOUT host document reloads!

---

1. Open https://wk.rt.ht/bug/iframe/prefers-color-scheme/
2. Press the &quot;Toggle iframe color-scheme&quot; button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens)

---

1. Open https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
2. Press the &quot;Toggle iframe color-scheme&quot; button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens)
3. Press F5 to reload the host document too (Safari → ⚠️ updates only on host document reload)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2209423</commentid>
    <comment_count>15</comment_count>
    <who name="Cetin Sert">cetin.sert</who>
    <bug_when>2026-05-09 18:52:14 -0700</bug_when>
    <thetext>Dynamic changes to color-scheme on the embedding iframe element do not cause prefers-color-scheme media queries in the embedded document to be re-evaluated.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>