diff options
author | Iulian Gabriel Radu <iulian.radu67@gmail.com> | 2019-04-11 00:26:01 +0300 |
---|---|---|
committer | Iulian Gabriel Radu <iulian.radu67@gmail.com> | 2019-06-26 02:07:24 +0300 |
commit | 62f0785c2c042b809400c704eda7a76bae954b5a (patch) | |
tree | 1d5461e7f6dd116358c47cd1f3fc3117d8d8c783 | |
parent | e100af57a5bd95701b5310871e9909e3726539f0 (diff) | |
download | servo-62f0785c2c042b809400c704eda7a76bae954b5a.tar.gz servo-62f0785c2c042b809400c704eda7a76bae954b5a.zip |
Implement PerformanceNavigation interface
19 files changed, 411 insertions, 69 deletions
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 77729567558..3504925df4b 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -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; diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index 9dff17fd872..b29858fdca5 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -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()) diff --git a/components/script/dom/performancenavigation.rs b/components/script/dom/performancenavigation.rs new file mode 100644 index 00000000000..db93441480f --- /dev/null +++ b/components/script/dom/performancenavigation.rs @@ -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() + } +} diff --git a/components/script/dom/webidls/Performance.webidl b/components/script/dom/webidls/Performance.webidl index 45358ffa6e8..77bca4392e7 100644 --- a/components/script/dom/webidls/Performance.webidl +++ b/components/script/dom/webidls/Performance.webidl @@ -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; +}; diff --git a/components/script/dom/webidls/PerformanceNavigation.webidl b/components/script/dom/webidls/PerformanceNavigation.webidl new file mode 100644 index 00000000000..5a1ccba61f1 --- /dev/null +++ b/components/script/dom/webidls/PerformanceNavigation.webidl @@ -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(); +}; diff --git a/tests/wpt/metadata/navigation-timing/test_navigation_attributes_exist.html.ini b/tests/wpt/metadata/navigation-timing/test_navigation_attributes_exist.html.ini deleted file mode 100644 index d47a6bfcb85..00000000000 --- a/tests/wpt/metadata/navigation-timing/test_navigation_attributes_exist.html.ini +++ /dev/null @@ -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 - diff --git a/tests/wpt/metadata/navigation-timing/test_navigation_redirectCount_none.html.ini b/tests/wpt/metadata/navigation-timing/test_navigation_redirectCount_none.html.ini index 34f56001ffc..0de344264bf 100644 --- a/tests/wpt/metadata/navigation-timing/test_navigation_redirectCount_none.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_navigation_redirectCount_none.html.ini @@ -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 diff --git a/tests/wpt/metadata/navigation-timing/test_navigation_type_backforward.html.ini b/tests/wpt/metadata/navigation-timing/test_navigation_type_backforward.html.ini index 98fd693372b..b47a8dfdb2f 100644 --- a/tests/wpt/metadata/navigation-timing/test_navigation_type_backforward.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_navigation_type_backforward.html.ini @@ -1,6 +1,3 @@ [test_navigation_type_backforward.html] type: testharness - expected: ERROR - [window.performance.navigation is defined] - expected: FAIL - + expected: TIMEOUT diff --git a/tests/wpt/metadata/navigation-timing/test_navigation_type_enums.html.ini b/tests/wpt/metadata/navigation-timing/test_navigation_type_enums.html.ini deleted file mode 100644 index e2c56dcdfec..00000000000 --- a/tests/wpt/metadata/navigation-timing/test_navigation_type_enums.html.ini +++ /dev/null @@ -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 - diff --git a/tests/wpt/metadata/navigation-timing/test_navigation_type_reload.html.ini b/tests/wpt/metadata/navigation-timing/test_navigation_type_reload.html.ini index 6d68b802797..19a2f0b9e96 100644 --- a/tests/wpt/metadata/navigation-timing/test_navigation_type_reload.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_navigation_type_reload.html.ini @@ -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 diff --git a/tests/wpt/metadata/navigation-timing/test_no_previous_document.html.ini b/tests/wpt/metadata/navigation-timing/test_no_previous_document.html.ini index 765ffb343c3..26111407e01 100644 --- a/tests/wpt/metadata/navigation-timing/test_no_previous_document.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_no_previous_document.html.ini @@ -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 diff --git a/tests/wpt/metadata/navigation-timing/test_performance_attributes_exist.html.ini b/tests/wpt/metadata/navigation-timing/test_performance_attributes_exist.html.ini deleted file mode 100644 index 66bafed742d..00000000000 --- a/tests/wpt/metadata/navigation-timing/test_performance_attributes_exist.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[test_performance_attributes_exist.html] - type: testharness - [window.performance.navigation is defined] - expected: FAIL - diff --git a/tests/wpt/metadata/navigation-timing/test_timing_attributes_order.html.ini b/tests/wpt/metadata/navigation-timing/test_timing_attributes_order.html.ini index b4ee9f70984..be26635671a 100644 --- a/tests/wpt/metadata/navigation-timing/test_timing_attributes_order.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_timing_attributes_order.html.ini @@ -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 diff --git a/tests/wpt/metadata/navigation-timing/test_timing_client_redirect.html.ini b/tests/wpt/metadata/navigation-timing/test_timing_client_redirect.html.ini index 94efb582fc4..e5a480cbd83 100644 --- a/tests/wpt/metadata/navigation-timing/test_timing_client_redirect.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_timing_client_redirect.html.ini @@ -1,6 +1,3 @@ [test_timing_client_redirect.html] type: testharness expected: TIMEOUT - [window.performance.navigation is defined] - expected: FAIL - diff --git a/tests/wpt/metadata/navigation-timing/test_timing_reload.html.ini b/tests/wpt/metadata/navigation-timing/test_timing_reload.html.ini index 608445d0a20..b6734bbecef 100644 --- a/tests/wpt/metadata/navigation-timing/test_timing_reload.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_timing_reload.html.ini @@ -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 diff --git a/tests/wpt/metadata/navigation-timing/test_timing_server_redirect.html.ini b/tests/wpt/metadata/navigation-timing/test_timing_server_redirect.html.ini index e28454ea16e..6d844fb90ac 100644 --- a/tests/wpt/metadata/navigation-timing/test_timing_server_redirect.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_timing_server_redirect.html.ini @@ -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 diff --git a/tests/wpt/metadata/navigation-timing/test_timing_xserver_redirect.html.ini b/tests/wpt/metadata/navigation-timing/test_timing_xserver_redirect.html.ini index 2c689295522..b6c5e5c69cf 100644 --- a/tests/wpt/metadata/navigation-timing/test_timing_xserver_redirect.html.ini +++ b/tests/wpt/metadata/navigation-timing/test_timing_xserver_redirect.html.ini @@ -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 diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index c32bb3cf8d4..d28591485bb 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -18899,7 +18899,7 @@ "testharness" ], "mozilla/interfaces.html": [ - "b6cbf4b4f9b4fdcbe5f05a96970822d2ae9d325d", + "cb0317a6de33cc5283f3754bece13a3b04940423", "testharness" ], "mozilla/interfaces.js": [ diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html index b6cbf4b4f9b..cb0317a6de3 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.html +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html @@ -186,6 +186,7 @@ test_interfaces([ "PerformanceEntry", "PerformanceMark", "PerformanceMeasure", + "PerformanceNavigation", "PerformanceNavigationTiming", "PerformanceObserver", "PerformanceObserverEntryList", |