Bug 1433439 - Don't expose non-content-accessible pseudo-elements from getComputedStyle. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Nov 2018 02:35:23 +0000
changeset 502978 ddd1c83fb4e828ac669fc180188ab0ec7ed77343
parent 502977 dfaa72cb3f7a16ea8bbedd78563157e6bef61a11
child 502979 f678d3408301ff96414b17c1cd4e20958c6034b2
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1433439
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1433439 - Don't expose non-content-accessible pseudo-elements from getComputedStyle. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D11830
layout/style/nsComputedDOMStyle.cpp
layout/style/test/test_non_content_accessible_pseudos.html
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -524,19 +524,18 @@ MustReresolveStyle(const mozilla::Comput
 }
 
 static inline CSSPseudoElementType
 GetPseudoType(nsAtom* aPseudo)
 {
   if (!aPseudo) {
     return CSSPseudoElementType::NotPseudo;
   }
-  // FIXME(emilio, bug 1433439): The eIgnoreEnabledState thing is dubious.
   return nsCSSPseudoElements::GetPseudoType(
-    aPseudo, CSSEnabledState::eIgnoreEnabledState);
+    aPseudo, CSSEnabledState::eForAllContent);
 }
 
 already_AddRefed<ComputedStyle>
 nsComputedDOMStyle::DoGetComputedStyleNoFlush(Element* aElement,
                                               nsAtom* aPseudo,
                                               nsIPresShell* aPresShell,
                                               StyleType aStyleType)
 {
--- a/layout/style/test/test_non_content_accessible_pseudos.html
+++ b/layout/style/test/test_non_content_accessible_pseudos.html
@@ -41,21 +41,19 @@ test(function() {
   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");
-    // FIXME(emilio, bug 1433439): This test should pass!
-    //
-    // if (pseudo.indexOf("::") === 0) {
-    //   let pseudoStyle = getComputedStyle(document.documentElement, pseudo);
-    //   let elementStyle = getComputedStyle(document.documentElement);
-    //   for (prop of pseudoStyle) {
-    //     assert_equals(pseudoStyle[prop], elementStyle[prop],
-    //                   pseudo + " styles shouldn't be visible from getComputedStyle");
-    //   }
-    // }
+    if (pseudo.indexOf("::") === 0) {
+      let pseudoStyle = getComputedStyle(document.documentElement, pseudo);
+      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>