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