summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_bug1127588.html
blob: 7d00a68eeedf25a2e5c4096836a05c7d3b7fee7c (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
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1127588
-->
<head>
  <script src="/tests/SimpleTest/SimpleTest.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=1127588">Mozilla Bug 1127588</a>
<p id="display"></p>
<div id="content" style="display: none">
<script type="application/javascript">

/** Test for Bug 1127588 **/

SimpleTest.waitForExplicitFinish();

window.onload = function () {
  let insertedEventCount = 0;
  let insertedListener = function() {
    insertedEventCount++;
  };

  let removedEventCount = 0;
  let removedListener = function() {
    removedEventCount++;
  };

  // Tests for no title element.
  document.addEventListener('DOMNodeRemoved', removedListener);
  document.addEventListener('DOMNodeInserted', insertedListener);
  document.title = "Test for Bug 1127588";
  document.removeEventListener('DOMNodeInserted', insertedListener);
  document.removeEventListener('DOMNodeRemoved', removedListener);

  // Check result.
  is(insertedEventCount, 2, "Should get 'DOMNodeInserted' mutation event");
  is(removedEventCount, 0, "Should not get 'DOMNodeRemoved' mutation event");

  // Test for updating title element.
  insertedEventCount = 0;
  removedEventCount = 0;
  document.addEventListener('DOMNodeRemoved', removedListener);
  document.addEventListener('DOMNodeInserted', insertedListener);
  document.title = document.title;
  document.removeEventListener('DOMNodeInserted', insertedListener);
  document.removeEventListener('DOMNodeRemoved', removedListener);

  // Check result.
  is(insertedEventCount, 1, "Should get 'DOMNodeInserted' mutation event");
  is(removedEventCount, 1, "Should get 'DOMNodeRemoved' mutation event");

  SimpleTest.finish();
};

</script>
</body>
</html>