mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
Auto merge of #19569 - asajeffrey:script-perf-measure-topLevelDomComplete, r=jdm
Add a topLevelDomComplete metric. <!-- Please describe your changes on the following line: --> Measure DOM completion without iframes. This is in support of measuring when the main document is loaded, ignoring secondary content, e.g. ads. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #19561 - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19569) <!-- Reviewable:end -->
This commit is contained in:
commit
d832e1b8f8
7 changed files with 59 additions and 0 deletions
|
@ -141,6 +141,13 @@ impl DocumentLoader {
|
|||
!self.blocking_loads.is_empty()
|
||||
}
|
||||
|
||||
pub fn is_only_blocked_by_iframes(&self) -> bool {
|
||||
self.blocking_loads.iter().all(|load| match *load {
|
||||
LoadType::Subframe(_) => true,
|
||||
_ => false
|
||||
})
|
||||
}
|
||||
|
||||
pub fn inhibit_events(&mut self) {
|
||||
self.events_inhibited = true;
|
||||
}
|
||||
|
|
|
@ -322,6 +322,7 @@ pub struct Document {
|
|||
dom_content_loaded_event_start: Cell<u64>,
|
||||
dom_content_loaded_event_end: Cell<u64>,
|
||||
dom_complete: Cell<u64>,
|
||||
top_level_dom_complete: Cell<u64>,
|
||||
load_event_start: Cell<u64>,
|
||||
load_event_end: Cell<u64>,
|
||||
/// <https://html.spec.whatwg.org/multipage/#concept-document-https-state>
|
||||
|
@ -1627,6 +1628,12 @@ impl Document {
|
|||
// asap_in_order_script_loaded.
|
||||
|
||||
let loader = self.loader.borrow();
|
||||
|
||||
// Servo measures when the top-level content (not iframes) is loaded.
|
||||
if (self.top_level_dom_complete.get() == 0) && loader.is_only_blocked_by_iframes() {
|
||||
update_with_current_time_ms(&self.top_level_dom_complete);
|
||||
}
|
||||
|
||||
if loader.is_blocked() || loader.events_inhibited() {
|
||||
// Step 6.
|
||||
return;
|
||||
|
@ -1951,6 +1958,10 @@ impl Document {
|
|||
self.dom_complete.get()
|
||||
}
|
||||
|
||||
pub fn get_top_level_dom_complete(&self) -> u64 {
|
||||
self.top_level_dom_complete.get()
|
||||
}
|
||||
|
||||
pub fn get_load_event_start(&self) -> u64 {
|
||||
self.load_event_start.get()
|
||||
}
|
||||
|
@ -2265,6 +2276,7 @@ impl Document {
|
|||
dom_content_loaded_event_start: Cell::new(Default::default()),
|
||||
dom_content_loaded_event_end: Cell::new(Default::default()),
|
||||
dom_complete: Cell::new(Default::default()),
|
||||
top_level_dom_complete: Cell::new(Default::default()),
|
||||
load_event_start: Cell::new(Default::default()),
|
||||
load_event_end: Cell::new(Default::default()),
|
||||
https_state: Cell::new(HttpsState::None),
|
||||
|
|
|
@ -86,6 +86,12 @@ impl PerformanceTimingMethods for PerformanceTiming {
|
|||
fn LoadEventEnd(&self) -> u64 {
|
||||
self.document.get_load_event_end()
|
||||
}
|
||||
|
||||
// check-tidy: no specs after this line
|
||||
// Servo-only timing for when top-level content (not iframes) is complete
|
||||
fn TopLevelDomComplete(&self) -> u64 {
|
||||
self.document.get_top_level_dom_complete()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,4 +29,7 @@ interface PerformanceTiming {
|
|||
readonly attribute unsigned long long domComplete;
|
||||
readonly attribute unsigned long long loadEventStart;
|
||||
readonly attribute unsigned long long loadEventEnd;
|
||||
/* Servo-onnly attribute for measuring when the top-level document (not iframes) is complete. */
|
||||
[Pref="dom.testperf.enabled"]
|
||||
readonly attribute unsigned long long topLevelDomComplete;
|
||||
};
|
||||
|
|
|
@ -40195,6 +40195,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/window_performance_topLevelDomComplete.html": [
|
||||
[
|
||||
"/_mozilla/mozilla/window_performance_topLevelDomComplete.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/window_requestAnimationFrame.html": [
|
||||
[
|
||||
"/_mozilla/mozilla/window_requestAnimationFrame.html",
|
||||
|
@ -72342,6 +72348,10 @@
|
|||
"f03283e68b82d972ad21f674243070643ef89489",
|
||||
"testharness"
|
||||
],
|
||||
"mozilla/window_performance_topLevelDomComplete.html": [
|
||||
"4b953e63ffa6bf4ed1bc9a2baaea457d46502b9d",
|
||||
"testharness"
|
||||
],
|
||||
"mozilla/window_requestAnimationFrame.html": [
|
||||
"86310f3e4b88cce70ef92b56e4f65f034999096e",
|
||||
"testharness"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[window_performance_topLevelDomComplete.html]
|
||||
type: testharness
|
||||
prefs: [dom.testperf.enabled:true]
|
|
@ -0,0 +1,18 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Performance toLevelDomComplete</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
window.onload = t.step_func(function() {
|
||||
assert_true(performance.timing.domLoading <= performance.timing.topLevelDomComplete);
|
||||
assert_true(performance.timing.topLevelDomComplete <= performance.timing.domComplete);
|
||||
t.done();
|
||||
});
|
||||
}, "performance.topLevelDomComplete");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue