Bug 1518442 - Part 5: Add a mochitest for pref-off form data event attribute; r=smaug,edgar

Differential Revision: https://phabricator.services.mozilla.com/D44871

--HG--
extra : moz-landing-system : lando
This commit is contained in:
John Dai 2019-09-09 13:53:38 +00:00
Родитель d53a464a30
Коммит eded859488
2 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -24,6 +24,7 @@ support-files =
[test_accel_virtual_modifier.html]
[test_addEventListenerExtraArg.html]
[test_all_synthetic_events.html]
[test_bug1518442.html]
[test_bug1539497.html]
[test_bug226361.xhtml]
[test_bug238987.html]

Просмотреть файл

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1518442</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
function runTest() {
try {
let eventName = "formdata";
window.testValue = "not fired";
document.documentElement.setAttribute("on" + eventName, "window.testValue = 'fired'");
document.documentElement.dispatchEvent(new Event(eventName));
is(window.testValue, "not fired", `${eventName} should not have fired when pref disable`);
window.testValue = "not fired";
document.documentElement.removeAttribute("on" + eventName);
document.documentElement.dispatchEvent(new Event(eventName));
is(window.testValue, "not fired", `${eventName} should not have fired any event`);
is(window.onformdata, null, "Should not have window.onformdata");
is(document.onformdata, null, "Should not have document.onformdata");
is(document.documentElement.onformdata, null, "Should not have document.documentElement.onformdata");
} finally {
delete window.testValue;
SimpleTest.finish();
}
};
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.formdata.event.enabled", false]]}, runTest);
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>