<?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>311812</bug_id>
          
          <creation_ts>2026-04-09 05:27:55 -0700</creation_ts>
          <short_desc>[site-isolation] WTR does not correctly generate the expected.png for color-scheme related tests</short_desc>
          <delta_ts>2026-05-04 16:22:55 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>309611</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=311766</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=284973</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=309611</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="Carlos Alberto Lopez Perez">clopez</reporter>
          <assigned_to name="Kiet Ho">kiet.ho</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>kiet.ho</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>2198335</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2026-04-09 05:27:55 -0700</bug_when>
    <thetext>This is a bug that i discovered meanwhile working on bug 311766

I can only reproduce on Mac, because on GTK/WPE site-isolation support seems broken and tests timeout.

To reproduce use the following 3 tests:

http/tests/css/prefers-color-scheme-in-cross-origin-iframe-follows-system-preference-without-parent-color-scheme.html 
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub.html 
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub.html

And to the following

1) Ensure that the tests should fail

echo &apos;&lt;html&gt;&lt;body&gt;&lt;h1&gt;I should fail!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;&apos; &gt; LayoutTests/http/tests/css/prefers-color-scheme-in-cross-origin-iframe-follows-system-preference-without-parent-color-scheme-expected.html
echo &apos;&lt;html&gt;&lt;body&gt;&lt;h1&gt;I should fail!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;&apos; &gt; LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub-expected.html 
echo &apos;&lt;html&gt;&lt;body&gt;&lt;h1&gt;I should fail!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;&apos; &gt; LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub-expected.html

That is, invalidate the expected file so it clearly should fail.

2) Now check the results before and after the fix from https://github.com/WebKit/WebKit/pull/62312 on ‎Source/WebCore/css/query/MediaQueryFeatures.cpp

Case A) With the fix from pull/62312 the 3 tests fail with site-isolation enabled. But the expected.png file rendered has nothing to do with the &quot;I should fail&quot; image that it should generate. It looks like instead of that -expected.html it is picking the test .html

Case B) Without the fix from pull/62312 all the 3 tests pass with site-isolation enabled! how that can be? clearly something wrong in the runner.

The command that I use to check this is the following:

./Tools/Scripts/run-webkit-tests --no-show-results --no-new-test-results --no-sample-on-timeout --no-build --results-directory layout-test-results --debug-rwt-logging --site-isolation --release  --no-retry-failures --expect-pass  http/tests/css/prefers-color-scheme-in-cross-origin-iframe-follows-system-preference-without-parent-color-scheme.html  imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub.html  imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2198336</commentid>
    <comment_count>1</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2026-04-09 05:28:09 -0700</bug_when>
    <thetext>Note: i&apos;m only reporting the bug. I don&apos;t plan to work on fixing this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2198403</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-04-09 09:51:31 -0700</bug_when>
    <thetext>&lt;rdar://problem/174417711&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2199534</commentid>
    <comment_count>3</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-04-12 19:07:16 -0700</bug_when>
    <thetext>If I remember correctly, run-webkit-tests --site-isolation compares the rendering result of the test file only (not -expected.html) between SI-enabled and SI-disabled, it doesn&apos;t check with the expected file at all. In other words, if the same test renders differently between SI-enabled and SI-disabled, that&apos;s a fail.

Given that, the three test cases you cited should pass without pull/62312 (case B), and should fail with pull/62312 (case A), because your change checks ownerRenderer() of the frame, which is not available in SI-enabled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2202051</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2026-04-19 16:23:22 -0700</bug_when>
    <thetext>(In reply to Kiet Ho from comment #3)
&gt; If I remember correctly, run-webkit-tests --site-isolation compares the
&gt; rendering result of the test file only (not -expected.html) between
&gt; SI-enabled and SI-disabled, it doesn&apos;t check with the expected file at all.

Why is that?
That means that any test will pass meanwhile it renders the same thing with SI or without SI enabled. That makes the test meaningless, as the expected is not checked.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206371</commentid>
    <comment_count>5</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-04-30 14:14:44 -0700</bug_when>
    <thetext>I don&apos;t make the tooling so I don&apos;t know. I think it&apos;s because --site-isolation is meant to test that SI and non-SI render identically.

I assume if non-SI render identically to the expected file, and SI renders the test identically to non-SI, then you could say that SI renders identically to the expected result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206396</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2026-04-30 15:08:01 -0700</bug_when>
    <thetext>(In reply to Kiet Ho from comment #5)
&gt; I don&apos;t make the tooling so I don&apos;t know. I think it&apos;s because
&gt; --site-isolation is meant to test that SI and non-SI render identically.
&gt; 
&gt; I assume if non-SI render identically to the expected file, and SI renders
&gt; the test identically to non-SI, then you could say that SI renders
&gt; identically to the expected result.

That makes sense, but that is not what is happening here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2207339</commentid>
    <comment_count>7</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-05-04 13:29:05 -0700</bug_when>
    <thetext>(sorry for the gap in replies, I just realized my bugzilla email was disabled so I didn&apos;t get any email notifications)

Let&apos;s back up a little bit:

&gt; With the fix from pull/62312 the 3 tests fail with site-isolation enabled. But the expected.png file rendered has nothing to do with the &quot;I should fail&quot; image that it should generate. It looks like instead of that -expected.html it is picking the test .html

run-webkit-tests --site-isolation does not use -expected.html at all. Instead it renders the test page in SI and non-SI, and use the non-SI as expected rendering. Therefore it only checks that a test page renders identically in SI vs non-SI mode, it doesn&apos;t check that the test page in SI mode renders identically to the expected page. You modified the -expected.html file, but it doesn&apos;t get used by --site-isolation, hence you didn&apos;t see the &quot;I should fail&quot;

With your fix in pull/62312, it&apos;s expected that the three tests you mentioned would fail with --site-isolation. Your fix uses frame.ownerRenderer(), which when running in a cross-origin iframe, would return null (because the owner renderer object is in another web content process). This leads to the @prefers (media-color-scheme) code not calling protect(parent-&gt;virtualView())-&gt;ownerElementOfChildFrameUsesDarkAppearance() (note that ownerElementOfChildFrameUsesDarkAppearance() is safe to be called in Site Isolation, as we synchronize the dark appearance of owner renderer between web content processes)

&gt; Case B) Without the fix from pull/62312 all the 3 tests pass with site-isolation enabled! how that can be? clearly something wrong in the runner.

This makes sense, since without the fix, we just call ownerElementOfChildFrameUsesDarkAppearance(), which is SI safe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2207340</commentid>
    <comment_count>8</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-05-04 13:31:16 -0700</bug_when>
    <thetext>I&apos;ve fixed the use of ownerRenderer() in 312212@main (bug 309611), so those tests should be passing now. I&apos;ll dupe this to bug 309611 then.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2207341</commentid>
    <comment_count>9</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-05-04 13:31:24 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 309611 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2207409</commentid>
    <comment_count>10</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2026-05-04 16:22:55 -0700</bug_when>
    <thetext>I see, thanks for the explanation. I understand now better the issue.
I think is quite confusing this behavior of run-webkit-tests with --site-isolation, but at least now I know how it works. Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>