summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/debugger/custom-element-lifecycle-events.html
blob: 71dddc393b1233146fd36a6475d219e00d74fc37 (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
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>

function test() {
    var setup = [
        "var proto = Object.create(HTMLElement.prototype);",
        "proto.createdCallback = function() { output('Invoked createdCallback.'); };",
        "proto.attachedCallback = function() { output('Invoked attachedCallback.'); };",
        "proto.detachedCallback = function() { output('Invoked detachedCallback.'); };",
        "proto.attributeChangedCallback = function() { output('Invoked attributeChangedCallback.'); };",
        "CustomElement = document.registerElement('x-foo', {prototype: proto});",
    ].join('\n');

    var lifecycleCallbacks = [
        "created = new CustomElement();",
        "created.setAttribute('x', '1');",
        "document.body.appendChild(created);",
        "created.remove();",
    ].join('\n');

    InspectorTest.startDebuggerTest(step1);

    function step1() {
        InspectorTest.evaluateInConsole(setup, function() {
            InspectorTest.addResult("Custom element registered.");
            InspectorTest.evaluateInConsoleAndDump("new CustomElement() instanceof CustomElement", step2);
        });
    }

    function step2() {
        InspectorTest.evaluateInConsole('debugger;');
        InspectorTest.waitUntilPaused(step3);
    }

    function step3() {
        InspectorTest.evaluateInConsoleAndDump("new CustomElement() instanceof CustomElement", step4);
    }

    function step4() {
        InspectorTest.evaluateInConsole(lifecycleCallbacks, InspectorTest.completeDebuggerTest);
    }
}

</script>
</head>

<body onload="runTest()">
<p>
Tests that custom element lifecycle events fire while debugger is paused.
</p>

</body>
</html>