summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/custom/lifecycle-created-createElement-reentrancy.html
blob: fd3ca08b630cce87f171b2f3549f1d5c83c78819 (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
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script>
description("This test ensures that the lifecycle callback of a parser-made element is visible in following script block.")

window.callbacksCalled = [];

function fooCreatedFunction() {
  shouldBe("window.callbacksCalled", "[]");
  window.callbacksCalled.push(this.tagName);
  this.innerHTML = "<x-bar></x-bar>";
  shouldBe("window.callbacksCalled", "['X-FOO', 'X-BAR']");
}

function barCreatedFunction() {
  shouldBe("window.callbacksCalled", "['X-FOO']");
  window.callbacksCalled.push(this.tagName);
}

document.register("x-foo", { prototype: Object.create(HTMLElement.prototype, { createdCallback: { value: fooCreatedFunction } }) });
document.register("x-bar", { prototype: Object.create(HTMLElement.prototype, { createdCallback: { value: barCreatedFunction } }) });
</script>
</head>
<body>
<script>
document.createElement("x-foo");
shouldBe("window.callbacksCalled", "['X-FOO', 'X-BAR']");
</script>
</body>
</html>