test(t => {
assert_throws(
{ name: "TypeError" }, function () { new PerformanceObserver();
}, "PerformanceObserver constructor should throw TypeError if no argument is specified."
);
assert_throws(
{ name: "TypeError" }, function () { new PerformanceObserver({});
}, "PerformanceObserver constructor should throw TypeError if the argument is not a function."
);
}, "Test that PerformanceObserver constructor throws exception");
test(t => { var observer = new PerformanceObserver(() => {});
assert_throws(
{ name: "TypeError" }, function () {
observer.observe();
}, "observe() should throw TypeError exception if no option specified."
);
assert_throws(
{ name: "TypeError" }, function () {
observer.observe({ unsupportedAttribute: "unsupported" });
}, "obsrve() should throw TypeError exception if the option has no 'entryTypes' attribute."
);
return promise.then(
() => {
assert_equals(performance.getEntriesByType("mark").length, 2);
assert_equals(performance.getEntriesByType("measure").length, 1);
},
list => {
assert_unreached("Observer callback should never be called.");
}
);
}, "Nothing should be notified after disconnecting observer");
return promise.then(list => {
assert_array_equals(
list.getEntries({ entryType: "mark" }),
performance.getEntriesByType("mark"), "getEntries with entryType filter should return correct results."
);
assert_array_equals(
list.getEntries({ name: "test" }),
performance.getEntriesByName("test"), "getEntries with name filter should return correct results."
);
assert_array_equals(
list.getEntries({ name: "test", entryType: "mark" }),
performance.getEntriesByName("test"), "getEntries with name and entryType filter should return correct results."
);
assert_array_equals(
list.getEntries({ name: "invalid" }),
[], "getEntries with non-existent name filter should return an empty array."
);
assert_array_equals(
list.getEntries({ name: "test", entryType: "measure" }),
[], "getEntries with name filter and non-existent entryType should return an empty array."
);
assert_array_equals(
list.getEntries({ name: "invalid", entryType: "mark" }),
[], "getEntries with non-existent name and entryType filter should return an empty array."
);
assert_array_equals(
list.getEntries({ initiatorType: "xmlhttprequest" }),
[], "getEntries with initiatorType filter should return an empty array."
);
});
}, "Test for PerformanceObserverEntryList.getEntries");
return promise.then(list => {
assert_equals(
list.getEntries().length,
3, "Observed user timing entries should have only three entries."
);
});
}, "Test that invoking observe method twice affects nothing");
promise_test(t => { var promise = new Promise(resolve => {
performance.clearMarks();
performance.clearMeasures();
var observer = new PerformanceObserver(list => resolve(list));
observer.observe({ entryTypes: ["mark", "measure"] });
observer.observe({ entryTypes: ["mark"] });
t.add_cleanup(() => observer.disconnect());
});
return promise.then(list => {
assert_equals(
list.getEntries().length,
2, "Observed user timing entries should have only two entries."
);
});
}, "Test that observing filter is replaced by a new filter");
promise_test(t => { var promise = new Promise(resolve => {
performance.clearMarks();
performance.clearMeasures();
var observer = new PerformanceObserver(list => resolve(list));
observer.observe({ entryTypes: ["mark"] });
observer.observe({ entryTypes: ["measure"] });
t.add_cleanup(() => observer.disconnect());
});
return promise.then(list => {
assert_equals(
list.getEntries().length,
1, "Observed user timing entries should have only 1 entries."
);
});
}, "Test that observing filter is replaced by a new filter");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.