Bug 1396228 - Filter out by type if the type if specified for PerformanceEntry.getEntries. r?baku draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 02 Sep 2017 21:42:00 +0900
changeset 657991 ea9017b0ccb1eb4d02d0eec579f66bd920eb7b5e
parent 657990 4761006774ea7d3400cd68226180fabee21d7048
child 657997 ae4c2f9468908b06d6c5d862199c8b66793baf10
push id77661
push userhikezoe@mozilla.com
push dateSat, 02 Sep 2017 12:42:20 +0000
reviewersbaku
bugs1396228
milestone57.0a1
Bug 1396228 - Filter out by type if the type if specified for PerformanceEntry.getEntries. r?baku MozReview-Commit-ID: 4XManqN8BVY
dom/performance/PerformanceObserverEntryList.cpp
testing/web-platform/meta/performance-timeline/po-getentries.any.js.ini
--- a/dom/performance/PerformanceObserverEntryList.cpp
+++ b/dom/performance/PerformanceObserverEntryList.cpp
@@ -85,15 +85,23 @@ PerformanceObserverEntryList::GetEntries
 
 void
 PerformanceObserverEntryList::GetEntriesByName(
   const nsAString& aName,
   const Optional<nsAString>& aEntryType,
   nsTArray<RefPtr<PerformanceEntry>>& aRetval)
 {
   aRetval.Clear();
+  const bool typePassed = aEntryType.WasPassed();
   for (const RefPtr<PerformanceEntry>& entry : mEntries) {
-    if (entry->GetName().Equals(aName)) {
-      aRetval.AppendElement(entry);
+    if (!entry->GetName().Equals(aName)) {
+      continue;
     }
+
+    if (typePassed &&
+        !entry->GetEntryType().Equals(aEntryType.Value())) {
+      continue;
+    }
+
+    aRetval.AppendElement(entry);
   }
   aRetval.Sort(PerformanceEntryComparator());
 }
deleted file mode 100644
--- a/testing/web-platform/meta/performance-timeline/po-getentries.any.js.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[po-getentries.any.html]
-  type: testharness
-  [getEntries, getEntriesByType and getEntriesByName work]
-    expected: FAIL
-
-
-[po-getentries.any.worker.html]
-  type: testharness
-  [getEntries, getEntriesByType and getEntriesByName work]
-    expected: FAIL
-