summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug895974.html
blob: 25499d5a2c1f7f25338141d67d29ee6f0f68696d (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
62
63
64
65
66
67
68
69
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=895974
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 895974</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">

  /** Test for Bug 895974 **/
  SimpleTest.waitForExplicitFinish();

  addLoadEvent(function() {
  var frag = document.createDocumentFragment();
  var span = document.createElement("span");
  var div = document.createElement("div");
  var text = document.createTextNode("help");
  frag.appendChild(document.createTextNode("fail"));
  frag.appendChild(span);
  frag.appendChild(text);
  frag.appendChild(div);
  frag.appendChild(document.createTextNode("fail"));

  is(text.nextElementSibling, div, "nextElementSibling should work on text");
  is(text.previousElementSibling, span,
    "previousElementSibling should work on text");

  is(document.firstElementChild, document.documentElement,
     "firstElementChild should work on document");
  is(document.lastElementChild, document.documentElement,
     "lastElementChild should work on document");
  is(document.children.length, 1, "Document has one element kid");
  is(document.children[0], document.documentElement,
     "Document only element child is <html>");

  is(frag.firstElementChild, span,
     "firstElementChild should work on document fragment");
  is(frag.lastElementChild, div,
     "lastElementChild should work on document fragment");
  is(frag.children.length, 2, "Document fragment has two element kids");
  is(frag.children[0], span, "Document fragment first element child is span");
  is(frag.children[1], div, "Document fragment second element child is div");

  is(document.documentElement.firstElementChild, document.head,
     "firstElementChild should work on element");
  is(document.documentElement.lastElementChild, document.body,
     "lastElementChild should work on element");
  is(document.documentElement.children.length, 2, "<html> has two element kids");
  is(document.documentElement.children[0], document.head,
     "<html> first element child is head");
  is(document.documentElement.children[1], document.body,
     "<html>  second element child is body");
  SimpleTest.finish();
  });
  </script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=895974">Mozilla Bug 895974</a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
</pre>
</body>
</html>