Bug 459619. Add zoom support to reftest harness. r+sr=dbaron
--- a/layout/reftests/reftest-sanity/reftest.list
+++ b/layout/reftests/reftest-sanity/reftest.list
@@ -1,16 +1,19 @@
== data:text/html,<body> about:blank
== data:text/plain, about:blank
!= data:text/plain,HELLO about:blank
# these tests make sure async reftests work:
== test-async.xul test-async-ref.xul
== test-async.html test-async-ref.html
+# test that zoom works (and really zooms, not just scales)
+== test-zoom.html test-zoom-ref.html
+
# Makes sure that the file: protocol handler and HTTP server both
# choose HTML vs. XHTML processing based on the file extensions.
!= html-vs-xhtml-by-extension.html html-vs-xhtml-by-extension.xhtml
HTTP != html-vs-xhtml-by-extension.html html-vs-xhtml-by-extension.xhtml
# make sure red and green colors are not the default and are different from
# each other
!= green.html default.html
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -328,22 +328,27 @@ function DoneTests()
dump("REFTEST FINISHED: Slowest test took " + gSlowestTestTime +
"ms (" + gSlowestTestURL + ")\n");
if (gServer)
gServer.stop();
goQuitApplication();
}
-function CanvasToURL(canvas)
-{
- var ctx = whichCanvas.getContext("2d");
- return canvas.toDataURL();
+function setupZoom(contentRootElement) {
+ if (!contentRootElement.hasAttribute('reftest-zoom'))
+ return;
+ gBrowser.markupDocumentViewer.fullZoom =
+ contentRootElement.getAttribute('reftest-zoom');
}
+function resetZoom() {
+ gBrowser.markupDocumentViewer.fullZoom = 1.0;
+}
+
function OnDocumentLoad(event)
{
if (event.target != gBrowser.contentDocument)
// Ignore load events for subframes.
return;
var contentRootElement = gBrowser.contentDocument.documentElement;
@@ -378,16 +383,18 @@ function OnDocumentLoad(event)
ps.headerStrCenter = "";
ps.headerStrRight = "";
ps.footerStrLeft = "";
ps.footerStrCenter = "";
ps.footerStrRight = "";
gBrowser.docShell.contentViewer.setPageMode(true, ps);
}
+ setupZoom(contentRootElement);
+
if (shouldWait()) {
// The testcase will let us know when the test snapshot should be made.
// Register a mutation listener to know when the 'reftest-wait' class
// gets removed.
contentRootElement.addEventListener(
"DOMAttrModified",
function(event) {
if (!shouldWait()) {
@@ -436,18 +443,28 @@ function DocumentLoaded()
canvas = gCanvas1;
else
canvas = gCanvas2;
/* XXX This needs to be rgb(255,255,255) because otherwise we get
* black bars at the bottom of every test that are different size
* for the first test and the rest (scrollbar-related??) */
var win = gBrowser.contentWindow;
- canvas.getContext("2d").drawWindow(win, win.scrollX, win.scrollY,
- canvas.width, canvas.height, "rgb(255,255,255)");
+ var ctx = canvas.getContext("2d");
+ var scale = gBrowser.markupDocumentViewer.fullZoom;
+ ctx.save();
+ // drawWindow always draws one canvas pixel for each CSS pixel in the source
+ // window, so scale the drawing to show the zoom (making each canvas pixel be one
+ // device pixel instead)
+ ctx.scale(scale, scale);
+ ctx.drawWindow(win, win.scrollX, win.scrollY,
+ canvas.width, canvas.height, "rgb(255,255,255)");
+ ctx.restore();
+
+ resetZoom();
switch (gState) {
case 1:
// First document has been loaded.
// Proceed to load the second document.
StartCurrentURI(2);
break;
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -6011,17 +6011,17 @@ trap 'rm -f $CONFIG_STATUS conftest*; ex
# Protect against Makefile macro expansion.
cat > conftest.defs <<\EOF
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '`
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
echo creating $CONFIG_STATUS
rm -f $CONFIG_STATUS