Bug 1582655, try to make browser_test_feature_preferencereads.js less racy and let browser_test_feature_jsallocations.js to run a bit longer, r=whawkins

Differential Revision: https://phabricator.services.mozilla.com/D46865

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Olli Pettay 2019-09-24 09:23:35 +00:00
Родитель 045149d49a
Коммит beb759c519
2 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
requestLongerTimeout(10);
/**
* Test the JS Allocations feature. This is done as a browser test to ensure that
* we realistically try out how the JS allocations are running. This ensures that

Просмотреть файл

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
requestLongerTimeout(10);
function countDpiPrefReadsInThread(thread) {
let count = 0;
for (let payload of getPayloadsOfType(thread, "PreferenceRead")) {
@ -12,6 +14,23 @@ function countDpiPrefReadsInThread(thread) {
return count;
}
async function waitForPaintAfterLoad() {
return ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
return new Promise(function(resolve) {
function listener() {
if (content.document.readyState == "complete") {
content.requestAnimationFrame(() => setTimeout(resolve, 0));
}
}
if (content.document.readyState != "complete") {
content.document.addEventListener("readystatechange", listener);
} else {
listener();
}
});
});
}
/**
* Test the PreferenceRead feature.
*/
@ -34,8 +53,7 @@ add_task(async function test_profile_feature_preferencereads() {
() => Services.appinfo.processID
);
// Wait 100ms so that the tab finishes executing.
await wait(100);
await waitForPaintAfterLoad();
// Check that some PreferenceRead profile markers were generated when the
// feature is enabled.
@ -54,8 +72,17 @@ add_task(async function test_profile_feature_preferencereads() {
startProfiler({ features: ["threads"] });
// Now reload the tab with a clean run.
gBrowser.reload();
await wait(100);
await ContentTask.spawn(contentBrowser, null, () => {
return new Promise(resolve => {
addEventListener("pageshow", () => resolve(), {
capturing: true,
once: true,
});
content.location.reload();
});
});
await waitForPaintAfterLoad();
// Check that no PreferenceRead markers were recorded when the feature
// is turned off.