Bug 1473034 - Ignore the gfx sanitytest window when recording start-up paints. r?florian
MozReview-Commit-ID: 9cI20Z4RbbL
--- a/browser/base/content/test/performance/browser_startup_flicker.js
+++ b/browser/base/content/test/performance/browser_startup_flicker.js
@@ -10,16 +10,17 @@
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 > 0, "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);
// The first screenshot we get in OSX / Windows shows an unfocused browser
--- a/browser/components/tests/startupRecorder.js
+++ b/browser/components/tests/startupRecorder.js
@@ -90,26 +90,43 @@ startupRecorder.prototype = {
firstPaintNotification,
"sessionstore-windows-restored",
];
for (let t of topics)
Services.obs.addObserver(this, t);
return;
}
+ // We only care about the first paint notification for browser windows, and
+ // not other types (for example, the gfx sanity test window)
+ if (topic == firstPaintNotification) {
+ // In the case we're handling xul-window-visible, we'll have been handed
+ // an nsIXULWindow instead of an nsIDOMWindow.
+ if (subject instanceof Ci.nsIXULWindow) {
+ subject = subject.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);
+ }
+
+ if (subject.document.documentElement.getAttribute("windowtype") != "navigator:browser") {
+ return;
+ }
+ }
+
if (topic == "image-drawing" || topic == "image-loading") {
this.data.images[topic].add(data);
return;
}
Services.obs.removeObserver(this, topic);
if (topic == firstPaintNotification &&
Services.prefs.getBoolPref("browser.startup.record", false)) {
- win = Services.wm.getMostRecentWindow("navigator:browser");
+ // Because of the check for navigator:browser we made earlier, we know
+ // that if we got here, then the subject must be the first browser window.
+ win = subject;
canvas = win.document.createElementNS("http://www.w3.org/1999/xhtml",
"canvas");
canvas.mozOpaque = true;
afterPaintListener();
win.addEventListener("MozAfterPaint", afterPaintListener);
}
if (topic == "sessionstore-windows-restored") {
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -886,17 +886,18 @@ NS_IMETHODIMP nsXULWindow::SetVisibility
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
if (windowMediator)
windowMediator->UpdateWindowTimeStamp(static_cast<nsIXULWindow*>(this));
// notify observers so that we can hide the splash screen if possible
nsCOMPtr<nsIObserverService> obssvc = services::GetObserverService();
NS_ASSERTION(obssvc, "Couldn't get observer service.");
if (obssvc) {
- obssvc->NotifyObservers(nullptr, "xul-window-visible", nullptr);
+ obssvc->NotifyObservers(static_cast<nsIXULWindow*>(this),
+ "xul-window-visible", nullptr);
}
mDebuting = false;
return NS_OK;
}
NS_IMETHODIMP nsXULWindow::GetEnabled(bool *aEnabled)
{