blob: 665ae9d804a2e8eca3539b6570055c5e58577e3e [file] [log] [blame]
<html>
<head>
<title>Test that the plugin unavailability indicator accurately knows if it's clipped.</title>
<script>
if (window.testRunner) {
testRunner.setBlockAllPlugins(true);
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
function log(text) {
logElement.appendChild(document.createTextNode(text));
logElement.appendChild(document.createElement("br"));
}
function testObscuredPlugins(className, expectedObscured) {
var failedAnyTest = false;
var expectedObscuredPlugins = document.getElementsByClassName(className);
for (var i = 0; i < expectedObscuredPlugins.length; i++) {
var plugin = expectedObscuredPlugins[i];
var pluginName = plugin.id;
if (plugin.tagName == "IFRAME")
plugin = plugin.contentDocument.getElementById("testPlugin");
var obscured = internals.isPluginUnavailabilityIndicatorObscured(plugin);
var passed = expectedObscured == obscured;
if (!passed)
failedAnyTest = true;
log("'" + pluginName + "' was obscured: " + obscured + " (expected " + expectedObscured + "; " + (passed ? "PASS" : "FAIL") + ")");
};
return failedAnyTest;
}
window.onload = function () {
logElement = document.getElementById("log");
if (!window.internals)
return;
setTimeout(function () {
log("Expected to be obscured:");
var failedAnyExpectedObscuredTest = testObscuredPlugins("shouldBeObscured", true);
log("")
log("Expected to not be obscured:");
var failedAnyExpectedVisibleTest = testObscuredPlugins("shouldNotBeObscured", false);
log("");
log("Passed all tests: " + !(failedAnyExpectedVisibleTest || failedAnyExpectedObscuredTest));
// Remove the plugins so that we don't have tons of whitespace in the output.
while(document.body.firstChild && document.body.firstChild.id != "log") {
document.body.removeChild(document.body.firstChild);
}
if (window.testRunner)
testRunner.notifyDone();
}, 0);
}
</script>
<style>
embed {
display: block;
width: 500px;
height: 500px;
}
.cover {
background-color: green;
width: 100%;
height: 100%;
position: absolute;
top: 0;
}
.container {
width: 500px;
height: 500px;
position: relative;
}
</style>
<body>
<embed id="large" class="shouldNotBeObscured" type="application/x-webkit-test-netscape"></embed>
<embed id="tooSmall" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="width: 10px; height: 10px;"></embed>
<embed id="emptyRect" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="width: 0; height: 0;"></embed>
<!-- Obscured by opacity -->
<embed id="lowOpacity" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="opacity: 0.05;"></embed>
<div style="opacity: 0.05;">
<embed id="lowOpacityParent" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
<div style="opacity: 0.2;">
<div style="opacity: 0.2;">
<embed id="stackedLowOpacityParents" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
</div>
<div style="opacity: 0.9;">
<div style="opacity: 0.9;">
<embed id="stackedHighOpacityParents" class="shouldNotBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
</div>
<!-- Clipped by overflow -->
<div style="width: 20px; overflow: hidden;">
<embed id="clippedByParent" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
<div style="width: 20px; overflow: visible;">
<embed id="notClippedByParent" class="shouldNotBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
<!-- Hidden -->
<embed id="visibilityHidden" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="visibility: hidden;"></embed>
<div style="visibility: hidden;">
<embed id="visibilityHiddenOnParent" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
<!-- Clicks blocked via pointer-events: none -->
<embed id="pointerEventsBlocked" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="pointer-events: none;"></embed>
<div style="pointer-events: none;">
<embed id="pointerEventsBlockedOnParent" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
<div class="container">
<embed id="pointerEventsBlockedOnObscuringSibling" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="pointer-events: none;"></div>
</div>
<!-- Obscured by siblings -->
<div class="container">
<embed id="leftHalfObscured" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="width: 50%;"></div>
</div>
<div class="container">
<embed id="rightHalfObscured" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="width: 50%; left: 50%;"></div>
</div>
<div class="container">
<embed id="topHalfObscured" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="height: 50%;"></div>
</div>
<div class="container">
<embed id="bottomHalfObscured" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="height: 50%; top: 50%;"></div>
</div>
<div class="container">
<embed id="topQuarterObscured" class="shouldNotBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="height: 25%;"></div>
</div>
<div class="container">
<embed id="bottomQuarterObscured" class="shouldNotBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="height: 25%; top: 75%;"></div>
</div>
<div class="container">
<embed id="centerObscured" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
<div class="cover" style="width: 20%; height: 20%; top: 40%; left: 40%;"></div>
</div>
<!-- Obscured by scroll clipping -->
<embed id="offScreenTopLeft" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="position: absolute; top: -1000px; left: -1000px;"></embed>
<embed id="offScreenTop" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="position: absolute; top: -1000px; left: 0;"></embed>
<embed id="offScreenLeft" class="shouldBeObscured" type="application/x-webkit-test-netscape" style="position: absolute; top: 0; left: -1000px;"></embed>
<!-- Obscured by overflow clipping -->
<div style="overflow: scroll; width: 100px; height: 100px;">
<embed id="overflowScrollObscured" class="shouldBeObscured" type="application/x-webkit-test-netscape"></embed>
</div>
<!-- Obscured by iframe clipping -->
<iframe id="smallIFrame" src="resources/plugin-page.html" style="width: 100px; height: 100px;" class="shouldBeObscured"></iframe>
<iframe id="largeIFrame" src="resources/plugin-page.html" style="width: 500px; height: 500px;" class="shouldNotBeObscured"></iframe>
<div id="log"></div>
</body>
</html>