forked from mirrors/gecko-dev
Automatic update from web-platform-testsReland "[CSS Env Vars] Add some WPT tests" This is a reland of 981a543f9e743001a6e492a006873de3a5953747 This adds a bugfix that adds a DetachFromParent method that we call in StyleEngine. This stops the global environment variables instance holding a reference to the document one after the document has been disposed. Original change's description: > [CSS Env Vars] Add some WPT tests > > Adds some WPT tests to test env() with @supports as well > as fallback values. > > BUG=825890 > > Change-Id: I071f5c2582f8056fe39b4a50ab62140d579c577d > Reviewed-on: https://chromium-review.googlesource.com/1111023 > Reviewed-by: Rune Lillesveen <futhark@chromium.org> > Reviewed-by: Mounir Lamouri <mlamouri@chromium.org> > Commit-Queue: Becca Hughes <beccahughes@chromium.org> > Cr-Commit-Position: refs/heads/master@{#569852} Bug: 825890 Change-Id: If828b977d62145fb1ea9bb710a48d76307a054d5 Reviewed-on: https://chromium-review.googlesource.com/1113877 Reviewed-by: Emil A Eklund <eae@chromium.org> Commit-Queue: Becca Hughes <beccahughes@chromium.org> Cr-Commit-Position: refs/heads/master@{#570117} -- wpt-commits: 775bb3b7bf1e28c58d8381422e6755c3f6936b46 wpt-pr: 11658
57 lines
2.7 KiB
HTML
57 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link rel="help" href="https://drafts.csswg.org/css-env-1/">
|
|
<title>Test env() syntax</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<style>
|
|
div { background-color: rgb(0, 128, 0); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
// This value is expected if the syntax is valid.
|
|
const envWorkingValue = "rgba(0, 0, 0, 0)";
|
|
|
|
// This value is expected if the syntax is invalid.
|
|
const pageDefaultValue = "rgb(0, 128, 0)";
|
|
|
|
// This value is used to test fallback values.
|
|
const blueValue = "rgb(0, 0, 255)";
|
|
|
|
const testCases = [
|
|
{ style: "", expectedPropertyValue: pageDefaultValue },
|
|
{ style: "background-color: env(test)", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: ENV(test)", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test) !important", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test, 10px)", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test, blue)", expectedPropertyValue: blueValue },
|
|
{ style: "background-color: env(test, env(another))", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test, env(another, blue))", expectedPropertyValue: blueValue },
|
|
{ style: "background-color: env(-test)", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(--test)", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(10px)", expectedPropertyValue: pageDefaultValue },
|
|
{ style: "background-color: env(env(test))", expectedPropertyValue: pageDefaultValue },
|
|
{ style: "background-color: env( test)", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test )", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env( test )", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test /**/, blue)", expectedPropertyValue: blueValue },
|
|
{ style: "background-color: env(test, {})", expectedPropertyValue: envWorkingValue },
|
|
{ style: "background-color: env(test, {)", expectedPropertyValue: pageDefaultValue },
|
|
];
|
|
|
|
testCases.forEach((testcase) => {
|
|
test(() => {
|
|
const elem = document.createElement("div");
|
|
const style = window.getComputedStyle(elem);
|
|
|
|
document.body.appendChild(elem);
|
|
elem.style.cssText = testcase.style;
|
|
|
|
assert_equals(style.getPropertyValue("background-color"), testcase.expectedPropertyValue);
|
|
}, testcase.style + " " + testcase.expectedPropertyValue);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|