summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_bug1518442.html
blob: d66846a5785cbca7d447bc6207dde901ce149c42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!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() {
  var iframe = document.createElement("iframe");
  iframe.src = "about:blank";
  iframe.onload = () => frameLoaded(iframe);
  document.body.appendChild(iframe);
}

function frameLoaded(iframe) {
  let win = iframe.contentWindow;
  let doc = iframe.contentDocument;
  let element = iframe.contentDocument.documentElement;

  is(win.onformdata, undefined, "Should not have window.onformdata");
  is(doc.onformdata, undefined, "Should not have document.onformdata");
  is(element.onformdata, undefined, "Should not have document.documentElement.onformdata");

  let eventName = "formdata";
  win.testValue = "not fired";
  element.setAttribute("on" + eventName, "window.testValue = 'fired'");
  element.dispatchEvent(new Event(eventName));
  is(win.testValue, "not fired", `${eventName} should not have fired when pref disable`);

  win.testValue = "not fired";
  element.removeAttribute("on" + eventName);
  element.dispatchEvent(new Event(eventName));
  is(win.testValue, "not fired", `${eventName} should not have fired any event`);

  delete win.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>