зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363361 - Make reflow tests use nsIDOMWindowUtils.ensureDirtyRootFrame to avoid manual frame dirtying hack. r=florian
MozReview-Commit-ID: E2azpUdgiSn --HG-- extra : rebase_source : 5166f7f9f4b46514280abdc58631164b404f6b30
This commit is contained in:
Родитель
348be03af6
Коммит
6549fe80ab
|
@ -118,7 +118,7 @@ add_task(async function() {
|
|||
BrowserTestUtils.waitForEvent(PanelUI.panel, "popuppositioned");
|
||||
await PanelUI.show();
|
||||
await popupPositioned;
|
||||
}, EXPECTED_APPMENU_OPEN_REFLOWS, window, PanelUI.panel);
|
||||
}, EXPECTED_APPMENU_OPEN_REFLOWS);
|
||||
|
||||
// Now open a series of subviews, and then close the appmenu. We
|
||||
// should not reflow during any of this.
|
||||
|
@ -160,5 +160,5 @@ add_task(async function() {
|
|||
let hidden = BrowserTestUtils.waitForEvent(PanelUI.panel, "popuphidden");
|
||||
PanelUI.hide();
|
||||
await hidden;
|
||||
}, EXPECTED_APPMENU_SUBVIEW_REFLOWS, window, PanelUI.panel);
|
||||
}, EXPECTED_APPMENU_SUBVIEW_REFLOWS);
|
||||
});
|
||||
|
|
|
@ -36,12 +36,6 @@ add_task(async function() {
|
|||
const TAB_COUNT_FOR_GROWTH = computeMaxTabCount();
|
||||
await createTabs(TAB_COUNT_FOR_GROWTH);
|
||||
|
||||
// Because the tab strip is a scrollable frame, we can't use the
|
||||
// default dirtying function from withReflowObserver and reliably
|
||||
// get reflows for the strip. Instead, we provide a node that's
|
||||
// already in the scrollable frame to dirty - in this case, the
|
||||
// original tab.
|
||||
let origTab = gBrowser.selectedTab;
|
||||
let lastTab = gBrowser.tabs[gBrowser.tabs.length - 1];
|
||||
await BrowserTestUtils.switchTab(gBrowser, lastTab);
|
||||
|
||||
|
@ -52,7 +46,7 @@ add_task(async function() {
|
|||
await BrowserTestUtils.waitForEvent(tab, "transitionend",
|
||||
false, e => e.propertyName === "max-width");
|
||||
await switchDone;
|
||||
}, EXPECTED_REFLOWS, window, origTab);
|
||||
}, EXPECTED_REFLOWS);
|
||||
|
||||
await removeAllButFirstTab();
|
||||
});
|
||||
|
|
|
@ -22,13 +22,6 @@ const EXPECTED_REFLOWS = [
|
|||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
|
||||
// Because the tab strip is a scrollable frame, we can't use the
|
||||
// default dirtying function from withReflowObserver and reliably
|
||||
// get reflows for the strip. Instead, we provide a node that's
|
||||
// already in the scrollable frame to dirty - in this case, the
|
||||
// original tab.
|
||||
let origTab = gBrowser.selectedTab;
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
await BrowserTestUtils.waitForCondition(() => tab._fullyOpen);
|
||||
|
||||
|
@ -39,6 +32,6 @@ add_task(async function() {
|
|||
await BrowserTestUtils.waitForEvent(tab, "transitionend",
|
||||
false, e => e.propertyName === "max-width");
|
||||
await switchDone;
|
||||
}, EXPECTED_REFLOWS, window, origTab);
|
||||
}, EXPECTED_REFLOWS);
|
||||
is(EXPECTED_REFLOWS.length, 0, "No reflows are expected when closing a tab");
|
||||
});
|
||||
|
|
|
@ -27,13 +27,6 @@ const EXPECTED_REFLOWS = [
|
|||
add_task(async function() {
|
||||
await ensureNoPreloadedBrowser();
|
||||
|
||||
// Because the tab strip is a scrollable frame, we can't use the
|
||||
// default dirtying function from withReflowObserver and reliably
|
||||
// get reflows for the strip. Instead, we provide a node that's
|
||||
// already in the scrollable frame to dirty - in this case, the
|
||||
// original tab.
|
||||
let origTab = gBrowser.selectedTab;
|
||||
|
||||
// Add a reflow observer and open a new tab.
|
||||
await withReflowObserver(async function() {
|
||||
let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
|
||||
|
@ -41,7 +34,7 @@ add_task(async function() {
|
|||
await BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "transitionend",
|
||||
false, e => e.propertyName === "max-width");
|
||||
await switchDone;
|
||||
}, EXPECTED_REFLOWS, window, origTab);
|
||||
}, EXPECTED_REFLOWS);
|
||||
|
||||
let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
|
||||
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
|
|
|
@ -33,20 +33,13 @@ add_task(async function() {
|
|||
|
||||
await createTabs(TAB_COUNT_FOR_SQUEEZE);
|
||||
|
||||
// Because the tab strip is a scrollable frame, we can't use the
|
||||
// default dirtying function from withReflowObserver and reliably
|
||||
// get reflows for the strip. Instead, we provide a node that's
|
||||
// already in the scrollable frame to dirty - in this case, the
|
||||
// original tab.
|
||||
let origTab = gBrowser.selectedTab;
|
||||
|
||||
await withReflowObserver(async function() {
|
||||
let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
|
||||
BrowserOpenTab();
|
||||
await BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "transitionend",
|
||||
false, e => e.propertyName === "max-width");
|
||||
await switchDone;
|
||||
}, EXPECTED_REFLOWS, window, origTab);
|
||||
}, EXPECTED_REFLOWS);
|
||||
|
||||
await removeAllButFirstTab();
|
||||
});
|
||||
|
|
|
@ -32,13 +32,7 @@ add_task(async function() {
|
|||
Assert.equal(EXPECTED_REFLOWS.length, 0,
|
||||
"We shouldn't have added any new expected reflows.");
|
||||
|
||||
// Because the tab strip is a scrollable frame, we can't use the
|
||||
// default dirtying function from withReflowObserver and reliably
|
||||
// get reflows for the strip. Instead, we provide a node that's
|
||||
// already in the scrollable frame to dirty - in this case, the
|
||||
// original tab.
|
||||
let origTab = gBrowser.selectedTab;
|
||||
|
||||
let firstSwitchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
|
||||
let otherTab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
await firstSwitchDone;
|
||||
|
@ -47,7 +41,7 @@ add_task(async function() {
|
|||
let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
|
||||
gBrowser.selectedTab = origTab;
|
||||
await switchDone;
|
||||
}, EXPECTED_REFLOWS, window, origTab);
|
||||
}, EXPECTED_REFLOWS);
|
||||
|
||||
await BrowserTestUtils.removeTab(otherTab);
|
||||
});
|
||||
|
|
|
@ -65,20 +65,17 @@
|
|||
* it defaults to the empty Array, meaning no reflows are expected.
|
||||
* @param window (browser window, optional)
|
||||
* The browser window to monitor. Defaults to the current window.
|
||||
* @param elemToDirty (DOM node, optional)
|
||||
* Callers can provide a custom DOM node to change some layout style
|
||||
* on in the event that the action being tested is occurring within
|
||||
* a scrollable frame. Otherwise, withReflowObserver defaults to dirtying
|
||||
* the first element child of the window.
|
||||
*/
|
||||
async function withReflowObserver(testFn, expectedStacks = [], win = window, elemToDirty) {
|
||||
if (!elemToDirty) {
|
||||
elemToDirty = win.document.firstElementChild;
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
let dirtyFrameFn = (e) => {
|
||||
elemToDirty.style.margin = (++i % 4) + "px";
|
||||
async function withReflowObserver(testFn, expectedStacks = [], win = window) {
|
||||
let dwu = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
let dirtyFrameFn = () => {
|
||||
try {
|
||||
dwu.ensureDirtyRootFrame();
|
||||
} catch (e) {
|
||||
// If this fails, we should probably make note of it, but it's not fatal.
|
||||
info("Note: ensureDirtyRootFrame threw an exception.");
|
||||
}
|
||||
};
|
||||
|
||||
let els = Cc["@mozilla.org/eventlistenerservice;1"]
|
||||
|
@ -120,7 +117,9 @@ async function withReflowObserver(testFn, expectedStacks = [], win = window, ele
|
|||
},
|
||||
|
||||
reflowInterruptible(start, end) {
|
||||
// We're not interested in interruptible reflows.
|
||||
// We're not interested in interruptible reflows, but might as well take the
|
||||
// opportuntiy to dirty the root frame.
|
||||
dirtyFrameFn();
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver,
|
||||
|
@ -148,8 +147,6 @@ async function withReflowObserver(testFn, expectedStacks = [], win = window, ele
|
|||
|
||||
els.removeListenerForAllEvents(win, dirtyFrameFn, true);
|
||||
docShell.removeWeakReflowObserver(observer);
|
||||
|
||||
elemToDirty.style.margin = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче