diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /layout/style/test/test_non_content_accessible_pseudos.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/style/test/test_non_content_accessible_pseudos.html')
-rw-r--r-- | layout/style/test/test_non_content_accessible_pseudos.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/layout/style/test/test_non_content_accessible_pseudos.html b/layout/style/test/test_non_content_accessible_pseudos.html new file mode 100644 index 0000000000..2ccefc2f48 --- /dev/null +++ b/layout/style/test/test_non_content_accessible_pseudos.html @@ -0,0 +1,69 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style id="sheet"></style> +<script> +// Even though some of these no longer exist, we still do want to test that +// they aren't exposed to the web. +const NON_CONTENT_ACCESIBLE_PSEUDOS = [ + "::-moz-complex-control-wrapper", + "::-moz-number-wrapper", + "::-moz-number-text", + "::-moz-number-spin-up", + "::-moz-number-spin-down", + "::-moz-number-spin-box", + "::-moz-search-clear-button", + + ":-moz-native-anonymous", + ":-moz-use-shadow-tree-root", + ":-moz-table-border-nonzero", + ":-moz-browser-frame", + ":-moz-devtools-highlighted", + ":-moz-styleeditor-transitioning", + ":-moz-handler-clicktoplay", + ":-moz-handler-vulnerable-updatable", + ":-moz-handler-vulnerable-no-update", + ":-moz-handler-disabled", + ":-moz-handler-blocked", + ":-moz-handler-chrased", + ":-moz-has-dir-attr", + ":-moz-dir-attr-ltr", + ":-moz-dir-attr-rtl", + ":-moz-dir-attr-like-auto", + ":-moz-autofill-preview", + ":-moz-lwtheme", + ":-moz-locale-dir(rtl)", + ":-moz-locale-dir(ltr)", + + "::-moz-tree-row", + "::-moz-tree-row(foo)", +]; + +test(function() { + sheet.textContent = `div { color: initial }`; + assert_equals(sheet.sheet.cssRules.length, 1); +}, "sanity"); + +for (const pseudo of NON_CONTENT_ACCESIBLE_PSEUDOS) { + test(function() { + sheet.textContent = `${pseudo} { color: blue; }`; + assert_equals(sheet.sheet.cssRules.length, 0, + pseudo + " shouldn't be accessible to content"); + if (pseudo.indexOf("::") === 0) { + let pseudoStyle; + try { + pseudoStyle = getComputedStyle(document.documentElement, pseudo); + } catch (ex) { + // We can hit this when layout.css.computed-style.throw-on-invalid-pseudo is true + assert_true(true, `${pseudo} shouldn't be visible to content`); + return; + } + let elementStyle = getComputedStyle(document.documentElement); + for (prop of pseudoStyle) { + assert_equals(pseudoStyle[prop], elementStyle[prop], + pseudo + " styles shouldn't be visible from getComputedStyle"); + } + } + }, pseudo); +} +</script> |