summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/collections/HTMLCollection-as-prototype.html
blob: d572d35c041496904901a9eb900e84f2f5b63704 (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
<!doctype html>
<meta charset=utf-8>
<title>Objects whose prototype is an HTMLCollection</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
  var obj = Object.create(document.getElementsByTagName("script"));
  assert_throws_js(TypeError, function() {
    obj.length;
  });
}, "HTMLCollection as a prototype should not allow getting .length on the base object")

test(function() {
  var element = document.createElement("p");
  element.id = "named";
  document.body.appendChild(element);
  this.add_cleanup(function() { element.remove() });

  var collection = document.getElementsByTagName("p");
  assert_equals(collection.named, element);
  var object = Object.create(collection);
  assert_equals(object.named, element);
  object.named = "foo";
  assert_equals(object.named, "foo");
  assert_equals(collection.named, element);
}, "HTMLCollection as a prototype and setting own properties")
</script>