diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/base/content/test/performance/browser_startup_flicker.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/performance/browser_startup_flicker.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/browser/base/content/test/performance/browser_startup_flicker.js b/browser/base/content/test/performance/browser_startup_flicker.js new file mode 100644 index 0000000000..8279a0a601 --- /dev/null +++ b/browser/base/content/test/performance/browser_startup_flicker.js @@ -0,0 +1,85 @@ +/* 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) { + // The first screenshot we get shows an unfocused browser window for some + // reason. See bug 1445161. + // + // We'll assume the changes we are seeing are due to this focus change if + // there are at least 5 areas that changed near the top of the screen, + // but will only ignore this once (hence the alreadyFocused variable). + // + // On Linux we expect just one rect because we don't draw titlebar + // buttons in the tab bar, so we just get a whole-tab-bar color-switch. + const minRects = AppConstants.platform == "linux" ? 0 : 5; + if (rects.length > minRects && rects.every(r => r.y2 < 100)) { + alreadyFocused = true; + todo( + false, + "bug 1445161 - the window should be focused at first paint, " + + rects.toSource() + ); + continue; + } + } + + 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"); +}); |