Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
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" type="text/css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | Tests for mozInnerScreenX/Y properties |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Test mozInnerScreenX/Y Properties" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 10 | |
michael@0 | 11 | <!-- test resuls are displayed in the html:body --> |
michael@0 | 12 | <body xmlns="http://www.w3.org/1999/xhtml" |
michael@0 | 13 | style="height: 400px; position:relative; overflow: auto;"> |
michael@0 | 14 | <iframe id="f" |
michael@0 | 15 | style="position:absolute; left:100px; |
michael@0 | 16 | top:200px; width:200px; height:200px; border:none;"></iframe> |
michael@0 | 17 | </body> |
michael@0 | 18 | |
michael@0 | 19 | <!-- test code goes here --> |
michael@0 | 20 | <script type="application/javascript"><![CDATA[ |
michael@0 | 21 | |
michael@0 | 22 | function isRounded(a, b, msg) { |
michael@0 | 23 | ok(Math.round(a) == Math.round(b), |
michael@0 | 24 | msg + " (rounded), got " + a + ", expected " + b); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function doTests() |
michael@0 | 28 | { |
michael@0 | 29 | var readable = false; |
michael@0 | 30 | try |
michael@0 | 31 | { |
michael@0 | 32 | mozScreenPixelsPerCSSPixel; |
michael@0 | 33 | readable = true; |
michael@0 | 34 | } |
michael@0 | 35 | catch(ex) { } |
michael@0 | 36 | ok(!readable, "window pixels per css pixel shouldn't be readable to content"); |
michael@0 | 37 | |
michael@0 | 38 | var domWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 39 | .getInterface(Components.interfaces.nsIDOMWindowUtils); |
michael@0 | 40 | var devPxPerCSSPx = domWindowUtils.screenPixelsPerCSSPixel; |
michael@0 | 41 | |
michael@0 | 42 | is(window.devicePixelRatio, devPxPerCSSPx, "window.devicePixelRatio"); |
michael@0 | 43 | |
michael@0 | 44 | var windowBO = document.documentElement.boxObject; |
michael@0 | 45 | isRounded(window.mozInnerScreenX*devPxPerCSSPx, windowBO.screenX, |
michael@0 | 46 | "window screen X"); |
michael@0 | 47 | isRounded(window.mozInnerScreenY*devPxPerCSSPx, windowBO.screenY, |
michael@0 | 48 | "window screen Y"); |
michael@0 | 49 | |
michael@0 | 50 | var f = document.getElementById("f"); |
michael@0 | 51 | var fBounds = f.getBoundingClientRect(); |
michael@0 | 52 | |
michael@0 | 53 | const CI = Components.interfaces; |
michael@0 | 54 | var fshell = f.contentWindow.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIWebNavigation).QueryInterface(CI.nsIDocShell); |
michael@0 | 55 | var fmudv = fshell.contentViewer.QueryInterface(CI.nsIMarkupDocumentViewer); |
michael@0 | 56 | |
michael@0 | 57 | isRounded(f.contentWindow.mozInnerScreenX, |
michael@0 | 58 | window.mozInnerScreenX + fBounds.left, |
michael@0 | 59 | "frame screen X"); |
michael@0 | 60 | isRounded(f.contentWindow.mozInnerScreenY, |
michael@0 | 61 | window.mozInnerScreenY + fBounds.top, |
michael@0 | 62 | "frame screen Y"); |
michael@0 | 63 | |
michael@0 | 64 | fmudv.fullZoom *= 2; |
michael@0 | 65 | var frameDomWindowUtils = f.contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 66 | .getInterface(Components.interfaces.nsIDOMWindowUtils); |
michael@0 | 67 | is(frameDomWindowUtils.screenPixelsPerCSSPixel, 2*devPxPerCSSPx, |
michael@0 | 68 | "frame screen pixels per CSS pixel"); |
michael@0 | 69 | |
michael@0 | 70 | is(f.contentWindow.devicePixelRatio, 2*devPxPerCSSPx, "frame devicePixelRatio"); |
michael@0 | 71 | |
michael@0 | 72 | isRounded(f.contentWindow.mozInnerScreenX*2, |
michael@0 | 73 | window.mozInnerScreenX + fBounds.left, |
michael@0 | 74 | "zoomed frame screen X"); |
michael@0 | 75 | isRounded(f.contentWindow.mozInnerScreenY*2, |
michael@0 | 76 | window.mozInnerScreenY + fBounds.top, |
michael@0 | 77 | "zoomed frame screen Y"); |
michael@0 | 78 | fmudv.fullZoom = 1.0; |
michael@0 | 79 | |
michael@0 | 80 | SimpleTest.finish(); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | addLoadEvent(doTests); |
michael@0 | 84 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 85 | |
michael@0 | 86 | ]]> |
michael@0 | 87 | </script> |
michael@0 | 88 | |
michael@0 | 89 | </window> |