Bug 1165796 - Part 3: Fix PerformanceObserverEntryList::GetEntries filtering for initiatorType. r=baku

--HG--
extra : rebase_source : 839dbd9ebda90f50b3a23036a34e05c9322f1ddd
This commit is contained in:
Hiroyuki Ikezoe 2015-08-17 15:13:26 -07:00
Родитель 07f62b2d0a
Коммит ecf1610a5b
3 изменённых файлов: 26 добавлений и 3 удалений

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

@ -43,9 +43,12 @@ PerformanceObserverEntryList::GetEntries(
{
aRetval.Clear();
for (const nsRefPtr<PerformanceEntry>& entry : mEntries) {
const PerformanceResourceTiming* resourceEntry =
entry->ToResourceTiming();
if (aFilter.mInitiatorType.WasPassed() && resourceEntry) {
if (aFilter.mInitiatorType.WasPassed()) {
const PerformanceResourceTiming* resourceEntry =
entry->ToResourceTiming();
if (!resourceEntry) {
continue;
}
nsAutoString initiatorType;
resourceEntry->GetInitiatorType(initiatorType);
if (!initiatorType.Equals(aFilter.mInitiatorType.Value())) {

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

@ -41,9 +41,11 @@ function promiseXHR(aUrl) {
async_test(t => {
performance.clearResourceTimings();
var observedEntryList;
var observedEntries = [];
var observer = new PerformanceObserver(list => {
list.getEntries().forEach(entry => observedEntries.push(entry));
observedEntryList = list;
});
observer.observe({entryTypes: ['resource']});
@ -54,6 +56,20 @@ async_test(t => {
assert_array_equals(observedEntries,
performance.getEntriesByType("resource"),
"Observed 'resource' entries should equal to entries obtained by getEntriesByType.");
// getEntries filtering tests
assert_array_equals(observedEntryList.getEntries({name: "http://mochi.test:8888/tests/dom/base/test/test-data.json"}),
performance.getEntriesByName("http://mochi.test:8888/tests/dom/base/test/test-data.json"),
"getEntries with name filter should return correct results.");
assert_array_equals(observedEntryList.getEntries({entryType: "resource"}),
performance.getEntriesByType("resource"),
"getEntries with entryType filter should return correct results.");
assert_array_equals(observedEntryList.getEntries({initiatorType: "xmlhttprequest"}),
performance.getEntriesByType("resource"),
"getEntries with initiatorType filter should return correct results.");
assert_array_equals(observedEntryList.getEntries({initiatorType: "link"}),
[],
"getEntries with non-existent initiatorType filter should return an empty array.");
}));
}, "resource-timing test");

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

@ -135,6 +135,10 @@ test(t => {
"entryType": "mark"}),
[],
"getEntries with non-existent name and entryType filter should return an empty array.");
assert_array_equals(observedEntryList.getEntries({initiatorType: "xmlhttprequest"}),
[],
"getEntries with initiatorType filter should return an empty array.");
}, "Test for PerformanceObserverEntryList.getEntries");
test(t => {