mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement PerformanceNavigation interface
This commit is contained in:
parent
e100af57a5
commit
62f0785c2c
19 changed files with 411 additions and 69 deletions
|
@ -428,6 +428,7 @@ pub mod performance;
|
|||
pub mod performanceentry;
|
||||
pub mod performancemark;
|
||||
pub mod performancemeasure;
|
||||
pub mod performancenavigation;
|
||||
pub mod performancenavigationtiming;
|
||||
pub mod performanceobserver;
|
||||
pub mod performanceobserverentrylist;
|
||||
|
|
|
@ -19,6 +19,7 @@ use crate::dom::globalscope::GlobalScope;
|
|||
use crate::dom::performanceentry::PerformanceEntry;
|
||||
use crate::dom::performancemark::PerformanceMark;
|
||||
use crate::dom::performancemeasure::PerformanceMeasure;
|
||||
use crate::dom::performancenavigation::PerformanceNavigation;
|
||||
use crate::dom::performancenavigationtiming::PerformanceNavigationTiming;
|
||||
use crate::dom::performanceobserver::PerformanceObserver as DOMPerformanceObserver;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -372,6 +373,11 @@ impl PerformanceMethods for Performance {
|
|||
unreachable!("Are we trying to expose Performance.timing in workers?");
|
||||
}
|
||||
|
||||
// https://w3c.github.io/navigation-timing/#dom-performance-navigation
|
||||
fn Navigation(&self) -> DomRoot<PerformanceNavigation> {
|
||||
PerformanceNavigation::new(&self.global())
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now
|
||||
fn Now(&self) -> DOMHighResTimeStamp {
|
||||
Finite::wrap(self.now())
|
||||
|
|
45
components/script/dom/performancenavigation.rs
Normal file
45
components/script/dom/performancenavigation.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::PerformanceNavigationBinding::{
|
||||
self, PerformanceNavigationConstants, PerformanceNavigationMethods,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct PerformanceNavigation {
|
||||
reflector_: Reflector,
|
||||
}
|
||||
|
||||
impl PerformanceNavigation {
|
||||
fn new_inherited() -> PerformanceNavigation {
|
||||
PerformanceNavigation {
|
||||
reflector_: Reflector::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalScope) -> DomRoot<PerformanceNavigation> {
|
||||
reflect_dom_object(
|
||||
Box::new(PerformanceNavigation::new_inherited()),
|
||||
global,
|
||||
PerformanceNavigationBinding::Wrap,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl PerformanceNavigationMethods for PerformanceNavigation {
|
||||
// https://w3c.github.io/navigation-timing/#dom-performancenavigation-type
|
||||
fn Type(&self) -> u16 {
|
||||
PerformanceNavigationConstants::TYPE_NAVIGATE
|
||||
}
|
||||
|
||||
// https://w3c.github.io/navigation-timing/#dom-performancenavigation-redirectcount
|
||||
fn RedirectCount(&self) -> u16 {
|
||||
self.global().as_window().Document().get_redirect_count()
|
||||
}
|
||||
}
|
|
@ -49,3 +49,8 @@ partial interface Performance {
|
|||
partial interface Performance {
|
||||
PerformanceNavigationTiming timing();
|
||||
};
|
||||
// https://w3c.github.io/navigation-timing/#extensions-to-the-performance-interface
|
||||
partial interface Performance {
|
||||
[SameObject, Exposed=Window]
|
||||
readonly attribute PerformanceNavigation navigation;
|
||||
};
|
||||
|
|
18
components/script/dom/webidls/PerformanceNavigation.webidl
Normal file
18
components/script/dom/webidls/PerformanceNavigation.webidl
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
/*
|
||||
* The origin of this IDL file is
|
||||
* https://w3c.github.io/navigation-timing/#the-performancenavigation-interface
|
||||
*/
|
||||
|
||||
[Exposed=Window]
|
||||
interface PerformanceNavigation {
|
||||
const unsigned short TYPE_NAVIGATE = 0;
|
||||
const unsigned short TYPE_RELOAD = 1;
|
||||
const unsigned short TYPE_BACK_FORWARD = 2;
|
||||
const unsigned short TYPE_RESERVED = 255;
|
||||
readonly attribute unsigned short type;
|
||||
readonly attribute unsigned short redirectCount;
|
||||
// [Default] object toJSON();
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
[test_navigation_attributes_exist.html]
|
||||
type: testharness
|
||||
[window.performance.navigation is defined]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.type is defined.]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.redirectCount is defined.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
[test_navigation_redirectCount_none.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
expected: FAIL
|
||||
|
||||
[timing.redirectStart on an non-redirected navigation]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
[test_navigation_type_backforward.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
expected: FAIL
|
||||
|
||||
expected: TIMEOUT
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
[test_navigation_type_enums.html]
|
||||
type: testharness
|
||||
[window.performance.navigation is defined]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_NAVIGATE is defined.]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_NAVIGATE = 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_RELOAD is defined.]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_RELOAD = 1]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_BACK_FORWARD is defined.]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_BACK_FORWARD = 2]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_RESERVED is defined.]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.TYPE_RESERVED = 255]
|
||||
expected: FAIL
|
||||
|
|
@ -1,6 +1,65 @@
|
|||
[test_navigation_type_reload.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
[Reload requestStart > Original requestStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload fetchStart > Original fetchStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domContentLoadedEventEnd > Original domContentLoadedEventEnd]
|
||||
expected: FAIL
|
||||
|
||||
[Reload redirectStart > Original redirectStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domLoading > Original domLoading]
|
||||
expected: FAIL
|
||||
|
||||
[Reload loadEventEnd > Original loadEventEnd]
|
||||
expected: FAIL
|
||||
|
||||
[Reload redirectEnd > Original redirectEnd]
|
||||
expected: FAIL
|
||||
|
||||
[Reload navigationStart > Original navigationStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domainLookupEnd > Original domainLookupEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.type == TYPE_RELOAD]
|
||||
expected: FAIL
|
||||
|
||||
[Reload connectStart > Original connectStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domContentLoadedEventStart > Original domContentLoadedEventStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domComplete > Original domComplete]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domainLookupStart > Original domainLookupStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload unloadEventEnd > Original unloadEventEnd]
|
||||
expected: FAIL
|
||||
|
||||
[Reload unloadEventStart > Original unloadEventStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload connectEnd > Original connectEnd]
|
||||
expected: FAIL
|
||||
|
||||
[Reload responseStart > Original responseStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload responseEnd > Original responseEnd]
|
||||
expected: FAIL
|
||||
|
||||
[Reload loadEventStart > Original loadEventStart]
|
||||
expected: FAIL
|
||||
|
||||
[Reload domInteractive > Original domInteractive]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
[test_no_previous_document.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
[timing.unloadEventEnd == 0 navigation with no previous document]
|
||||
expected: FAIL
|
||||
|
||||
[timing.unloadEventStart == 0 on navigation with no previous document]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[test_performance_attributes_exist.html]
|
||||
type: testharness
|
||||
[window.performance.navigation is defined]
|
||||
expected: FAIL
|
||||
|
|
@ -1,6 +1,164 @@
|
|||
[test_timing_attributes_order.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
[window.performance.timing.fetchStart difference with window.performance.timing.navigationStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.unloadEventStart difference with window.performance.timing.navigationStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.loadEventStart difference with window.performance.timing.domContentLoadedEventEnd is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.unloadEventEnd difference with window.performance.timing.unloadEventStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.requestStart difference with window.performance.timing.connectEnd is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.unloadEventStart >= window.performance.timing.navigationStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.loadEventEnd >= window.performance.timing.loadEventStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domainLookupEnd >= window.performance.timing.domainLookupStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domContentLoadedEventStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domLoading >= window.performance.timing.fetchStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.requestStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.fetchStart >= window.performance.timing.navigationStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domInteractive >= window.performance.timing.responseEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.navigationStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.loadEventEnd difference with window.performance.timing.loadEventStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectEnd == 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.responseEnd >= window.performance.timing.responseStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.connectStart difference with window.performance.timing.domainLookupEnd is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.unloadEventEnd >= window.performance.timing.unloadEventStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.connectStart >= window.performance.timing.domainLookupEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectStart == 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domInteractive difference with window.performance.timing.responseEnd is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domContentLoadedEventEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domainLookupEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domLoading > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domComplete >= window.performance.timing.domContentLoadedEventEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.connectEnd difference with window.performance.timing.connectStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.connectEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domContentLoadedEventEnd >= window.performance.timing.domContentLoadedEventStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domLoading difference with window.performance.timing.fetchStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.unloadEventStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domContentLoadedEventStart >= window.performance.timing.domInteractive]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.connectStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.responseEnd difference with window.performance.timing.responseStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.fetchStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domainLookupEnd difference with window.performance.timing.domainLookupStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.responseStart difference with window.performance.timing.requestStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domComplete difference with window.performance.timing.domContentLoadedEventEnd is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domContentLoadedEventEnd difference with window.performance.timing.domContentLoadedEventStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domainLookupStart >= window.performance.timing.fetchStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.responseEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.unloadEventEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domainLookupStart difference with window.performance.timing.fetchStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domainLookupStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domInteractive > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domContentLoadedEventStart difference with window.performance.timing.domInteractive is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.responseStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.responseStart >= window.performance.timing.requestStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.loadEventStart >= window.performance.timing.domContentLoadedEventEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.requestStart >= window.performance.timing.connectEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.connectEnd >= window.performance.timing.connectStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.domComplete > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.loadEventStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.loadEventEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
[test_timing_client_redirect.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[window.performance.navigation is defined]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +1,65 @@
|
|||
[test_timing_reload.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
[loadEventStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[domContentLoadedEventEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[domainLookupEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[unloadEventStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[responseStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[redirectStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[domComplete is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[redirectEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[loadEventEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[connectStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[domainLookupStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[navigationStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.navigation.type == TYPE_RELOAD]
|
||||
expected: FAIL
|
||||
|
||||
[domLoading is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[unloadEventEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[responseEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[connectEnd is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[fetchStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[domInteractive is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[domContentLoadedEventStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
[requestStart is different after the reload.]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +1,44 @@
|
|||
[test_timing_server_redirect.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
[navigation.redirectCount == 1 on an server redirected navigation]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.fetchStart >= window.performance.timing.redirectEnd]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.requestStart difference with window.performance.timing.fetchStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectStart >= window.performance.timing.navigationStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectEnd >= window.performance.timing.redirectStart]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectEnd difference with window.performance.timing.redirectStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectStart difference with window.performance.timing.navigationStart is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.fetchStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.navigationStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.requestStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.fetchStart difference with window.performance.timing.redirectEnd is 0 or at least 5 microseconds]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.redirectEnd > 0]
|
||||
expected: FAIL
|
||||
|
||||
[window.performance.timing.requestStart >= window.performance.timing.fetchStart]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
[test_timing_xserver_redirect.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
||||
[window.performance.navigation is defined]
|
||||
[window.performance.timing.navigationStart > 0]
|
||||
expected: FAIL
|
||||
|
||||
[timing.redirectStart == 0 on a server redirected navigation from another domain]
|
||||
expected: FAIL
|
||||
|
||||
[timing.redirectEnd == 0 on a server redirected navigation from another domain]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -18899,7 +18899,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"mozilla/interfaces.html": [
|
||||
"b6cbf4b4f9b4fdcbe5f05a96970822d2ae9d325d",
|
||||
"cb0317a6de33cc5283f3754bece13a3b04940423",
|
||||
"testharness"
|
||||
],
|
||||
"mozilla/interfaces.js": [
|
||||
|
|
|
@ -186,6 +186,7 @@ test_interfaces([
|
|||
"PerformanceEntry",
|
||||
"PerformanceMark",
|
||||
"PerformanceMeasure",
|
||||
"PerformanceNavigation",
|
||||
"PerformanceNavigationTiming",
|
||||
"PerformanceObserver",
|
||||
"PerformanceObserverEntryList",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue