Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PerformanceObserver.supportedEntryTypes #25697

Merged
merged 1 commit into from Feb 15, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -159,10 +159,13 @@ impl ExtendableMessageEventMethods for ExtendableMessageEvent {
.collect();
let frozen_ports = to_frozen_array(ports.as_slice(), cx);

// Cache the Js value.
let heap_val = Heap::default();
heap_val.set(frozen_ports);
*self.frozen_ports.borrow_mut() = Some(heap_val);
// Safety: need to create the Heap value in its final memory location before setting it.
*self.frozen_ports.borrow_mut() = Some(Heap::default());
self.frozen_ports
.borrow()
.as_ref()
.unwrap()
.set(frozen_ports);

frozen_ports
}
@@ -16,6 +16,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::bindings::settings_stack::{entry_global, incumbent_global, AutoEntryScript};
use crate::dom::bindings::str::DOMString;
use crate::dom::bindings::structuredclone;
use crate::dom::bindings::utils::to_frozen_array;
use crate::dom::bindings::weakref::{DOMTracker, WeakRef};
use crate::dom::blob::Blob;
use crate::dom::crypto::Crypto;
@@ -31,6 +32,7 @@ use crate::dom::messageevent::MessageEvent;
use crate::dom::messageport::MessagePort;
use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope;
use crate::dom::performance::Performance;
use crate::dom::performanceobserver::VALID_ENTRY_TYPES;
use crate::dom::promise::Promise;
use crate::dom::window::Window;
use crate::dom::workerglobalscope::WorkerGlobalScope;
@@ -63,7 +65,7 @@ use js::jsapi::JSObject;
use js::jsapi::{CurrentGlobalOrNull, GetNonCCWObjectGlobal};
use js::jsapi::{HandleObject, Heap};
use js::jsapi::{JSAutoRealm, JSContext};
use js::jsval::UndefinedValue;
use js::jsval::{JSVal, UndefinedValue};
use js::panic::maybe_resume_unwind;
use js::rust::wrappers::EvaluateUtf8;
use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime};
@@ -222,6 +224,10 @@ pub struct GlobalScope {

#[ignore_malloc_size_of = "defined in wgpu"]
gpu_id_hub: RefCell<Identities>,

// https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
#[ignore_malloc_size_of = "mozjs"]
frozen_supported_performance_entry_types: DomRefCell<Option<Heap<JSVal>>>,
}

/// A wrapper for glue-code between the ipc router and the event-loop.
@@ -513,6 +519,7 @@ impl GlobalScope {
is_headless,
user_agent,
gpu_id_hub: RefCell::new(Identities::new()),
frozen_supported_performance_entry_types: DomRefCell::new(Default::default()),
}
}

@@ -2087,6 +2094,29 @@ impl GlobalScope {
unreachable!();
}

// https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
pub fn supported_performance_entry_types(&self, cx: SafeJSContext) -> JSVal {
if let Some(types) = &*self.frozen_supported_performance_entry_types.borrow() {
return types.get();
}

let types: Vec<DOMString> = VALID_ENTRY_TYPES
.iter()
.map(|t| DOMString::from(t.to_string()))
.collect();
let frozen_types = to_frozen_array(types.as_slice(), cx);

// Safety: need to create the Heap value in its final memory location before setting it.
*self.frozen_supported_performance_entry_types.borrow_mut() = Some(Heap::default());
self.frozen_supported_performance_entry_types
.borrow()
.as_ref()
.unwrap()
.set(frozen_types);

frozen_types
}

pub fn is_headless(&self) -> bool {
self.is_headless
}
@@ -255,10 +255,13 @@ impl MessageEventMethods for MessageEvent {
.collect();
let frozen_ports = to_frozen_array(ports.as_slice(), cx);

// Cache the Js value.
let heap_val = Heap::default();
heap_val.set(frozen_ports);
*self.frozen_ports.borrow_mut() = Some(heap_val);
// Safety: need to create the Heap value in its final memory location before setting it.
*self.frozen_ports.borrow_mut() = Some(Heap::default());
self.frozen_ports
.borrow()
.as_ref()
.unwrap()
.set(frozen_ports);

frozen_ports
}
@@ -18,19 +18,21 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::performance::PerformanceEntryList;
use crate::dom::performanceentry::PerformanceEntry;
use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList;
use crate::script_runtime::JSContext;
use dom_struct::dom_struct;
use js::jsval::JSVal;
use std::cell::Cell;
use std::rc::Rc;

/// List of allowed performance entry types.
const VALID_ENTRY_TYPES: &'static [&'static str] = &[
/// List of allowed performance entry types, in alphabetical order.
pub const VALID_ENTRY_TYPES: &'static [&'static str] = &[
// "frame", //TODO Frame Timing API
"mark", // User Timing API
"measure", // User Timing API
"resource", // Resource Timing API
"navigation", // Navigation Timing API
// "frame", //TODO Frame Timing API
// "server", XXX Server Timing API
"paint", // Paint Timing API
"paint", // Paint Timing API
"resource", // Resource Timing API
// "server", XXX Server Timing API
];

#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
@@ -110,6 +112,14 @@ impl PerformanceObserver {
pub fn set_entries(&self, entries: DOMPerformanceEntryList) {
*self.entries.borrow_mut() = entries;
}

// https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute
#[allow(non_snake_case)]
pub fn SupportedEntryTypes(cx: JSContext, global: &GlobalScope) -> JSVal {
// While this is exposed through a method of PerformanceObserver,
// it is specified as associated with the global scope.
global.supported_performance_entry_types(cx)
}
}

impl PerformanceObserverMethods for PerformanceObserver {
@@ -21,5 +21,6 @@ interface PerformanceObserver {
void observe(optional PerformanceObserverInit options = {});
void disconnect();
PerformanceEntryList takeRecords();
// [SameObject] static readonly attribute FrozenArray<DOMString> supportedEntryTypes;
// codegen doesn't like SameObject+static and doesn't know FrozenArray
/*[SameObject]*/ static readonly attribute /*FrozenArray<DOMString>*/ any supportedEntryTypes;
};
@@ -1,4 +1,4 @@
[supported_navigation_type.window.html]
[supportedEntryTypes contains 'navigation'.]
expected: FAIL

expected: TIMEOUT
['navigation' entries should be observable.]
expected: TIMEOUT
@@ -11,9 +11,6 @@
[Test default toJSON operation of PerformanceMark]
expected: FAIL

[PerformanceObserver interface: attribute supportedEntryTypes]
expected: FAIL

[PerformanceMark interface: attribute detail]
expected: FAIL

@@ -31,9 +28,6 @@
[Test default toJSON operation of PerformanceMark]
expected: FAIL

[PerformanceObserver interface: attribute supportedEntryTypes]
expected: FAIL

[PerformanceMark interface: attribute detail]
expected: FAIL

This file was deleted.

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.