Bug 1429713 part 2 - Add basic tests for the layout.css.webkit-appearance.enabled pref. r=emilio

This commit is contained in:
Jonathan Watt 2018-05-25 15:52:25 -07:00
parent 367565f0a2
commit db894ff24e
2 changed files with 68 additions and 0 deletions

View File

@ -359,6 +359,7 @@ skip-if = toolkit == 'android' # TIMED_OUT for android
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]

View File

@ -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>