Bug 1326189 part 3 - Make test_visited_reftests support needs-focus. r=dholbert
MozReview-Commit-ID: XCy3kVh5FN
--- a/layout/style/test/test_visited_reftests.html
+++ b/layout/style/test/test_visited_reftests.html
@@ -121,33 +121,48 @@ function passes(equal, shot1, shot2)
return correct;
}
function waitFor100ms() {
return new Promise(resolve => setTimeout(resolve, 100));
}
async function runTest(testLine) {
- var splitData = testLine.split(" ");
- let isEqual = splitData[0] == "==";
- let testFile = splitData[1];
- let refFile = splitData[2];
+ let splitData = testLine.split(" ");
+ let isEqual;
+ let needsFocus = false;
+ while (true) {
+ let op = splitData.shift();
+ if (op == "needs-focus") {
+ needsFocus = true;
+ } else if (op == "==" || op == "!=") {
+ isEqual = op == "==";
+ break;
+ } else {
+ ok(false, "Unknown syntax");
+ return;
+ }
+ }
+ let [testFile, refFile] = splitData;
let promiseTestWin = startIframe(testFile);
let promiseRefWin = startIframe(refFile);
let refSnapshot = snapshotWindow(await promiseRefWin);
let testWindow = await promiseTestWin;
// Always wait at least 100ms, so that any test that switches
// from passing to failing when the asynchronous link coloring
// happens should fail at least some of the time.
await waitFor100ms();
let tries;
let testSnapshot;
for (tries = 0; tries < gMaxPassingTries * gTimeoutFactor; ++tries) {
+ if (needsFocus) {
+ await SimpleTest.promiseFocus(testWindow, false);
+ }
testSnapshot = snapshotWindow(testWindow);
if (passes(isEqual, testSnapshot, refSnapshot)) {
if (tries > gMaxPassingTries) {
gMaxPassingTries = tries;
}
break;
}
// Links might not have been colored yet. Try again in 100ms.