Bug 624636, part 1: Allow reftests to override viewport+displayport. r=roc

This commit is contained in:
Chris Jones 2011-02-23 11:45:09 -06:00
parent c6f01d8156
commit 176eb6eee2
6 changed files with 70 additions and 28 deletions

View File

@ -85,3 +85,7 @@ needs-focus load needs-focus.html
# Bug 632636
fails == data:text/plain,HELLO about:blank
needs-focus == data:text/plain, about:blank
# Sanity check of viewport+displayport overrides
fails-if(!browserIsRemote) == test-displayport.html test-displayport-ref.html # bug 593168
skip-if(!browserIsRemote) != test-displayport-2.html test-displayport-ref.html # bug 593168

View File

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html reftest-viewport-w="100" reftest-viewport-h="100"
reftest-displayport-w="200" reftest-displayport-h="200">
<body>
<div style="position: absolute; left:0px; top:0px;width:800px; height:1000px; background:green;"></div>
</body>
</html>

View File

@ -0,0 +1,4 @@
<!DOCTYPE HTML>
<html>
<body style="background:green;"></body>
</html>

View File

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html reftest-viewport-w="100" reftest-viewport-h="100"
reftest-displayport-w="800" reftest-displayport-h="1000">
<body>
<div style="position: absolute; left:0px; top:0px;width:800px; height:1000px; background:green;"></div>
</body>
</html>

View File

@ -231,6 +231,41 @@ function setupPrintMode() {
docShell.contentViewer.setPageMode(true, ps);
}
function setupDisplayport(contentRootElement) {
if (!contentRootElement) {
return;
}
function attrOrDefault(attr, def) {
return contentRootElement.hasAttribute(attr) ?
contentRootElement.getAttribute(attr) : def;
}
var vw = attrOrDefault("reftest-viewport-w", 0);
var vh = attrOrDefault("reftest-viewport-h", 0);
if (vw !== 0 || vh !== 0) {
LogInfo("Setting viewport to <w="+ vw +", h="+ vh +">");
windowUtils().setCSSViewport(vw, vh);
}
// XXX support displayPortX/Y when needed
var dpw = attrOrDefault("reftest-displayport-w", 0);
var dph = attrOrDefault("reftest-displayport-h", 0);
if (dpw !== 0 || dph !== 0) {
LogInfo("Setting displayport to <x=0, y=0, w="+ dpw +", h="+ dph +">");
windowUtils().setDisplayPort(0, 0, dpw, dph);
}
// XXX support resolution when needed
// XXX support viewconfig when needed
}
function resetDisplayport() {
// XXX currently the displayport configuration lives on the
// presshell and so is "reset" on nav when we get a new presshell.
}
function shouldWaitForExplicitPaintWaiters() {
return gExplicitPendingPaintCount > 0;
}
@ -470,6 +505,7 @@ function OnDocumentLoad(event)
var contentRootElement = currentDoc ? currentDoc.documentElement : null;
setupZoom(contentRootElement);
setupDisplayport(contentRootElement);
var inPrintMode = false;
function AfterOnLoadScripts() {
@ -517,28 +553,6 @@ function OnDocumentLoad(event)
}
}
function UpdateCurrentCanvasForEvent(event)
{
if (!gCurrentCanvas)
return;
var ctx = gCurrentCanvas.getContext("2d");
var rectList = event.clientRects;
for (var i = 0; i < rectList.length; ++i) {
var r = rectList[i];
// Set left/top/right/bottom to pixel boundaries
var left = Math.floor(r.left);
var top = Math.floor(r.top);
var right = Math.ceil(r.right);
var bottom = Math.ceil(r.bottom);
ctx.save();
ctx.translate(left, top);
DoDrawWindow(ctx, left, top, right - left, bottom - top);
ctx.restore();
}
}
function RecordResult()
{
LogInfo("RecordResult fired");
@ -665,8 +679,8 @@ function RegisterMessageListeners()
function (m) { RecvLoadTest(m.json.type, m.json.uri, m.json.timeout); }
);
addMessageListener(
"reftest:ResetZoom",
function (m) { RecvResetZoom(); }
"reftest:ResetRenderingState",
function (m) { RecvResetRenderingState(); }
);
}
@ -686,9 +700,10 @@ function RecvLoadScriptTest(uri, timeout)
StartTestURI(TYPE_SCRIPT, uri, timeout);
}
function RecvResetZoom()
function RecvResetRenderingState()
{
resetZoom();
resetDisplayport();
}
function SendAssertionCount(numAssertions)

View File

@ -1124,7 +1124,7 @@ function RecordResult(testRunTime, errorMsg, scriptResults)
}
gCurrentCanvas = null;
SendResetZoom();
ResetRenderingState();
switch (gState) {
case 1:
@ -1262,6 +1262,11 @@ function DoAssertionCheck(numAsserts)
StartCurrentTest();
}
function ResetRenderingState()
{
SendResetRenderingState();
// We would want to clear any viewconfig here, if we add support for it
}
function RegisterMessageListenersAndLoadContentScript()
{
@ -1379,7 +1384,7 @@ function SendLoadTest(type, uri, timeout)
);
}
function SendResetZoom()
function SendResetRenderingState()
{
gBrowserMessageManager.sendAsyncMessage("reftest:ResetZoom");
gBrowserMessageManager.sendAsyncMessage("reftest:ResetRenderingState");
}