Bug 1426223 - remove tests for Stylo blocklist mechanism. draft
authorJeremy Chen <jeremychen@mozilla.com>
Sat, 27 Jan 2018 18:08:15 +0800
changeset 748035 b3b4eebc02394894b95e551d94b12bf74ae488c1
parent 747859 6190b1e65676010bc61ca612b14198992aa27f5a
child 748036 cd6b3cbc75d9879d9fd82f5fc3bc963616ccab85
push id97052
push userbmo:chenpighead@gmail.com
push dateSat, 27 Jan 2018 13:49:09 +0000
bugs1426223
milestone60.0a1
Bug 1426223 - remove tests for Stylo blocklist mechanism. In this patch, we remove 3 tests: 1. test for blocked domain 2. test for blocked sub-domain 3. test for non-blocked domain Two nsIDOMWindowUtils APIs were added for adding/removing a mock domain to the existing blocklist. They are only used in the Stylo blocklist tests, so we remove them as well. MozReview-Commit-ID: A0ETWlqwbpN
build/pgo/server-locations.txt
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/style/test/mochitest.ini
layout/style/test/stylo_blocked_domain_page.html
layout/style/test/stylo_non_blocked_domain_page.html
layout/style/test/test_stylo_blocklist-01.html
layout/style/test/test_stylo_blocklist-02.html
layout/style/test/test_stylo_blocklist-03.html
--- a/build/pgo/server-locations.txt
+++ b/build/pgo/server-locations.txt
@@ -284,14 +284,10 @@ https://symantec-not-whitelisted-before-
 https://ssl3.example.com:443        privileged,ssl3
 https://rc4.example.com:443         privileged,rc4
 https://ssl3rc4.example.com:443     privileged,ssl3,rc4
 https://tls1.example.com:443        privileged,tls1
 
 # Hosts for youtube rewrite tests
 https://mochitest.youtube.com:443
 
-# Hosts for stylo blocklist tests
-http://stylo-blocklist.com:80          privileged
-http://test.stylo-blocklist.com:80     privileged
-
 # Host for U2F localhost tests
 https://localhost:443
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -4440,34 +4440,16 @@ nsDOMWindowUtils::EnsureDirtyRootFrame()
 NS_IMETHODIMP
 nsDOMWindowUtils::GetIsStyledByServo(bool* aStyledByServo)
 {
   nsIDocument* doc = GetDocument();
   *aStyledByServo = doc && doc->IsStyledByServo();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDOMWindowUtils::AddToStyloBlocklist(const nsACString& aBlockedDomain)
-{
-#ifdef MOZ_STYLO
-  nsLayoutUtils::AddToStyloBlocklist(aBlockedDomain);
-#endif
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::RemoveFromStyloBlocklist(const nsACString& aBlockedDomain)
-{
-#ifdef MOZ_STYLO
-  nsLayoutUtils::RemoveFromStyloBlocklist(aBlockedDomain);
-#endif
-  return NS_OK;
-}
-
 NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsITranslationNodeList)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsTranslationNodeList)
 NS_IMPL_RELEASE(nsTranslationNodeList)
 
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1975,30 +1975,16 @@ interface nsIDOMWindowUtils : nsISupport
 
   /**
    * Whether the current document is styled by Servo's style engine.
    *
    * This calls nsIDocument::IsStyledByServo().
    */
   readonly attribute boolean isStyledByServo;
 
-  /**
-   * Add a domain to the existing stylo blocklist.
-   *
-   * This calls nsLayoutUtils::AddToStyloBlocklist().
-   */
-  void addToStyloBlocklist(in ACString aBlockedDomain);
-
-  /**
-   * Remove a domain from the existing stylo blocklist.
-   *
-   * This calls nsLayoutUtils::RemoveFromStyloBlocklist().
-   */
-  void removeFromStyloBlocklist(in ACString aBlockedDomain);
-
   // These consts are only for testing purposes.
   const long DEFAULT_MOUSE_POINTER_ID = 0;
   const long DEFAULT_PEN_POINTER_ID   = 1;
   const long DEFAULT_TOUCH_POINTER_ID = 2;
 
   // Match WidgetMouseEventBase::buttonType.
   const long MOUSE_BUTTON_LEFT_BUTTON   = 0;
   const long MOUSE_BUTTON_MIDDLE_BUTTON = 1;
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8354,42 +8354,16 @@ nsLayoutUtils::IsInStyloBlocklist(nsIPri
     if (baseDomain.Equals(domains)) {
       return true;
     }
   }
   return false;
 }
 
 /* static */
-void
-nsLayoutUtils::AddToStyloBlocklist(const nsACString& aBlockedDomain)
-{
-  if (!sStyloBlocklist) {
-    sStyloBlocklist = new nsTArray<nsCString>;
-  }
-  sStyloBlocklist->AppendElement(aBlockedDomain);
-}
-
-/* static */
-void
-nsLayoutUtils::RemoveFromStyloBlocklist(const nsACString& aBlockedDomain)
-{
-  if (!sStyloBlocklist) {
-    return;
-  }
-
-  sStyloBlocklist->RemoveElement(aBlockedDomain);
-
-  if (sStyloBlocklist->IsEmpty()) {
-    delete sStyloBlocklist;
-    sStyloBlocklist = nullptr;
-  }
-}
-
-/* static */
 bool
 nsLayoutUtils::StyloChromeEnabled()
 {
   static bool sInitialized = false;
   static bool sEnabled = false;
   if (!sInitialized) {
     // We intentionally don't allow dynamic toggling of this pref
     // because it is rather risky to mix style backend in XUL.
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2590,30 +2590,16 @@ public:
   /**
    * Principal-based blocklist for stylo.
    * Check if aPrincipal is blocked by stylo's blocklist and should fallback to
    * use Gecko's style backend. Note that using a document's principal rather
    * than the document URI will let us piggy-back off the existing principal
    * relationships and symmetries.
    */
   static bool IsInStyloBlocklist(nsIPrincipal* aPrincipal);
-
-  /**
-   * Add aBlockedDomain to the existing stylo blocklist, i.e., sStyloBlocklist.
-   * This function is exposed to nsDOMWindowUtils and only for testing purpose.
-   * So, NEVER use this in any other cases.
-   */
-  static void AddToStyloBlocklist(const nsACString& aBlockedDomain);
-
-  /**
-   * Remove aBlockedDomain from the existing stylo blocklist, i.e., sStyloBlocklist.
-   * This function is exposed to nsDOMWindowUtils and only for testing purpose.
-   * So, NEVER use this in any other cases.
-   */
-  static void RemoveFromStyloBlocklist(const nsACString& aBlockedDomain);
 #else
   static bool ShouldUseStylo(nsIURI* aDocumentURI, nsIPrincipal* aPrincipal) {
     return false;
   }
 #endif
 
   /**
    * Register an imgIRequest object with a refresh driver.
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -299,25 +299,16 @@ skip-if = toolkit == 'android' #bug 7752
 [test_specified_value_serialization.html]
 [test_style_attr_listener.html]
 [test_style_attribute_quirks.html]
 [test_style_attribute_standards.html]
 [test_style_struct_copy_constructors.html]
 [test_stylesheet_additions.html]
 skip-if = !stylo
 [test_stylesheet_clone_font_face.html]
-[test_stylo_blocklist-01.html]
-support-files = stylo_blocked_domain_page.html
-skip-if = !stylo # no need to test blocklist for non-stylo platforms
-[test_stylo_blocklist-02.html]
-support-files = stylo_blocked_domain_page.html
-skip-if = !stylo # no need to test blocklist for non-stylo platforms
-[test_stylo_blocklist-03.html]
-support-files = stylo_non_blocked_domain_page.html
-skip-if = !stylo # no need to test blocklist for non-stylo platforms
 [test_supports_rules.html]
 [test_system_font_serialization.html]
 [test_text_decoration_shorthands.html]
 [test_transitions_and_reframes.html]
 [test_transitions_and_restyles.html]
 [test_transitions_and_zoom.html]
 [test_transitions_at_start.html]
 [test_transitions_cancel_near_end.html]
deleted file mode 100644
--- a/layout/style/test/stylo_blocked_domain_page.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<head>
-  <title>Test page with a mock domain which is listed in the stylo blocklist</title>
-</head>
-<script>
-window.onload = function() {
-  if (SpecialPowers.getDOMWindowUtils(window).isStyledByServo == false) {
-    opener.postMessage("TEST-PASS", "*");
-  } else {
-    opener.postMessage("TEST-FAIL", "*");
-  }
-}
-</script>
deleted file mode 100644
--- a/layout/style/test/stylo_non_blocked_domain_page.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<head>
-  <title>Test page with a mock domain which is NOT listed in the stylo blocklist</title>
-</head>
-<script>
-window.onload = function() {
-  if (SpecialPowers.getDOMWindowUtils(window).isStyledByServo == true) {
-    opener.postMessage("TEST-PASS", "*");
-  } else {
-    opener.postMessage("TEST-FAIL", "*");
-  }
-}
-</script>
deleted file mode 100644
--- a/layout/style/test/test_stylo_blocklist-01.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test the mechanism of stylo blocklist</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script>
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.getDOMWindowUtils(window).addToStyloBlocklist("stylo-blocklist.com");
-let win =
-  window.open("http://stylo-blocklist.com/tests/layout/style/test/stylo_blocked_domain_page.html", "");
-window.onmessage = function (evt) {
-  is(evt.data, "TEST-PASS",
-     "Document with blocked domain should not use servo backend");
-  win.close();
-  SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("stylo-blocklist.com");
-  SimpleTest.finish();
-}
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/layout/style/test/test_stylo_blocklist-02.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test the mechanism of stylo blocklist</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script>
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.getDOMWindowUtils(window).addToStyloBlocklist("stylo-blocklist.com");
-let win =
-  window.open("http://test.stylo-blocklist.com/tests/layout/style/test/stylo_blocked_domain_page.html", "");
-window.onmessage = function (evt) {
-  is(evt.data, "TEST-PASS",
-     "Document with blocked sub-domain should not use servo backend");
-  win.close();
-  SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("stylo-blocklist.com");
-  SimpleTest.finish();
-}
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/layout/style/test/test_stylo_blocklist-03.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test the mechanism of stylo blocklist</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script>
-SimpleTest.waitForExplicitFinish();
-// "http://example.com" should not be in the blocklist by any chance. Adding this
-// line is just for safety, and it also makes this test more readable.
-SpecialPowers.getDOMWindowUtils(window).removeFromStyloBlocklist("example.com");
-let win =
-  window.open("http://example.com/tests/layout/style/test/stylo_non_blocked_domain_page.html", "");
-window.onmessage = function (evt) {
-  is(evt.data, "TEST-PASS",
-     "Document without blocked domain should use servo backend");
-  win.close();
-  SimpleTest.finish();
-}
-</script>
-</pre>
-</body>
-</html>