New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 876760 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 24
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Mac
Pri: 2
Type: Bug



Sign in to add a comment

min-color doesn't match inside cross-origin iframe

Project Member Reported by jridgewell@google.com, Aug 22

Issue description

Chrome Version: Version 68.0.3440.106 (Official Build) (64-bit)
OS: OS X 10.12.6

What steps will reproduce the problem?
(1) Goto: https://output.jsbin.com/pinopab/quiet
(2) Observe first iframe (cross-origin) includes "Failed to match min-color"
(3) Observe second iframe (same-origin) hides it 

What is the expected result?

Both iframes should match min-color media queries.

What happens instead?

Cross-origin iframes fail to match min-color media queries.
 
Components: -Blink>CSS Internals>Sandbox>SiteIsolation
Components: Blink>CSS
Cc: creis@chromium.org nasko@chromium.org
Labels: -Pri-3 OS-Linux Pri-2
Confirmed with ToT build that the bug is indeed specific to OOPIFs. 
Cc: andruud@chromium.org futhark@chromium.org
Owner: futhark@chromium.org
Status: Assigned (was: Untriaged)
Thanks for the pointer! I took a quick look and it seems that there are two methods in this file that explicitly check for LocalFrame and return early. The rest of the methods query directly, so I tried a quick test to remove the early returns and the test page rendered fine. Here is a diff of what I tried:

diff --git a/third_party/blink/renderer/core/css/media_values.cc b/third_party/blink/renderer/core/css/media_values.cc                                                  
index c2b522a84ddc..904b91eaaa6d 100644
--- a/third_party/blink/renderer/core/css/media_values.cc
+++ b/third_party/blink/renderer/core/css/media_values.cc
@@ -76,9 +76,6 @@ int MediaValues::CalculateColorBitsPerComponent(LocalFrame* frame) {
   DCHECK(frame);
   DCHECK(frame->GetPage());
   DCHECK(frame->GetPage()->MainFrame());
-  if (!frame->GetPage()->MainFrame()->IsLocalFrame() ||
-      frame->GetPage()->GetChromeClient().GetScreenInfo().is_monochrome)
-    return 0;
   return frame->GetPage()
       ->GetChromeClient()
       .GetScreenInfo()
@@ -89,9 +86,6 @@ int MediaValues::CalculateMonochromeBitsPerComponent(LocalFrame* frame) {
   DCHECK(frame);
   DCHECK(frame->GetPage());
   DCHECK(frame->GetPage()->MainFrame());
-  if (!frame->GetPage()->MainFrame()->IsLocalFrame() ||
-      !frame->GetPage()->GetChromeClient().GetScreenInfo().is_monochrome)
-    return 0;
   return frame->GetPage()
       ->GetChromeClient()
       .GetScreenInfo()

Note that I haven't run any other tests, so it is quite possible some tests might break, though I would posit that this should be the right behavior.
Thanks for the code link.

Seems the bad behavior was introduced in https://codereview.chromium.org/336553003/. I think the monochrome checks are needed, but the mainFrame checks are the issue.
Project Member

Comment 9 by bugdroid1@chromium.org, Sep 24

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a3f28c81b8ceb9f8cc6edc985305c87a123007bc

commit a3f28c81b8ceb9f8cc6edc985305c87a123007bc
Author: Rune Lillesveen <futhark@chromium.org>
Date: Mon Sep 24 08:59:18 2018

Get ScreenInfo from Page's client regardless of OOPIF.

Two of the MediaValues calculations ignored ScreenInfo when called from
out-of-process iframes. There is no reason to do that. Just skip that
check.

Bug:  876760 
Change-Id: I6d5139f9bcbaaac45c7fcaa764d84b41151a93a9
Reviewed-on: https://chromium-review.googlesource.com/1238542
Reviewed-by: Anders Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593492}
[modify] https://crrev.com/a3f28c81b8ceb9f8cc6edc985305c87a123007bc/third_party/blink/renderer/core/css/media_values.cc
[modify] https://crrev.com/a3f28c81b8ceb9f8cc6edc985305c87a123007bc/third_party/blink/renderer/core/exported/web_frame_test.cc

Status: Fixed (was: Started)
The fix seems very simple and safe. Should we merge it to M70 to ensure it reaches users faster?

Sign in to add a comment