summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/regions/webkit-named-flow-event-remove-from-flow.html
blob: 6450d1ecdd813fda6e2796abd68d303ffd0620eb (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
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="resources/helper.js"></script>
<style>
#article {
    -webkit-flow-into: article;
    border: 2px solid black;
}
#region_1, #region_2{
    -webkit-flow-from: no_article;
    overflow:hidden;
    display:inline-block;
    vertical-align:top;
    margin:10px;
}
.block {
   display:block;
}
#region_1, #region_2 { height:110px; width:200px; margin: 5px; border: 1px solid red;}
</style>
</head>
<body>
<div id="description" class="block"></div>
<div id="article">
    <div>
        <div id="content" style="height: 200px; background-color: green;"></div>
    </div>
</div>

<div id="region_1"></div>
<div id="region_2"></div>

<div id="console" class="block"></div>

<script>
    description("Tests regionOversetChange event")
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }
    
    window.jsTestIsAsync = true;
    function flowContent(flowName) {
        var r = document.getElementById("region_1");
        r.style.webkitFlowFrom = flowName;
        r = document.getElementById("region_2");
        r.style.webkitFlowFrom = flowName;
    }

    var eventCount = 0;
    function finishTest() {
        shouldBe("eventCount", "2");
        finishJSTest();
    }

    function regionOversetChanged(event) {
        shouldBeEqualToString("event.target.name", "article");
        if (++eventCount > 1) {
            // this should be reached after region_2 is removed from DOM
           setTimeout("finishTest()", 200);
           return;
        }
        
        var r2 = document.getElementById("region_2");
        debug("Removing region_2 from flow");
        r2.style.webkitFlowFrom = "none"; // this will trigger a new round of events due to layout
    }
    
    function startTest() {
        var flow = getFlowByName("article");
        flow.addEventListener("webkitregionoversetchange", regionOversetChanged);
        
        debug("Flow content");
        flowContent("article");
    }
    window.addEventListener("load", startTest);
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>