implement PerformanceObserverInit.buffered (fixes #18108)

This commit is contained in:
Remi THEBAULT 2017-08-21 02:02:10 +02:00
parent 10cd518b59
commit e186b52b04
4 changed files with 35 additions and 2 deletions

View file

@ -89,23 +89,30 @@ impl PerformanceObserver {
pub fn entries(&self) -> DOMPerformanceEntryList {
self.entries.borrow().clone()
}
pub fn set_entries(&self, entries: DOMPerformanceEntryList) {
*self.entries.borrow_mut() = entries;
}
}
impl PerformanceObserverMethods for PerformanceObserver {
// https://w3c.github.io/performance-timeline/#dom-performanceobserver-observe()
fn Observe(&self, options: &PerformanceObserverInit) -> Fallible<()> {
// step 1
// Make sure the client is asking to observe events from allowed entry types.
let entry_types = options.entryTypes.iter()
.filter(|e| VALID_ENTRY_TYPES.contains(&e.as_ref()))
.map(|e| e.clone())
.collect::<Vec<DOMString>>();
// step 2
// There must be at least one valid entry type.
if entry_types.is_empty() {
return Err((Error::Type("entryTypes cannot be empty".to_string())));
}
let performance = self.global().as_window().Performance();
performance.add_observer(self, entry_types);
// step 3-4-5
performance.add_observer(self, entry_types, options.buffered);
Ok(())
}