Bug 1429713 part 2 - Add basic tests for the layout.css.webkit-appearance.enabled pref. r=emilio
authorJonathan Watt <jwatt@jwatt.org>
Fri, 25 May 2018 15:52:25 -0700
changeset 477004 395339b3bbfce79ca9dbf22eb9c9561f6087ff7a
parent 477003 7c6f05265942d6f1484906a902085439a53d22ba
child 477005 d9ad37d3b0b24e5b343dbc41781808655f0c0a80
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1429713
milestone62.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 1429713 part 2 - Add basic tests for the layout.css.webkit-appearance.enabled pref. r=emilio
layout/style/test/mochitest.ini
layout/style/test/test_webkit_appearance_basic.html
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -354,15 +354,16 @@ skip-if = toolkit == 'android' # TIMED_O
 [test_visited_image_loading_empty.html]
 skip-if = toolkit == 'android' # TIMED_OUT for android
 [test_visited_lying.html]
 skip-if = toolkit == 'android' # TIMED_OUT for android
 [test_visited_pref.html]
 skip-if = toolkit == 'android' # TIMED_OUT for android
 [test_visited_reftests.html]
 skip-if = toolkit == 'android' # TIMED_OUT for android
+[test_webkit_appearance_basic.html]
 [test_webkit_device_pixel_ratio.html]
 [test_webkit_flex_display.html]
 [test_first_letter_restrictions.html]
 [test_first_line_restrictions.html]
 [test_placeholder_restrictions.html]
 [test_mql_event_listener_leaks.html]
 [test_non_matching_sheet_media.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_webkit_appearance_basic.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1429713
+-->
+<head>
+  <title>Test pref layout.css.webkit-appearance.enabled</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1429713">Mozilla Bug 1429713</a>
+<div id="content" style="display: none">
+  <iframe id="iframe"></iframe>
+</div>
+<script type="text/javascript">
+</script>
+<pre id="test">
+<script class="testbody" type="application/javascript">
+
+function iframe_reload() {
+  return new Promise(resolve => {
+    iframe.addEventListener("load", _ => resolve());
+    iframe.contentWindow.location.reload();
+  });
+}
+
+add_task(async function runTests() {
+  // Pref changes only take affect after a page is reloaded, which is why we
+  // use an iframe here and reload it after the pref changes.
+
+  const iframe = document.getElementById("iframe");
+
+  // Test pref enabled:
+
+  await SpecialPowers.pushPrefEnv({
+    "set": [["layout.css.webkit-appearance.enabled", true]],
+  });
+
+  await iframe_reload();
+
+  let win = iframe.contentWindow;
+  let testElem = win.document.body;
+  testElem.style["-webkit-appearance"] = "none";
+  is(window.getComputedStyle(testElem)["-webkit-appearance"], "none",
+     "Pref should enable -webkit-appearance support");
+
+  // Test pref disabled:
+
+  await SpecialPowers.pushPrefEnv({
+    "set": [["layout.css.webkit-appearance.enabled", false]],
+  });
+
+  await iframe_reload();
+
+  win = iframe.contentWindow;
+  testElem = win.document.body;
+  testElem.style["-webkit-appearance"] = "none";
+  is(window.getComputedStyle(testElem)["-webkit-appearance"], undefined,
+     "Pref should disable -webkit-appearance support");
+});
+
+</script>
+</pre>
+</body>
+</html>