2009-04-06 04:04:02 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" title="Test Plugin Positioning">
|
|
|
|
<head>
|
2019-04-16 06:50:44 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2009-04-06 04:04:02 +04:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
2019-02-15 23:26:17 +03:00
|
|
|
<!-- Use a XUL element here so we can get its screenX/Y -->
|
2009-04-06 04:04:02 +04:00
|
|
|
<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<hbox style="width:100px;"></hbox><hbox id="h2"/>
|
|
|
|
</hbox>
|
|
|
|
|
|
|
|
<embed id="p" type="application/x-test" width="200" height="200" wmode="window"></embed>
|
2009-09-11 05:44:20 +04:00
|
|
|
<embed id="p2" type="application/x-test" wmode="window"
|
|
|
|
style="outline:5px solid blue; width:200px; height:200px;
|
|
|
|
border:solid black; border-width:4px 8px 4px 8px;
|
|
|
|
padding:3px 1px;">
|
|
|
|
</embed>
|
2009-04-06 04:04:02 +04:00
|
|
|
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
var windowFrameX, windowFrameY;
|
|
|
|
|
2009-09-11 05:44:20 +04:00
|
|
|
function checkGeometry(id, x, y, w, h) {
|
2009-04-06 04:04:02 +04:00
|
|
|
var p = document.getElementById(id);
|
2009-07-04 13:47:15 +04:00
|
|
|
var bounds = p.getBoundingClientRect();
|
2009-04-06 04:04:02 +04:00
|
|
|
var pX = p.getEdge(0);
|
|
|
|
var pY = p.getEdge(1);
|
|
|
|
var pWidth = p.getEdge(2) - pX;
|
|
|
|
var pHeight = p.getEdge(3) - pY;
|
|
|
|
|
2009-09-11 05:44:20 +04:00
|
|
|
is(pX, windowFrameX + bounds.left + x, id + " plugin X");
|
|
|
|
is(pY, windowFrameY + bounds.top + y, id + " plugin Y");
|
|
|
|
is(pWidth, w, id + " plugin width");
|
|
|
|
is(pHeight, h, id + " plugin height");
|
2009-04-06 04:04:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function runTests() {
|
|
|
|
var h1 = document.getElementById("h1");
|
|
|
|
var h2 = document.getElementById("h2");
|
2019-02-15 23:26:17 +03:00
|
|
|
var hwidth = h2.screenX - h1.screenX;
|
2009-04-06 04:04:02 +04:00
|
|
|
if (hwidth != 100) {
|
|
|
|
// Maybe it's a DPI issue
|
|
|
|
todo(false, "Unexpected DPI?");
|
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!document.getElementById("p").identifierToStringTest) {
|
|
|
|
todo(false, "Test plugin not available");
|
|
|
|
SimpleTest.finish();
|
|
|
|
return;
|
|
|
|
}
|
2009-07-04 13:47:15 +04:00
|
|
|
|
2009-04-06 04:04:02 +04:00
|
|
|
var bounds = h1.getBoundingClientRect();
|
2019-02-15 23:26:17 +03:00
|
|
|
windowFrameX = h1.screenX - bounds.left - window.screenX;
|
|
|
|
windowFrameY = h1.screenY - bounds.top - window.screenY;
|
2009-04-06 04:04:02 +04:00
|
|
|
|
2009-09-11 05:44:20 +04:00
|
|
|
checkGeometry("p", 0, 0, 200, 200);
|
|
|
|
// This one tests widget positioning in the presence of borders and padding
|
|
|
|
checkGeometry("p2", 9, 7, 182, 186);
|
2009-04-06 04:04:02 +04:00
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2009-07-04 13:47:15 +04:00
|
|
|
// When load events run, painting may still be suppressed for the window.
|
|
|
|
// While painting is suppressed, plugins are hidden so won't be positioned
|
|
|
|
// or sized as expected.
|
|
|
|
// So call runTests after the load event has finished, when painting will
|
|
|
|
// be unsuppressed.
|
2010-01-19 23:25:18 +03:00
|
|
|
addLoadEvent(function() { setTimeout(runTests, 1000); });
|
2009-04-06 04:04:02 +04:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2014-12-11 21:34:40 +03:00
|
|
|
SimpleTest.requestFlakyTimeout("untriaged");
|
2009-04-06 04:04:02 +04:00
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|