Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Unified Diff: third_party/WebKit/Source/core/timing/Performance.cpp

Issue 2553493003: Add more detail to same-origin attribution indicating self|ancestor|descendant (Closed)
Patch Set: update layout test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/timing/Performance.cpp
diff --git a/third_party/WebKit/Source/core/timing/Performance.cpp b/third_party/WebKit/Source/core/timing/Performance.cpp
index dc017d37dfcfcce2775ac3eb87e89fd0bbbacab9..7137b1a18193c88bebab5984ea8c3bb4c291ef9a 100644
--- a/third_party/WebKit/Source/core/timing/Performance.cpp
+++ b/third_party/WebKit/Source/core/timing/Performance.cpp
@@ -48,8 +48,12 @@ static const double kLongTaskThreshold = 0.05;
static const char kUnknownAttribution[] = "unknown";
static const char kAmbiguousAttribution[] = "multiple-contexts";
static const char kSameOriginAttribution[] = "same-origin";
-static const char kAncestorAttribution[] = "cross-origin-ancestor";
-static const char kDescendantAttribution[] = "cross-origin-descendant";
+static const char kSameOriginSelfAttribution[] = "same-origin-self";
+static const char kSameOriginAncestorAttribution[] = "same-origin-ancestor";
+static const char kSameOriginDescendantAttribution[] = "same-origin-descendant";
+static const char kCrossOriginAncestorAttribution[] = "cross-origin-ancestor";
+static const char kCrossOriginDescendantAttribution[] =
+ "cross-origin-descendant";
static const char kCrossOriginAttribution[] = "cross-origin-unreachable";
namespace blink {
@@ -68,6 +72,16 @@ String getFrameAttribute(HTMLFrameOwnerElement* frameOwner,
return attrValue;
}
+const char* sameOriginAttribution(Frame* observerFrame, Frame* culpritFrame) {
+ if (observerFrame == culpritFrame)
+ return kSameOriginSelfAttribution;
+ if (observerFrame->tree().isDescendantOf(culpritFrame))
+ return kSameOriginAncestorAttribution;
+ if (culpritFrame->tree().isDescendantOf(observerFrame))
+ return kSameOriginDescendantAttribution;
+ return kSameOriginAttribution;
+}
+
} // namespace
static double toTimeOrigin(LocalFrame* frame) {
@@ -185,7 +199,8 @@ std::pair<String, DOMWindow*> Performance::sanitizedAttribution(
DCHECK(culpritFrame);
if (canAccessOrigin(observerFrame, culpritFrame)) {
// From accessible frames or same origin, return culprit location URL.
- return std::make_pair(kSameOriginAttribution, culpritFrame->domWindow());
+ return std::make_pair(sameOriginAttribution(observerFrame, culpritFrame),
+ culpritFrame->domWindow());
}
// For cross-origin, if the culprit is the descendant or ancestor of
// observer then indicate the *closest* cross-origin frame between
@@ -202,11 +217,11 @@ std::pair<String, DOMWindow*> Performance::sanitizedAttribution(
lastCrossOriginFrame = frame;
}
}
- return std::make_pair(kDescendantAttribution,
+ return std::make_pair(kCrossOriginDescendantAttribution,
lastCrossOriginFrame->domWindow());
}
if (observerFrame->tree().isDescendantOf(culpritFrame)) {
- return std::make_pair(kAncestorAttribution, nullptr);
+ return std::make_pair(kCrossOriginAncestorAttribution, nullptr);
}
return std::make_pair(kCrossOriginAttribution, nullptr);
}

Powered by Google App Engine
This is Rietveld 408576698