Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Deprecate window.styleMedia and remove its matchMedium() method
https://bugs.webkit.org/show_bug.cgi?id=215236 Reviewed by Simon Fraser. window.styleMedia was defined in early CSSOM View Module draft [1] and later standardized as window.matchMedia. StyleMedia isn't implemented in Firefox and is barely documented for web developers. This patch: 1. Adds [MasqueradesAsUndefined] IDL attribute to StyleMedia interface, preventing its conditional usage, and exposes it with [NotEnumerable]. 2. Simplifies window.styleMedia.type to always return "screen" because, until recently, window.print() was blocking and "print" was never observed. Other media types are deprecated [2]. 3. Removes window.styleMedia.matchMedium() since its usage on the web [3] is as low as 0.02% of page loads. 4. Adds console deprecation message for window.styleMedia access, attempting to reduce its usage even further. [1] https://www.w3.org/TR/2009/WD-cssom-view-20090804 [2] https://www.w3.org/TR/mediaqueries-5/#media-types [3] https://www.chromestatus.com/metrics/feature/timeline/popularity/608 No new tests needed. * LayoutTests/fast/dom/style-media-null-document-element-expected.txt: Removed. * LayoutTests/fast/dom/style-media-null-document-element.html: Removed. * LayoutTests/fast/loader/window-properties-restored-from-page-cache-expected.txt: * LayoutTests/fast/loader/window-properties-restored-from-page-cache.html: * LayoutTests/fast/media/invalid-lengths.html: * LayoutTests/fast/media/lifetime-expected.txt: Removed. * LayoutTests/fast/media/lifetime.html: Removed. * LayoutTests/fast/media/matchmedium-query-api.html: * LayoutTests/fast/media/print-restores-previous-mediatype-expected.txt: * LayoutTests/fast/media/print-restores-previous-mediatype.html: * LayoutTests/fast/media/video-playable-inline-media-query.html: * LayoutTests/http/tests/dom/same-origin-detached-window-properties-expected.txt: * LayoutTests/http/tests/dom/same-origin-detached-window-properties.html: * Source/WebCore/css/StyleMedia.cpp: (WebCore::StyleMedia::StyleMedia): (WebCore::StyleMedia::type const): (WebCore::StyleMedia::matchMedium const): Deleted. * Source/WebCore/css/StyleMedia.h: * Source/WebCore/css/StyleMedia.idl: * Source/WebCore/page/DOMWindow+CSSOMView.idl: * Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js: Canonical link: https://commits.webkit.org/253168@main
- Loading branch information
1 parent
885184b
commit 2d61c2b
Showing
19 changed files
with
22 additions
and
146 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
LayoutTests/fast/dom/style-media-null-document-element-expected.txt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
LayoutTests/fast/dom/style-media-null-document-element.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
LayoutTests/fast/media/print-restores-previous-mediatype-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Media type is set to 'handheld' to be different than the default 'screen' | ||
PASS: window.styleMedia.type should be 'handheld' and is. | ||
PASS window.matchMedia('handheld').matches is true | ||
|
||
The page is printed, which changes the media type to 'print', and then back | ||
PASS: window.styleMedia.type should be 'handheld' and is. | ||
PASS window.matchMedia('handheld').matches is true | ||
|
29 changes: 6 additions & 23 deletions
29
LayoutTests/fast/media/print-restores-previous-mediatype.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,24 @@ | ||
<html> | ||
<head> | ||
<title>Test that print restores previous media type</title> | ||
<style type="text/css"> | ||
|
||
</style> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script type="text/javascript" charset="utf-8"> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
window.internals.settings.setMediaTypeOverride("handheld"); | ||
} | ||
|
||
function log(m) | ||
{ | ||
var results = document.getElementById('results'); | ||
results.innerHTML += m + '<br>'; | ||
} | ||
|
||
function shouldBe(aDescription, a, b) | ||
{ | ||
if (a === b) { | ||
log("PASS: " + aDescription + " should be '" + b + "' and is."); | ||
} else { | ||
log("FAIL: " + aDescription + " should be '" + b + "' but instead is '" + a + "'."); | ||
} | ||
} | ||
|
||
function runTests() | ||
{ | ||
log("Media type is set to 'handheld' to be different than the default 'screen'"); | ||
shouldBe("window.styleMedia.type", window.styleMedia.type, "handheld"); | ||
log("<br>The page is printed, which changes the media type to 'print', and then back"); | ||
debug("Media type is set to 'handheld' to be different than the default 'screen'"); | ||
shouldBeTrue("window.matchMedia('handheld').matches"); | ||
debug(""); | ||
debug("The page is printed, which changes the media type to 'print', and then back"); | ||
window.print(); | ||
shouldBe("window.styleMedia.type", window.styleMedia.type, "handheld"); | ||
shouldBeTrue("window.matchMedia('handheld').matches"); | ||
} | ||
</script> | ||
</head> | ||
<body onload="runTests()"> | ||
<div id="results"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...tests/WebIDL/ecmascript-binding/attributes-accessors-unique-function-objects-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CONSOLE MESSAGE: window.styleMedia is deprecated draft version of window.matchMedia API that is not implemented in Firefox and will be removed from the web platform in future. | ||
|
||
PASS For attributes, each copy of the accessor property has distinct built-in function objects for its getters and setters. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters