Skip to content

Commit

Permalink
[MQ5] Ensure that media “scripting: initial-only” never matches
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260432

Reviewed by Tim Nguyen.

w3c/csswg-drafts#8621

* LayoutTests/fast/css/media-query-scripting-initial-only-expected.html: Added.
* LayoutTests/fast/css/media-query-scripting-initial-only.html: Added.
* Source/WebCore/css/query/MediaQueryFeatures.cpp:
(WebCore::MQ::Features::scripting):

Canonical link: https://commits.webkit.org/267198@main
  • Loading branch information
sideshowbarker authored and nt1m committed Aug 23, 2023
1 parent 508ac94 commit 706e894
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<html style="color: green;"><p>This text should be green when printing.</p></html>
18 changes: 18 additions & 0 deletions LayoutTests/fast/css/media-query-scripting-initial-only.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<style>
:root {
color: green;
}
@media (scripting: initial-only) {
:root {
color: red;
}
}
</style>
<p>This text should be green when printing.</p>
<script>
if (window.internals)
internals.settings.setMediaTypeOverride("print");
</script>
</html>
5 changes: 0 additions & 5 deletions Source/WebCore/css/query/MediaQueryFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,6 @@ const FeatureSchema& scripting()

if (!frame.script().canExecuteScripts(ReasonForCallingCanExecuteScripts::NotAboutToExecuteScript))
return MatchingIdentifiers { CSSValueNone };

auto* frameView = frame.view();
if (frameView && frameView->mediaType() == printAtom())
return MatchingIdentifiers { CSSValueInitialOnly };

return MatchingIdentifiers { CSSValueEnabled };
}
};
Expand Down

0 comments on commit 706e894

Please sign in to comment.