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