layout/generic/test/test_plugin_position.xhtml

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:41d10bf864bb
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
3 <html xmlns="http://www.w3.org/1999/xhtml" title="Test Plugin Positioning">
4 <head>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 </head>
7 <body>
8
9 <!-- Use a XUL element here so we can get its boxObject.screenX/Y -->
10 <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
12 <hbox style="width:100px;"></hbox><hbox id="h2"/>
13 </hbox>
14
15 <embed id="p" type="application/x-test" width="200" height="200" wmode="window"></embed>
16 <embed id="p2" type="application/x-test" wmode="window"
17 style="outline:5px solid blue; width:200px; height:200px;
18 border:solid black; border-width:4px 8px 4px 8px;
19 padding:3px 1px;">
20 </embed>
21
22 <script class="testbody" type="application/javascript">
23 <![CDATA[
24
25 var windowFrameX, windowFrameY;
26
27 function checkGeometry(id, x, y, w, h) {
28 var p = document.getElementById(id);
29 var bounds = p.getBoundingClientRect();
30 var pX = p.getEdge(0);
31 var pY = p.getEdge(1);
32 var pWidth = p.getEdge(2) - pX;
33 var pHeight = p.getEdge(3) - pY;
34
35 is(pX, windowFrameX + bounds.left + x, id + " plugin X");
36 is(pY, windowFrameY + bounds.top + y, id + " plugin Y");
37 is(pWidth, w, id + " plugin width");
38 is(pHeight, h, id + " plugin height");
39 }
40
41 function runTests() {
42 var h1 = document.getElementById("h1");
43 var h2 = document.getElementById("h2");
44 var hwidth = h2.boxObject.screenX - h1.boxObject.screenX;
45 if (hwidth != 100) {
46 // Maybe it's a DPI issue
47 todo(false, "Unexpected DPI?");
48 SimpleTest.finish();
49 return;
50 }
51
52 if (!document.getElementById("p").identifierToStringTest) {
53 todo(false, "Test plugin not available");
54 SimpleTest.finish();
55 return;
56 }
57
58 var bounds = h1.getBoundingClientRect();
59 windowFrameX = h1.boxObject.screenX - bounds.left - window.screenX;
60 windowFrameY = h1.boxObject.screenY - bounds.top - window.screenY;
61
62 checkGeometry("p", 0, 0, 200, 200);
63 // This one tests widget positioning in the presence of borders and padding
64 checkGeometry("p2", 9, 7, 182, 186);
65
66 SimpleTest.finish();
67 }
68
69 // When load events run, painting may still be suppressed for the window.
70 // While painting is suppressed, plugins are hidden so won't be positioned
71 // or sized as expected.
72 // So call runTests after the load event has finished, when painting will
73 // be unsuppressed.
74 addLoadEvent(function() { setTimeout(runTests, 1000); });
75 SimpleTest.waitForExplicitFinish();
76
77 ]]>
78 </script>
79
80 </body>
81 </html>

mercurial