mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-01 12:03:08 +00:00
Bug 975931. Part 4: Support reftest-async-scroll attributes. r=dbaron
--HG-- extra : rebase_source : 2f87486f71f6e670df0999e75ac96cc43123921e
This commit is contained in:
parent
280f1f2ea9
commit
52f68466db
@ -494,6 +494,14 @@ When the "reftest-async-scroll" attribute is set on the root element, *all*
|
||||
elements in the document are checked for "reftest-displayport-x/y/w/h" and have
|
||||
displayports set on them when those attributes are present.
|
||||
|
||||
Testing Async Scrolling: reftest-async-scroll-x/y="<int>"
|
||||
=========================================================
|
||||
|
||||
When the "reftest-async-scroll" attribute is set on the root element, for any
|
||||
element where either the "reftest-async-scroll-x" or "reftest-async-scroll-y
|
||||
attributes are nonzero, at the end of the test take the snapshot with the given
|
||||
offset (in CSS pixels) added to the async scroll offset.
|
||||
|
||||
Printing Tests: class="reftest-print"
|
||||
=====================================
|
||||
|
||||
|
@ -183,7 +183,7 @@ function setupPrintMode() {
|
||||
}
|
||||
|
||||
function attrOrDefault(element, attr, def) {
|
||||
return element.hasAttribute(attr) ? element.getAttribute(attr) : def;
|
||||
return element.hasAttribute(attr) ? Number(element.getAttribute(attr)) : def;
|
||||
}
|
||||
|
||||
function setupViewport(contentRootElement) {
|
||||
@ -221,10 +221,8 @@ function setupDisplayport(contentRootElement) {
|
||||
|
||||
function setupDisplayportForElementSubtree(element) {
|
||||
setupDisplayportForElement(element);
|
||||
for (var c = element.firstChild; c; c = c.nextSibling) {
|
||||
if (c.nodeType == c.ELEMENT_NODE) {
|
||||
setupDisplayportForElementSubtree(c);
|
||||
}
|
||||
for (var c = element.firstElementChild; c; c = c.nextElementSibling) {
|
||||
setupDisplayportForElementSubtree(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,6 +234,43 @@ function setupDisplayport(contentRootElement) {
|
||||
}
|
||||
}
|
||||
|
||||
function setupAsyncScrollOffsets(options) {
|
||||
var currentDoc = content.document;
|
||||
var contentRootElement = currentDoc ? currentDoc.documentElement : null;
|
||||
|
||||
if (!contentRootElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
function setupAsyncScrollOffsetsForElement(element) {
|
||||
var sx = attrOrDefault(element, "reftest-async-scroll-x", 0);
|
||||
var sy = attrOrDefault(element, "reftest-async-scroll-y", 0);
|
||||
if (sx != 0 || sy != 0) {
|
||||
try {
|
||||
// This might fail when called from RecordResult since layers
|
||||
// may not have been constructed yet
|
||||
windowUtils().setAsyncScrollOffset(element, sx, sy);
|
||||
} catch (e) {
|
||||
if (!options.allowFailure) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupAsyncScrollOffsetsForElementSubtree(element) {
|
||||
setupAsyncScrollOffsetsForElement(element);
|
||||
for (var c = element.firstElementChild; c; c = c.nextElementSibling) {
|
||||
setupAsyncScrollOffsetsForElementSubtree(c);
|
||||
}
|
||||
}
|
||||
|
||||
var asyncScroll = contentRootElement.hasAttribute("reftest-async-scroll");
|
||||
if (asyncScroll) {
|
||||
setupAsyncScrollOffsetsForElementSubtree(contentRootElement);
|
||||
}
|
||||
}
|
||||
|
||||
function resetDisplayportAndViewport() {
|
||||
// XXX currently the displayport configuration lives on the
|
||||
// presshell and so is "reset" on nav when we get a new presshell.
|
||||
@ -667,6 +702,9 @@ function RecordResult()
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup async scroll offsets now in case SynchronizeForSnapshot is not
|
||||
// called (due to reftest-no-sync-layers being supplied).
|
||||
setupAsyncScrollOffsets({allowFailure:true});
|
||||
SendTestDone(currentTestRunTime);
|
||||
FinishTestItem();
|
||||
}
|
||||
@ -747,6 +785,10 @@ function SynchronizeForSnapshot(flags)
|
||||
var ctx = dummyCanvas.getContext("2d");
|
||||
var flags = ctx.DRAWWINDOW_DRAW_CARET | ctx.DRAWWINDOW_DRAW_VIEW | ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
|
||||
ctx.drawWindow(content, 0, 0, 1, 1, "rgb(255,255,255)", flags);
|
||||
|
||||
// Setup async scroll offsets now, because any scrollable layers should
|
||||
// have had their AsyncPanZoomControllers created.
|
||||
setupAsyncScrollOffsets({allowFailure:false});
|
||||
}
|
||||
|
||||
function RegisterMessageListeners()
|
||||
|
Loading…
x
Reference in New Issue
Block a user