summaryrefslogtreecommitdiff
path: root/dom/performance
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-04-06 21:06:47 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-04-10 18:22:54 +0800
commit65203af3dc042f8c152626088bde2427dcdd69fa (patch)
tree2ecbfe63db9b2eb6927454e3e7b06f0acfbd90a4 /dom/performance
parent19a7544fdf5f151bdd7a5307258f5aae16c8ee0c (diff)
downloaduxp-65203af3dc042f8c152626088bde2427dcdd69fa.tar.gz
Issue #2053 - Part 4a: Align IsPerformanceTimingAttribute to user-timing spec
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1772417
Diffstat (limited to 'dom/performance')
-rwxr-xr-xdom/performance/Performance.cpp22
-rw-r--r--dom/performance/Performance.h4
-rw-r--r--dom/performance/PerformanceMainThread.cpp22
-rw-r--r--dom/performance/PerformanceMainThread.h7
-rw-r--r--dom/performance/PerformanceMark.cpp3
5 files changed, 32 insertions, 26 deletions
diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
index f3523293a4..bf36707be8 100755
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -300,6 +300,28 @@ Performance::ClearMarks(const Optional<nsAString>& aName)
ClearUserEntries(aName, NS_LITERAL_STRING("mark"));
}
+// To be removed once bug 1124165 lands
+bool
+Performance::IsPerformanceTimingAttribute(const nsAString& aName) const
+{
+ // Note that toJSON is added to this list due to bug 1047848
+ static const char* attributes[] =
+ {"navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart",
+ "redirectEnd", "fetchStart", "domainLookupStart", "domainLookupEnd",
+ "connectStart", "secureConnectionStart", "connectEnd", "requestStart", "responseStart",
+ "responseEnd", "domLoading", "domInteractive",
+ "domContentLoadedEventStart", "domContentLoadedEventEnd", "domComplete",
+ "loadEventStart", "loadEventEnd", nullptr};
+
+ for (uint32_t i = 0; attributes[i]; ++i) {
+ if (aName.EqualsASCII(attributes[i])) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
DOMHighResTimeStamp
Performance::ConvertMarkToTimestampWithString(const nsAString& aName,
ErrorResult& aRv)
diff --git a/dom/performance/Performance.h b/dom/performance/Performance.h
index 6bdd42a8e8..75d164c214 100644
--- a/dom/performance/Performance.h
+++ b/dom/performance/Performance.h
@@ -117,7 +117,9 @@ public:
virtual nsITimedChannel* GetChannel() const = 0;
- virtual bool IsPerformanceTimingAttribute(const nsAString& aName)
+ bool IsPerformanceTimingAttribute(const nsAString& aName) const;
+
+ virtual bool IsGlobalObjectWindow() const
{
return false;
}
diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
index acb69ea358..a4dbf88799 100644
--- a/dom/performance/PerformanceMainThread.cpp
+++ b/dom/performance/PerformanceMainThread.cpp
@@ -177,28 +177,6 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel,
}
}
-// To be removed once bug 1124165 lands
-bool
-PerformanceMainThread::IsPerformanceTimingAttribute(const nsAString& aName)
-{
- // Note that toJSON is added to this list due to bug 1047848
- static const char* attributes[] =
- {"navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart",
- "redirectEnd", "fetchStart", "domainLookupStart", "domainLookupEnd",
- "connectStart", "secureConnectionStart", "connectEnd", "requestStart", "responseStart",
- "responseEnd", "domLoading", "domInteractive",
- "domContentLoadedEventStart", "domContentLoadedEventEnd", "domComplete",
- "loadEventStart", "loadEventEnd", nullptr};
-
- for (uint32_t i = 0; attributes[i]; ++i) {
- if (aName.EqualsASCII(attributes[i])) {
- return true;
- }
- }
-
- return false;
-}
-
DOMHighResTimeStamp
PerformanceMainThread::GetPerformanceTimingFromString(const nsAString& aProperty)
{
diff --git a/dom/performance/PerformanceMainThread.h b/dom/performance/PerformanceMainThread.h
index 35fd4ab0e2..702483e9de 100644
--- a/dom/performance/PerformanceMainThread.h
+++ b/dom/performance/PerformanceMainThread.h
@@ -57,6 +57,11 @@ public:
const Optional<nsAString>& aEntryType,
nsTArray<RefPtr<PerformanceEntry>>& aRetval) override;
+ bool IsGlobalObjectWindow() const override
+ {
+ return true;
+ }
+
protected:
~PerformanceMainThread();
@@ -67,8 +72,6 @@ protected:
void InsertUserEntry(PerformanceEntry* aEntry) override;
- bool IsPerformanceTimingAttribute(const nsAString& aName) override;
-
DOMHighResTimeStamp
GetPerformanceTimingFromString(const nsAString& aTimingName) override;
diff --git a/dom/performance/PerformanceMark.cpp b/dom/performance/PerformanceMark.cpp
index cd6d1bb39d..bf8d930c5d 100644
--- a/dom/performance/PerformanceMark.cpp
+++ b/dom/performance/PerformanceMark.cpp
@@ -52,7 +52,8 @@ already_AddRefed<PerformanceMark> PerformanceMark::Constructor(
return nullptr;
}
- if (performance->IsPerformanceTimingAttribute(aMarkName)) {
+ if (performance->IsGlobalObjectWindow() &&
+ performance->IsPerformanceTimingAttribute(aMarkName)) {
aRv.ThrowTypeError<MSG_PMO_INVALID_TIMING_ATTR>();
return nullptr;
}