1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/test/test_plugin_position.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?> 1.6 +<html xmlns="http://www.w3.org/1999/xhtml" title="Test Plugin Positioning"> 1.7 +<head> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 +</head> 1.10 +<body> 1.11 + 1.12 +<!-- Use a XUL element here so we can get its boxObject.screenX/Y --> 1.13 +<hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1" 1.14 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.15 + <hbox style="width:100px;"></hbox><hbox id="h2"/> 1.16 +</hbox> 1.17 + 1.18 +<embed id="p" type="application/x-test" width="200" height="200" wmode="window"></embed> 1.19 +<embed id="p2" type="application/x-test" wmode="window" 1.20 + style="outline:5px solid blue; width:200px; height:200px; 1.21 + border:solid black; border-width:4px 8px 4px 8px; 1.22 + padding:3px 1px;"> 1.23 +</embed> 1.24 + 1.25 +<script class="testbody" type="application/javascript"> 1.26 +<![CDATA[ 1.27 + 1.28 +var windowFrameX, windowFrameY; 1.29 + 1.30 +function checkGeometry(id, x, y, w, h) { 1.31 + var p = document.getElementById(id); 1.32 + var bounds = p.getBoundingClientRect(); 1.33 + var pX = p.getEdge(0); 1.34 + var pY = p.getEdge(1); 1.35 + var pWidth = p.getEdge(2) - pX; 1.36 + var pHeight = p.getEdge(3) - pY; 1.37 + 1.38 + is(pX, windowFrameX + bounds.left + x, id + " plugin X"); 1.39 + is(pY, windowFrameY + bounds.top + y, id + " plugin Y"); 1.40 + is(pWidth, w, id + " plugin width"); 1.41 + is(pHeight, h, id + " plugin height"); 1.42 +} 1.43 + 1.44 +function runTests() { 1.45 + var h1 = document.getElementById("h1"); 1.46 + var h2 = document.getElementById("h2"); 1.47 + var hwidth = h2.boxObject.screenX - h1.boxObject.screenX; 1.48 + if (hwidth != 100) { 1.49 + // Maybe it's a DPI issue 1.50 + todo(false, "Unexpected DPI?"); 1.51 + SimpleTest.finish(); 1.52 + return; 1.53 + } 1.54 + 1.55 + if (!document.getElementById("p").identifierToStringTest) { 1.56 + todo(false, "Test plugin not available"); 1.57 + SimpleTest.finish(); 1.58 + return; 1.59 + } 1.60 + 1.61 + var bounds = h1.getBoundingClientRect(); 1.62 + windowFrameX = h1.boxObject.screenX - bounds.left - window.screenX; 1.63 + windowFrameY = h1.boxObject.screenY - bounds.top - window.screenY; 1.64 + 1.65 + checkGeometry("p", 0, 0, 200, 200); 1.66 + // This one tests widget positioning in the presence of borders and padding 1.67 + checkGeometry("p2", 9, 7, 182, 186); 1.68 + 1.69 + SimpleTest.finish(); 1.70 +} 1.71 + 1.72 +// When load events run, painting may still be suppressed for the window. 1.73 +// While painting is suppressed, plugins are hidden so won't be positioned 1.74 +// or sized as expected. 1.75 +// So call runTests after the load event has finished, when painting will 1.76 +// be unsuppressed. 1.77 +addLoadEvent(function() { setTimeout(runTests, 1000); }); 1.78 +SimpleTest.waitForExplicitFinish(); 1.79 + 1.80 +]]> 1.81 +</script> 1.82 + 1.83 +</body> 1.84 +</html>