summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/Node-contains.html
blob: a3d6448664f00e455cb3fbbc32ff2a39df60cdfd (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
<!doctype html>
<title>Node.contains() tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../common.js></script>
<script>
"use strict";

testNodes.forEach(function(referenceName) {
  var reference = eval(referenceName);

  test(function() {
    assert_false(reference.contains(null));
  }, referenceName + ".contains(null)");

  testNodes.forEach(function(otherName) {
    var other = eval(otherName);
    test(function() {
      var ancestor = other;
      while (ancestor && ancestor !== reference) {
        ancestor = ancestor.parentNode;
      }
      if (ancestor === reference) {
        assert_true(reference.contains(other));
      } else {
        assert_false(reference.contains(other));
      }
    }, referenceName + ".compareDocumentPosition(" + otherName + ")");
  });
});

testDiv.parentNode.removeChild(testDiv);
</script>
<!-- vim: set expandtab tabstop=2 shiftwidth=2: -->