Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / performance / PerformanceNavigationTiming.h
blob2a10b345813e4969c40a7d77a1d5bb1a8991255b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_PerformanceNavigationTiming_h___
8 #define mozilla_dom_PerformanceNavigationTiming_h___
10 #include <stdint.h>
11 #include <utility>
12 #include "js/RootingAPI.h"
13 #include "mozilla/UniquePtr.h"
14 #include "mozilla/dom/PerformanceNavigationTimingBinding.h"
15 #include "mozilla/dom/PerformanceResourceTiming.h"
16 #include "nsDOMNavigationTiming.h"
17 #include "nsISupports.h"
18 #include "nsLiteralString.h"
19 #include "nsString.h"
20 #include "nsTLiteralString.h"
22 class JSObject;
23 class nsIHttpChannel;
24 class nsITimedChannel;
25 struct JSContext;
27 namespace mozilla::dom {
29 class Performance;
30 class PerformanceTimingData;
32 // https://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming
33 class PerformanceNavigationTiming final : public PerformanceResourceTiming {
34 public:
35 NS_DECL_ISUPPORTS_INHERITED
37 // Note that aPerformanceTiming must be initalized with zeroTime = 0
38 // so that timestamps are relative to startTime, as opposed to the
39 // performance.timing object for which timestamps are absolute and has a
40 // zeroTime initialized to navigationStart
41 // aPerformanceTiming and aPerformance must be non-null.
42 PerformanceNavigationTiming(
43 UniquePtr<PerformanceTimingData>&& aPerformanceTiming,
44 Performance* aPerformance, const nsAString& aName)
45 : PerformanceResourceTiming(std::move(aPerformanceTiming), aPerformance,
46 aName) {
47 SetEntryType(u"navigation"_ns);
48 SetInitiatorType(u"navigation"_ns);
51 DOMHighResTimeStamp Duration() const override {
52 return LoadEventEnd() - StartTime();
55 DOMHighResTimeStamp StartTime() const override { return 0; }
57 JSObject* WrapObject(JSContext* aCx,
58 JS::Handle<JSObject*> aGivenProto) override;
60 DOMHighResTimeStamp UnloadEventStart() const;
61 DOMHighResTimeStamp UnloadEventEnd() const;
63 DOMHighResTimeStamp DomInteractive() const;
64 DOMHighResTimeStamp DomContentLoadedEventStart() const;
65 DOMHighResTimeStamp DomContentLoadedEventEnd() const;
66 DOMHighResTimeStamp DomComplete() const;
67 DOMHighResTimeStamp LoadEventStart() const;
68 DOMHighResTimeStamp LoadEventEnd() const;
70 DOMHighResTimeStamp RedirectStart(
71 nsIPrincipal& aSubjectPrincipal) const override;
72 DOMHighResTimeStamp RedirectEnd(
73 nsIPrincipal& aSubjectPrincipal) const override;
75 NavigationType Type() const;
76 uint16_t RedirectCount() const;
78 void UpdatePropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel,
79 nsITimedChannel* aChannel);
82 * For use with the WebIDL Func attribute to determine whether
83 * window.PerformanceNavigationTiming is exposed.
85 static bool Enabled(JSContext* aCx, JSObject* aGlobal);
87 private:
88 ~PerformanceNavigationTiming() = default;
91 } // namespace mozilla::dom
93 #endif // mozilla_dom_PerformanceNavigationTiming_h___