Bug 1518999 - Refactor some performance.getEntries related tests r=mstange

Some tests made some assumptions about the number of returned entries
by performance.getEntries, and these assumptions are not valid
anymore once we added new entries.

Depends on D66463

Differential Revision: https://phabricator.services.mozilla.com/D68645
This commit is contained in:
Sean Feng 2020-07-31 19:20:41 +00:00
parent d914187ce2
commit f59ae11633
3 changed files with 15 additions and 7 deletions

View File

@ -192,13 +192,20 @@ add_task(async function runRTPTests() {
content.performance.measure("Test-Measure", "Test", "Test-End");
// Check the entries for performance.getEntries/getEntriesByType/getEntriesByName.
await new Promise(resolve => {
const paintObserver = new content.PerformanceObserver(() => {
resolve();
});
paintObserver.observe({ type: "paint", buffered: true });
});
is(
content.performance.getEntries().length,
4,
5,
"For reduceTimerPrecision, there should be 4 entries for performance.getEntries()"
// PerformanceNavigationTiming, PerformanceMark, PerformanceMark, PerformanceMeasure
// PerformancePaintTiming, PerformanceNavigationTiming, PerformanceMark, PerformanceMark, PerformanceMeasure
);
for (var i = 0; i < 4; i++) {
for (var i = 0; i < 5; i++) {
let startTime = content.performance.getEntries()[i].startTime;
let duration = content.performance.getEntries()[i].duration;
ok(

View File

@ -407,7 +407,9 @@ add_task(async function() {
tests.forEach(test => {
let { input, headers } = test;
if (input === "PERFORMANCE_ENTRIES") {
input = content.wrappedJSObject.performance.getEntries();
input = content.wrappedJSObject.performance.getEntriesByType(
"navigation"
);
}
content.wrappedJSObject.doConsoleTable(input, headers);
});

View File

@ -144,9 +144,8 @@ var allResources = {
};
window.onload = function() {
let entries = performance.getEntries();
// The entries.slice() to drop first 'document' item.
for (let entry of entries.slice(1)) {
let entries = performance.getEntriesByType('resource');
for (let entry of entries) {
//dump(entry.name + " || "+ entry.initiatorType+ "\n");
if (!(entry.name in allResources)) {
if (entry.name.substr(-4) == ".ttf") {