Bug 1914685 - [wpt-sync] Update web-platform-tests to 26c88095d89792c886494e30c85aca3...
[gecko.git] / layout / style / test / test_non_content_accessible_properties.html
blob220ddf2d2629a4c5758a275ca6fcf2bf13a5d563
1 <!doctype html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <iframe></iframe>
5 <iframe srcdoc="Foo"></iframe>
6 <script>
7 const CHROME_ONLY_PROPERTIES = [
8 "-moz-window-input-region-margin",
9 "-moz-window-shadow",
10 "-moz-window-opacity",
11 "-moz-window-transform",
12 "-moz-window-transform-origin",
13 "-moz-default-appearance",
14 "-moz-user-focus",
17 const UA_ONLY_PROPERTIES = [
18 "-x-span",
19 "-x-lang",
20 "-x-text-scale",
21 "-moz-control-character-visibility",
22 "-moz-top-layer",
23 "-moz-script-level",
24 "-moz-math-display",
25 "-moz-math-variant",
26 "-moz-inert",
27 "-moz-min-font-size-ratio",
28 // TODO: This should ideally be in CHROME_ONLY_PROPERTIES, but due to how
29 // [Pref] and [ChromeOnly] interact in WebIDL, the former wins.
30 "-moz-context-properties",
33 function testInWin(win) {
34 const doc = win.document;
35 const sheet = doc.createElement("style");
36 const div = doc.createElement("div");
37 doc.documentElement.appendChild(sheet);
38 doc.documentElement.appendChild(div);
40 sheet.textContent = `div { color: initial }`;
41 assert_equals(sheet.sheet.cssRules[0].style.length, 1, `sanity: ${doc.documentURI}`);
43 for (const prop of CHROME_ONLY_PROPERTIES.concat(UA_ONLY_PROPERTIES)) {
44 sheet.textContent = `div { ${prop}: initial }`;
45 let block = sheet.sheet.cssRules[0].style;
46 assert_false(prop in block, `${prop} shouldn't be exposed in CSS2Properties`);
48 let isUAOnly = UA_ONLY_PROPERTIES.includes(prop);
49 assert_equals(prop in SpecialPowers.wrap(block), !isUAOnly, `${prop} should be exposed to chrome code if needed`);
51 assert_equals(
52 block.length,
54 `${prop} shouldn't be parsed in ${doc.documentURI}`
56 block.setProperty(prop, "initial");
57 assert_equals(
58 block.length,
60 `${prop} shouldn't be settable via CSSOM in ${doc.documentURI}`
62 assert_equals(
63 win.getComputedStyle(div).getPropertyValue(prop),
64 "",
65 `${prop} shouldn't be accessible via CSSOM in ${doc.documentURI}`
67 assert_false(
68 win.CSS.supports(prop + ': initial'),
69 `${prop} shouldn't be exposed in CSS.supports in ${doc.documentURI}`
71 assert_false(
72 win.CSS.supports(prop, 'initial'),
73 `${prop} shouldn't be exposed in CSS.supports in ${doc.documentURI} (2-value version)`
78 let t = async_test("test non-content-accessible props");
79 onload = t.step_func_done(function() {
80 testInWin(window);
81 for (let f of document.querySelectorAll("iframe")) {
82 testInWin(f.contentWindow);
84 });
85 </script>