Source code

Revision control

Other Tools

1
/* Any copyright is dedicated to the Public Domain.
3
4
"use strict";
5
6
/*
7
* This test ensures that there is no unexpected flicker
8
* on the first window opened during startup.
9
*/
10
11
add_task(async function() {
12
let startupRecorder = Cc["@mozilla.org/test/startuprecorder;1"].getService()
13
.wrappedJSObject;
14
await startupRecorder.done;
15
16
// Ensure all the frame data is in the test compartment to avoid traversing
17
// a cross compartment wrapper for each pixel.
18
let frames = Cu.cloneInto(startupRecorder.data.frames, {});
19
ok(frames.length > 0, "Should have captured some frames.");
20
21
let unexpectedRects = 0;
22
let alreadyFocused = false;
23
for (let i = 1; i < frames.length; ++i) {
24
let frame = frames[i],
25
previousFrame = frames[i - 1];
26
let rects = compareFrames(frame, previousFrame);
27
28
// The first screenshot we get in OSX / Windows shows an unfocused browser
29
// window for some reason. See bug 1445161.
30
//
31
// We'll assume the changes we are seeing are due to this focus change if
32
// there are at least 5 areas that changed near the top of the screen, but
33
// will only ignore this once (hence the alreadyFocused variable).
34
if (!alreadyFocused && rects.length > 5 && rects.every(r => r.y2 < 100)) {
35
alreadyFocused = true;
36
todo(
37
false,
38
"bug 1445161 - the window should be focused at first paint, " +
39
rects.toSource()
40
);
41
continue;
42
}
43
44
rects = rects.filter(rect => {
45
let width = frame.width;
46
47
let exceptions = [
48
/**
49
* Nothing here! Please don't add anything new!
50
*/
51
];
52
53
let rectText = `${rect.toSource()}, window width: ${width}`;
54
for (let e of exceptions) {
55
if (e.condition(rect)) {
56
todo(false, e.name + ", " + rectText);
57
return false;
58
}
59
}
60
61
ok(false, "unexpected changed rect: " + rectText);
62
return true;
63
});
64
if (!rects.length) {
65
info("ignoring identical frame");
66
continue;
67
}
68
69
// Before dumping a frame with unexpected differences for the first time,
70
// ensure at least one previous frame has been logged so that it's possible
71
// to see the differences when examining the log.
72
if (!unexpectedRects) {
73
dumpFrame(previousFrame);
74
}
75
unexpectedRects += rects.length;
76
dumpFrame(frame);
77
}
78
is(unexpectedRects, 0, "should have 0 unknown flickering areas");
79
});