fune/browser/base/content/test/performance/browser_windowopen_reflows.js
Johann Hofmann a2901df84e Bug 1375335 - Fix window control height calculation on Windows 10. r=dao
This commit:

- Makes the window controls have exactly the same height as tabs when the
  menubar is hidden, and have the same height as the menubar when it is shown.
  This requires us to remove the menubar height before flushing layout in
  case it is shown, since we need its original height for the calculation.

- Removes the top margin between the menu bar and the window border
  that was present on Windows 10 and makes it apply on Windows 7 only.
  The border was causing miscalculations of the window control height,
  which could have been handled in browser-tabsintitlebar.js, but since
  it's not part of the Photon spec we decide to remove it entirely.

- Makes window control height calculations ignore vertical tabs toolbar
  margins. The only margin it has right now is -1px and the calculation
  code doesn't work right with negative margins.

MozReview-Commit-ID: HJXxUUJFX8x

--HG--
extra : rebase_source : fdb5db7e5b410cb45cef054d5cbec41048211f75
2017-08-09 14:36:01 +01:00

126 lines
3.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* WHOA THERE: We should never be adding new things to EXPECTED_REFLOWS. This
* is a whitelist that should slowly go away as we improve the performance of
* the front-end. Instead of adding more reflows to the whitelist, you should
* be modifying your code to avoid the reflow.
*
* See https://developer.mozilla.org/en-US/Firefox/Performance_best_practices_for_Firefox_fe_engineers
* for tips on how to do that.
*/
const EXPECTED_REFLOWS = [
{
stack: [
"select@chrome://global/content/bindings/textbox.xml",
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
"_delayedStartup@chrome://browser/content/browser.js",
],
},
];
if (Services.appinfo.OS == "Linux") {
if (gMultiProcessBrowser) {
EXPECTED_REFLOWS.push({
stack: [
"handleEvent@chrome://browser/content/tabbrowser.xml",
],
});
} else {
EXPECTED_REFLOWS.push({
stack: [
"handleEvent@chrome://browser/content/tabbrowser.xml",
"inferFromText@chrome://browser/content/browser.js",
"handleEvent@chrome://browser/content/browser.js",
],
});
}
}
if (Services.appinfo.OS == "Darwin") {
EXPECTED_REFLOWS.push({
stack: [
"handleEvent@chrome://browser/content/tabbrowser.xml",
"inferFromText@chrome://browser/content/browser.js",
"handleEvent@chrome://browser/content/browser.js",
],
});
}
if (Services.appinfo.OS == "WINNT") {
EXPECTED_REFLOWS.push(
{
stack: [
"handleEvent@chrome://browser/content/tabbrowser.xml",
"inferFromText@chrome://browser/content/browser.js",
"handleEvent@chrome://browser/content/browser.js",
],
},
{
stack: [
"handleEvent@chrome://browser/content/tabbrowser.xml",
],
}
);
}
if (Services.appinfo.OS == "WINNT" || Services.appinfo.OS == "Darwin") {
EXPECTED_REFLOWS.push(
{
stack: [
"rect@chrome://browser/content/browser-tabsintitlebar.js",
"_update@chrome://browser/content/browser-tabsintitlebar.js",
"init@chrome://browser/content/browser-tabsintitlebar.js",
"handleEvent@chrome://browser/content/tabbrowser.xml",
],
times: 4, // This number should only ever go down - never up.
},
{
stack: [
"verticalMargins@chrome://browser/content/browser-tabsintitlebar.js",
"_update@chrome://browser/content/browser-tabsintitlebar.js",
"init@chrome://browser/content/browser-tabsintitlebar.js",
"handleEvent@chrome://browser/content/tabbrowser.xml",
],
times: 2, // This number should only ever go down - never up.
}
);
}
/*
* This test ensures that there are no unexpected
* uninterruptible reflows when opening new windows.
*/
add_task(async function() {
const IS_WIN8 = (navigator.userAgent.indexOf("Windows NT 6.2") != -1);
if (IS_WIN8) {
ok(true, "Skipping this test because of perma-failures on Windows 8 x64 (bug 1381521)");
return;
}
// Flushing all caches helps to ensure that we get consistent
// behaviour when opening a new window, even if windows have been
// opened in previous tests.
Services.obs.notifyObservers(null, "startupcache-invalidate");
Services.obs.notifyObservers(null, "chrome-flush-skin-caches");
Services.obs.notifyObservers(null, "chrome-flush-caches");
let win = OpenBrowserWindow();
await withReflowObserver(async function() {
let resizeEvent = BrowserTestUtils.waitForEvent(win, "resize");
let delayedStartup =
TestUtils.topicObserved("browser-delayed-startup-finished",
subject => subject == win);
await resizeEvent;
await delayedStartup;
}, EXPECTED_REFLOWS, win);
await BrowserTestUtils.closeWindow(win);
});