mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-15 17:55:15 -10:00
This patch looks bigger than it is, but it's mostly because of plumbing. To implement revert-layer we need not only the cascade origin of the declaration, but the whole cascade level, plus also the layer order. In order to do this, encapsulate these two things inside a 32-bit `CascadePriority` struct and plumb it through the rule tree and so on. This allows us to remove the packing and unpacking of CascadeLevel, though I kept the ShadowCascadeOrder limit for now in case we need to reintroduce it. Fix `!important` behavior of layers while at it (implementing it in `CascadeLevel::cmp`, spec quote included since it was tricky to find) since some revert-layer tests were depending on it. The style attribute test is failing now, but follow-up commit fixes it, see spec issue. In terms of the actual keyword implementation, it's sort of straight-forward: We implement revert and revert-layer in a shared way, by storing the cascade priority that reverted it. Differential Revision: https://phabricator.services.mozilla.com/D133372
73 lines
2.6 KiB
HTML
73 lines
2.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
Bug 1265798 - Replace inIDOMUtils.cssPropertyIsShorthand
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test CSS Properties Actor</title>
|
|
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
|
<script type="application/javascript" src="inspector-helpers.js"></script>
|
|
<script type="application/javascript">
|
|
"use strict";
|
|
|
|
window.onload = function() {
|
|
function toSortedString(array) {
|
|
return JSON.stringify(array.sort());
|
|
}
|
|
|
|
const runCssPropertiesTests = async function(url) {
|
|
info(`Opening tab with CssPropertiesActor support.`);
|
|
// Open a new tab. The only property we are interested in is `target`.
|
|
const { target } = await attachURL(url);
|
|
const { cssProperties } = await target.getFront("cssProperties");
|
|
|
|
ok(cssProperties.isKnown("border"),
|
|
"The `border` shorthand property is known.");
|
|
ok(cssProperties.isKnown("display"),
|
|
"The `display` property is known.");
|
|
ok(!cssProperties.isKnown("foobar"),
|
|
"A fake property is not known.");
|
|
ok(cssProperties.isKnown("--foobar"),
|
|
"A CSS variable properly evaluates.");
|
|
ok(cssProperties.isKnown("--foob\\{ar"),
|
|
"A CSS variable with escaped character properly evaluates.");
|
|
ok(cssProperties.isKnown("--fübar"),
|
|
"A CSS variable unicode properly evaluates.");
|
|
ok(!cssProperties.isKnown("--foo bar"),
|
|
"A CSS variable with spaces fails");
|
|
|
|
is(toSortedString(cssProperties.getValues("margin")),
|
|
toSortedString(["auto", "inherit", "initial", "unset", "revert", "revert-layer"]),
|
|
"Can get values for the CSS margin.");
|
|
is(cssProperties.getValues("foobar").length, 0,
|
|
"Unknown values return an empty array.");
|
|
|
|
const bgColorValues = cssProperties.getValues("background-color");
|
|
ok(bgColorValues.includes("blanchedalmond"),
|
|
"A property with color values includes blanchedalmond.");
|
|
ok(bgColorValues.includes("papayawhip"),
|
|
"A property with color values includes papayawhip.");
|
|
ok(bgColorValues.includes("rgb"),
|
|
"A property with color values includes non-colors.");
|
|
};
|
|
|
|
addAsyncTest(async function setup() {
|
|
const url = document.getElementById("cssProperties").href;
|
|
await runCssPropertiesTests(url);
|
|
|
|
runNextTest();
|
|
});
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
runNextTest();
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1265798">Mozilla Bug 1265798</a>
|
|
<a id="cssProperties" target="_blank" href="inspector_css-properties.html">Test Document</a>
|
|
</body>
|
|
</html>
|