gecko-dev/layout/style/test/test_non_content_accessible...

174 строки
4.3 KiB
HTML

<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style id="sheet"></style>
<div></div>
<script>
const NON_CONTENT_ACCESSIBLE_VALUES = {
"color": [
"-moz-gtk-buttonactivetext",
],
"display": [
"-moz-grid",
"-moz-grid-group",
"-moz-grid-line",
"-moz-stack",
"-moz-deck",
"-moz-popup",
"-moz-groupbox",
],
"-moz-appearance": [
"button-arrow-down",
"button-arrow-next",
"button-arrow-previous",
"button-arrow-up",
"button-focus",
"dualbutton",
"groupbox",
"menubar",
"menuitem",
"checkmenuitem",
"radiomenuitem",
"menuitemtext",
"menupopup",
"menucheckbox",
"menuradio",
"menuseparator",
"menuarrow",
"menuimage",
"-moz-menulist-button",
"checkbox-container",
"radio-container",
"checkbox-label",
"radio-label",
"resizerpanel",
"resizer",
"scrollbar",
"scrollbar-small",
"scrollbar-horizontal",
"scrollbar-vertical",
"scrollbarbutton-up",
"scrollbarbutton-down",
"scrollbarbutton-left",
"scrollbarbutton-right",
"scrollcorner",
"separator",
"spinner",
"spinner-upbutton",
"spinner-downbutton",
"spinner-textfield",
"splitter",
"statusbar",
"statusbarpanel",
"tab",
"tabpanel",
"tabpanels",
"tab-scroll-arrow-back",
"tab-scroll-arrow-forward",
"toolbar",
"toolbarbutton",
"toolbarbutton-dropdown",
"toolbargripper",
"toolbox",
"tooltip",
"treeheader",
"treeheadercell",
"treeheadersortarrow",
"treeitem",
"treeline",
"treetwisty",
"treetwistyopen",
"treeview",
"window",
"dialog",
"-moz-win-communications-toolbox",
"-moz-win-media-toolbox",
"-moz-win-browsertabbar-toolbox",
"-moz-win-glass",
"-moz-win-borderless-glass",
"-moz-win-exclude-glass",
"-moz-mac-fullscreen-button",
"-moz-mac-help-button",
"-moz-window-button-box",
"-moz-window-button-box-maximized",
"-moz-window-button-close",
"-moz-window-button-maximize",
"-moz-window-button-minimize",
"-moz-window-button-restore",
"-moz-window-frame-bottom",
"-moz-window-frame-left",
"-moz-window-frame-right",
"-moz-window-titlebar",
"-moz-window-titlebar-maximized",
"-moz-gtk-info-bar",
"-moz-mac-active-source-list-selection",
"-moz-mac-disclosure-button-closed",
"-moz-mac-disclosure-button-open",
"-moz-mac-source-list",
"-moz-mac-source-list-selection",
"-moz-mac-vibrancy-dark",
"-moz-mac-vibrancy-light",
"-moz-mac-vibrant-titlebar-dark",
"-moz-mac-vibrant-titlebar-light",
"button-bevel",
"caret",
"listitem",
"menulist-textfield",
"menulist-text",
],
"-moz-user-select": [
"-moz-text",
],
"line-height": [
"-moz-block-height",
],
};
if (!SpecialPowers.getBoolPref("layout.css.xul-box-display-values.content.enabled")) {
NON_CONTENT_ACCESSIBLE_VALUES.display.push("-moz-box", "-moz-inline-box");
}
const sheet = document.getElementById("sheet");
const div = document.querySelector("div");
test(function() {
sheet.textContent = `div { color: initial }`;
assert_equals(sheet.sheet.cssRules[0].style.length, 1);
}, "sanity");
for (const prop in NON_CONTENT_ACCESSIBLE_VALUES) {
const values = NON_CONTENT_ACCESSIBLE_VALUES[prop];
test(function() {
for (const value of values) {
sheet.textContent = `div { ${prop}: ${value} }`;
const block = sheet.sheet.cssRules[0].style;
assert_equals(
block.length,
0,
`${prop}: ${value} should not be parsed in content`
);
block.setProperty(prop, value);
assert_equals(
block.length,
0,
`${prop}: ${value} should not be settable via CSSOM in content`
);
div.style.setProperty(prop, value);
assert_equals(
div.style.length,
0,
`${prop}: ${value} should not be settable via CSSOM in content (inline style)`
);
assert_not_equals(
getComputedStyle(div).getPropertyValue(prop),
value,
`${prop}: ${value} should not be settable via CSSOM in content (gcs)`
);
assert_false(CSS.supports(prop, value), `${prop}: ${value} should not claim to be supported`)
}
}, prop + " non-accessible values: " + values.join(", "))
}
</script>