1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/*
* This test ensures that there is no unexpected flicker
* on the first window opened during startup.
*/
add_task(async function () {
let startupRecorder =
Cc["@mozilla.org/test/startuprecorder;1"].getService().wrappedJSObject;
await startupRecorder.done;
// Ensure all the frame data is in the test compartment to avoid traversing
// a cross compartment wrapper for each pixel.
let frames = Cu.cloneInto(startupRecorder.data.frames, {});
ok(!!frames.length, "Should have captured some frames.");
let unexpectedRects = 0;
let alreadyFocused = false;
for (let i = 1; i < frames.length; ++i) {
let frame = frames[i],
previousFrame = frames[i - 1];
let rects = compareFrames(frame, previousFrame);
if (!alreadyFocused && isLikelyFocusChange(rects, frame)) {
todo(
false,
"bug 1445161 - the window should be focused at first paint, " +
rects.toSource()
);
continue;
}
alreadyFocused = true;
rects = rects.filter(rect => {
let width = frame.width;
let exceptions = [
/**
* Please don't add anything new unless justified!
*/
];
let rectText = `${rect.toSource()}, window width: ${width}`;
for (let e of exceptions) {
if (e.condition(rect)) {
todo(false, e.name + ", " + rectText);
return false;
}
}
ok(false, "unexpected changed rect: " + rectText);
return true;
});
if (!rects.length) {
info("ignoring identical frame");
continue;
}
// Before dumping a frame with unexpected differences for the first time,
// ensure at least one previous frame has been logged so that it's possible
// to see the differences when examining the log.
if (!unexpectedRects) {
dumpFrame(previousFrame);
}
unexpectedRects += rects.length;
dumpFrame(frame);
}
is(unexpectedRects, 0, "should have 0 unknown flickering areas");
});
|