diff --git a/devtools/client/performance/test/browser.ini b/devtools/client/performance/test/browser.ini index 9ababa4a863f..1a3cea0ebc42 100644 --- a/devtools/client/performance/test/browser.ini +++ b/devtools/client/performance/test/browser.ini @@ -132,7 +132,6 @@ skip-if = os == 'linux' || debug # bug 1186322 for Linux, bug 1203895 for leaks [browser_perf-telemetry-03.js] [browser_perf-telemetry-04.js] [browser_profiler_tree-abstract-01.js] -skip-if = e10s && os == 'linux' # bug 1186322 [browser_profiler_tree-abstract-02.js] [browser_profiler_tree-abstract-03.js] [browser_profiler_tree-abstract-04.js] diff --git a/devtools/client/performance/test/browser_profiler_tree-abstract-01.js b/devtools/client/performance/test/browser_profiler_tree-abstract-01.js index a869c1432cad..fe42e66b4abf 100644 --- a/devtools/client/performance/test/browser_profiler_tree-abstract-01.js +++ b/devtools/client/performance/test/browser_profiler_tree-abstract-01.js @@ -11,7 +11,7 @@ var { Heritage } = Cu.import("resource://devtools/client/shared/widgets/ViewHelp function* spawnTest() { let container = document.createElement("vbox"); - gBrowser.selectedBrowser.parentNode.appendChild(container); + yield appendAndWaitForPaint(gBrowser.selectedBrowser.parentNode, container); // Populate the tree and test the root item... diff --git a/devtools/client/performance/test/browser_profiler_tree-abstract-02.js b/devtools/client/performance/test/browser_profiler_tree-abstract-02.js index f18758f4ff68..e535423665e1 100644 --- a/devtools/client/performance/test/browser_profiler_tree-abstract-02.js +++ b/devtools/client/performance/test/browser_profiler_tree-abstract-02.js @@ -11,10 +11,9 @@ var { Heritage } = Cu.import("resource://devtools/client/shared/widgets/ViewHelp function* spawnTest() { let container = document.createElement("vbox"); - gBrowser.selectedBrowser.parentNode.appendChild(container); + yield appendAndWaitForPaint(gBrowser.selectedBrowser.parentNode, container); // Populate the tree and test `expand`, `collapse` and `getChild`... - let treeRoot = new MyCustomTreeItem(gDataSrc, { parent: null }); treeRoot.autoExpandDepth = 1; treeRoot.attachTo(container); diff --git a/devtools/client/performance/test/browser_profiler_tree-abstract-03.js b/devtools/client/performance/test/browser_profiler_tree-abstract-03.js index 9b0e76009c30..c8c9de229487 100644 --- a/devtools/client/performance/test/browser_profiler_tree-abstract-03.js +++ b/devtools/client/performance/test/browser_profiler_tree-abstract-03.js @@ -11,7 +11,7 @@ var { Heritage } = Cu.import("resource://devtools/client/shared/widgets/ViewHelp function* spawnTest() { let container = document.createElement("vbox"); - gBrowser.selectedBrowser.parentNode.appendChild(container); + yield appendAndWaitForPaint(gBrowser.selectedBrowser.parentNode, container); // Populate the tree by pressing RIGHT... diff --git a/devtools/client/performance/test/browser_profiler_tree-abstract-04.js b/devtools/client/performance/test/browser_profiler_tree-abstract-04.js index b835a68cbc37..676dee7df55a 100644 --- a/devtools/client/performance/test/browser_profiler_tree-abstract-04.js +++ b/devtools/client/performance/test/browser_profiler_tree-abstract-04.js @@ -10,7 +10,7 @@ var { Heritage } = Cu.import("resource://devtools/client/shared/widgets/ViewHelp function* spawnTest() { let container = document.createElement("vbox"); - gBrowser.selectedBrowser.parentNode.appendChild(container); + yield appendAndWaitForPaint(gBrowser.selectedBrowser.parentNode, container); // Populate the tree and test the root item... diff --git a/devtools/client/performance/test/head.js b/devtools/client/performance/test/head.js index 087e2b389350..c6c11f5b4e5a 100644 --- a/devtools/client/performance/test/head.js +++ b/devtools/client/performance/test/head.js @@ -206,6 +206,37 @@ function onceSpread(aTarget, aEventName, aUseCapture) { return once(aTarget, aEventName, aUseCapture, true); } +/** + * Returns a promise that will resolve when the window triggers a MozAfterPaint + * event. This ensures the current tab has been painted. + * @return {Promise} + */ +function waitForMozAfterPaint() { + return new Promise(resolve => { + let onMozAfterPaint = function() { + window.removeEventListener("MozAfterPaint", onMozAfterPaint); + resolve(); + }; + window.addEventListener("MozAfterPaint", onMozAfterPaint); + }); +} + +/** + * Appends the provided element to the provided parent node. If run in e10s + * mode, will also wait for MozAfterPaint to make sure the tab is rendered. + * Should be reviewed if Bug 1240509 lands + */ +function* appendAndWaitForPaint(parent, element) { + let isE10s = Services.appinfo.browserTabsRemoteAutostart; + if (isE10s) { + let onMozAfterPaint = waitForMozAfterPaint(); + parent.appendChild(element); + return onMozAfterPaint; + } + + parent.appendChild(element); +} + function test () { Task.spawn(spawnTest).then(finish, handleError); }