blob: 6e22cb8f089be8bf436e78814337de9a8f8c799b [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="resources/helper.js"></script>
<style>
body { font-family: monospace; }
#region, #region2 { width: 250px; height: 50px; }
.article { -webkit-flow-into: flow; }
.article2 { -webkit-flow-into: flow2; }
.region { -webkit-flow-from: flow; }
.region2 { -webkit-flow-from: flow2; }
.noRegion { -webkit-flow-from: none; }
</style>
</head>
<body>
<div id="console"></div>
<div id="article" class="article"></div>
<div id="region" class="region"></div>
<div id="region2"></div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
description("Test for 90759: [CSSRegions] Rename NamedFlow::getRegionsByContentNode to NamedFlow::getRegionsByContent");
var namedFlow = getFlowByName("flow");
// Getting the regions for a non existant node should return null.
var pElement;
var regionList = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList");
shouldBeZero("regionList.length");
// Getting the regions for an element that was not added to the dom should return an empty list.
pElement = document.createElement("p");
var regionList2 = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList2");
shouldEvaluateTo("regionList2.length", 0);
shouldBeTrue("regionList != regionList2");
// Add the element to the dom but not in the flow. The region list should be empty.
document.body.appendChild(pElement);
var regionList3 = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList3");
shouldEvaluateTo("regionList3.length", 0);
// Add the same element to the flow. The region list should contain one region.
document.body.removeChild(pElement);
document.getElementById("article").appendChild(pElement);
var regionList4 = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList4");
shouldEvaluateTo("regionList4.length", 1);
shouldBeEqualToString("regionList4.item(0).id", "region");
// Remove the region node and get the region list. The list should be empty.
document.getElementById("region").className = "noRegion";
var regionList5 = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList5");
shouldEvaluateTo("regionList5.length", 0);
// Bring back the region and get the region list. The list should have one element.
document.getElementById("region").className = "region";
var regionList6 = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList6");
shouldEvaluateTo("regionList6.length", 1);
shouldBeEqualToString("regionList6.item(0).id", "region");
// Remove the named flow, the region list should be empty.
document.getElementById("article").className = "";
var regionList7 = namedFlow.getRegionsByContent(pElement);
shouldBeNonNull("regionList7");
shouldEvaluateTo("regionList7.length", 0);
// Move the article to another named flow, the region list should be empty.
document.getElementById("article").className = "article2";
var namedFlow2 = getFlowByName("flow2");
var regionList8 = namedFlow2.getRegionsByContent(pElement);
shouldBeNonNull("regionList8");
shouldEvaluateTo("regionList8.length", 0);
// Add a region to the second named flow, the region list should contain one element
// since the p element is a child of article that is collected by flow2.
document.getElementById("region2").className = "region2";
var regionList9 = namedFlow2.getRegionsByContent(pElement);
shouldBeNonNull("regionList9");
shouldEvaluateTo("regionList9.length", 1);
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>