|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
4 type="text/css"?> |
|
5 <window title="Basic Plugin Tests" |
|
6 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
7 <script type="application/javascript" |
|
8 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
9 <script type="application/javascript" src="utils.js"></script> |
|
10 <script type="application/javascript"> |
|
11 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
|
12 </script> |
|
13 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()"> |
|
14 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed> |
|
15 </body> |
|
16 <script class="testbody" type="application/javascript"> |
|
17 <![CDATA[ |
|
18 SimpleTest.waitForExplicitFinish(); |
|
19 |
|
20 function runTests() { |
|
21 var pluginElement = document.getElementById("plugin1"); |
|
22 // Poll to see if the plugin is in the right place yet. |
|
23 // Check if x-coordinate 0 in plugin space is 0 in window space. If it is, |
|
24 // the plugin hasn't been placed yet. |
|
25 if (pluginElement.convertPointX(1, 0, 0, 2) == 0) { |
|
26 setTimeout(runTests, 0); |
|
27 return; |
|
28 } |
|
29 |
|
30 var domWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
|
31 .getInterface(Components.interfaces.nsIDOMWindowUtils); |
|
32 var devPxPerCSSPx = domWindowUtils.screenPixelsPerCSSPixel; |
|
33 |
|
34 var pluginRect = pluginElement.getBoundingClientRect(); |
|
35 var pluginX = (pluginRect.left * devPxPerCSSPx) + ((window.mozInnerScreenX * devPxPerCSSPx) - window.screenX); |
|
36 var pluginY = (pluginRect.top * devPxPerCSSPx) + ((window.mozInnerScreenY * devPxPerCSSPx) - window.screenY); |
|
37 |
|
38 var windowX = window.screenX; |
|
39 var windowY = window.screenY; |
|
40 var windowHeight = window.outerHeight; |
|
41 |
|
42 var screenHeight = window.screen.height; |
|
43 |
|
44 // arbitrary coordinates of test point in plugin top-left origin terms |
|
45 var xOffset = 5; |
|
46 var yOffset = 5; |
|
47 |
|
48 var NPCoordinateSpacePluginX = 0 + xOffset; |
|
49 var NPCoordinateSpacePluginY = 0 + yOffset; |
|
50 |
|
51 var NPCoordinateSpaceWindowX = pluginX + xOffset; |
|
52 var NPCoordinateSpaceWindowY = (windowHeight - pluginY) - yOffset; |
|
53 |
|
54 var NPCoordinateSpaceFlippedWindowX = pluginX + xOffset; |
|
55 var NPCoordinateSpaceFlippedWindowY = pluginY + yOffset; |
|
56 |
|
57 var NPCoordinateSpaceScreenX = windowX + pluginX + xOffset; |
|
58 var NPCoordinateSpaceScreenY = ((screenHeight - windowY) - pluginY) - yOffset; |
|
59 |
|
60 var NPCoordinateSpaceFlippedScreenX = windowX + pluginX + xOffset; |
|
61 var NPCoordinateSpaceFlippedScreenY = windowY + pluginY + yOffset; |
|
62 |
|
63 // these are in coordinate space enumeration order |
|
64 var xValues = new Array(NPCoordinateSpacePluginX, NPCoordinateSpaceWindowX, NPCoordinateSpaceFlippedWindowX, NPCoordinateSpaceScreenX, NPCoordinateSpaceFlippedScreenX); |
|
65 var yValues = new Array(NPCoordinateSpacePluginY, NPCoordinateSpaceWindowY, NPCoordinateSpaceFlippedWindowY, NPCoordinateSpaceScreenY, NPCoordinateSpaceFlippedScreenY); |
|
66 |
|
67 var i; |
|
68 for (i = 0; i < 5; i = i + 1) { |
|
69 var sourceCoordSpaceValue = i + 1; |
|
70 var j; |
|
71 for (j = 0; j < 5; j = j + 1) { |
|
72 var destCoordSpaceValue = j + 1; |
|
73 xResult = pluginElement.convertPointX(sourceCoordSpaceValue, xValues[i], yValues[i], destCoordSpaceValue); |
|
74 yResult = pluginElement.convertPointY(sourceCoordSpaceValue, xValues[i], yValues[i], destCoordSpaceValue); |
|
75 is(xResult, xValues[j], "convertPointX: space " + sourceCoordSpaceValue + " to space " + destCoordSpaceValue + " mismatch"); |
|
76 is(yResult, yValues[j], "convertPointY: space " + sourceCoordSpaceValue + " to space " + destCoordSpaceValue + " mismatch"); |
|
77 } |
|
78 } |
|
79 |
|
80 SimpleTest.finish(); |
|
81 } |
|
82 ]]> |
|
83 </script> |
|
84 </window> |