4 <script src="../../../resources/js-test.js"></script>
5 <script src="../resources/helper.js"></script>
7 .notVisible { visibility: hidden; }
8 .flow { -webkit-flow-into: flow; }
9 #article { width: 50px; height: 50px; background-color: green; }
10 #region { -webkit-flow-from: flow; }
14 <div id="eventCount"></div>
15 <div id="article"></div>
16 <div id="region"></div>
18 description("Test for WebKitBug 102101 [CSS Regions] regionlayoutupdate event fires continuously");
20 if (window.testRunner) {
21 window.testRunner.dumpAsText();
22 window.testRunner.waitUntilDone();
25 window.jsTestIsAsync = true;
27 var eventDispatchCount = 0;
30 function flowThreadUpdated(event) {
31 if (++eventDispatchCount > 1) {
36 // Updating the content of eventCount element should not trigger a layout
37 // on the auto-height region.
38 document.getElementById("eventCount").textContent = eventDispatchCount;
41 function startTest() {
42 getFlowByName("flow").addEventListener("webkitregionlayoutupdate", flowThreadUpdated);
43 document.getElementById("article").className = "flow";
44 timeoutID = window.setTimeout(endTest, 500);
48 window.clearTimeout(timeoutID);
49 getFlowByName("flow").removeEventListener("webkitregionlayoutupdate", flowThreadUpdated);
51 document.getElementById("eventCount").className = "notVisible";
52 document.getElementById("region").className = "notVisible";
54 if (eventDispatchCount > 1)
55 debug("FAIL The regionlayoutupdate event fired twice instead of once.")
57 debug("PASS The regionlayoutupdate fired only once.");
61 window.addEventListener("load", startTest);