Bug 1403077 - Part 3: Add tests for the stylo blocklist mechanism. r=heycam, a=ritu
authorJeremy Chen <jeremychen@mozilla.com>
Wed, 11 Oct 2017 20:57:00 -0400
changeset 432433 f4ba99b411837e4b16b134cbab5bcc355ddd6b22
parent 432432 1059f19c81364d89cbdfedcacf50e06998d87e7d
child 432434 8eb20bcd4198231facd775b7e0f7d1c8026eb549
push id7953
push userryanvm@gmail.com
push dateThu, 12 Oct 2017 14:05:58 +0000
treeherdermozilla-beta@f4ba99b41183 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, ritu
bugs1403077
milestone57.0
Bug 1403077 - Part 3: Add tests for the stylo blocklist mechanism. r=heycam, a=ritu In this patch, we add 3 tests: 1. test for blocked domain 2. test for blocked sub-domain 3. test for non-blocked domain MozReview-Commit-ID: 54DDxE77Yif
build/pgo/server-locations.txt
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
@@ -280,8 +280,12 @@ https://sha256ee.example.com:443        
 # Hosts for ssl3/rc4 console warning tests
 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
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -286,16 +286,25 @@ 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]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/stylo_blocked_domain_page.html
@@ -0,0 +1,13 @@
+<!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>
new file mode 100644
--- /dev/null
+++ b/layout/style/test/stylo_non_blocked_domain_page.html
@@ -0,0 +1,13 @@
+<!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>
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_stylo_blocklist-01.html
@@ -0,0 +1,24 @@
+<!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>
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_stylo_blocklist-02.html
@@ -0,0 +1,24 @@
+<!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>
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_stylo_blocklist-03.html
@@ -0,0 +1,25 @@
+<!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>