min-color doesn't match inside cross-origin iframe |
|||||
Issue descriptionChrome 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.
,
Aug 27
,
Aug 27
Spec for @media: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/color
,
Aug 27
Confirmed with ToT build that the bug is indeed specific to OOPIFs.
,
Aug 27
Returning 0 when MainFrame() is not a LocalFrame here: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/media_values.cc?q=CalculateColorBitsPerComponent&sq=package:chromium&dr=CSs&l=79-81
,
Aug 27
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.
,
Aug 27
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.
,
Sep 21
,
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
,
Sep 24
,
Sep 24
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 |
|||||
Comment 1 by e...@chromium.org
, Aug 26