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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp

Issue 2449673002: Refactor InspectorWebPerfAgent: update lifecycle management to be per Local Frame root; replace hea… (Closed)
Patch Set: Update unittests Created 4 years, 1 month 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/inspector/InspectorWebPerfAgentTest.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp
index ba29066fe0013a71b59187dfea7e6cb6be320381..fd2fbc49e58917737fe69278e127643c1e7140ba 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp
@@ -4,6 +4,7 @@
#include "core/inspector/InspectorWebPerfAgent.h"
+#include "core/frame/LocalFrame.h"
#include "core/frame/Location.h"
#include "core/inspector/InspectedFrames.h"
#include "core/testing/DummyPageHolder.h"
@@ -31,11 +32,9 @@ class InspectorWebPerfAgentTest : public ::testing::Test {
String frameContextURL();
int numUniqueFrameContextsSeen();
- String sanitizedLongTaskName(
- HeapHashSet<Member<Location>> frameContextLocations,
- Frame* rootFrame) {
- return m_agent->sanitizedAttribution(frameContextLocations, rootFrame)
- .first;
+ String sanitizedLongTaskName(HeapHashSet<Member<Frame>> frameContexts,
+ Frame* observerFrame) {
+ return m_agent->sanitizedAttribution(frameContexts, observerFrame).first;
}
Persistent<InspectorWebPerfAgent> m_agent;
@@ -46,7 +45,7 @@ class InspectorWebPerfAgentTest : public ::testing::Test {
void InspectorWebPerfAgentTest::SetUp() {
m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
m_pageHolder->document().setURL(KURL(KURL(), "https://example.com/foo"));
- m_agent = new InspectorWebPerfAgent(frame());
+ m_agent = new InspectorWebPerfAgent(InspectedFrames::create(frame()));
// Create another dummy page holder and pretend this is the iframe.
m_anotherPageHolder = DummyPageHolder::create(IntSize(400, 300));
@@ -56,14 +55,14 @@ void InspectorWebPerfAgentTest::SetUp() {
String InspectorWebPerfAgentTest::frameContextURL() {
// This is reported only if there is a single frameContext URL.
- if (m_agent->m_frameContextLocations.size() != 1)
+ if (m_agent->m_frameContexts.size() != 1)
return "";
- Location* location = (*m_agent->m_frameContextLocations.begin()).get();
- return location->href();
+ Frame* frame = (*m_agent->m_frameContexts.begin()).get();
+ return toLocalFrame(frame)->document()->location()->href();
}
int InspectorWebPerfAgentTest::numUniqueFrameContextsSeen() {
- return m_agent->m_frameContextLocations.size();
+ return m_agent->m_frameContexts.size();
}
TEST_F(InspectorWebPerfAgentTest, SingleScriptInTask) {
@@ -130,30 +129,28 @@ TEST_F(InspectorWebPerfAgentTest, NoScriptInLongTask) {
}
TEST_F(InspectorWebPerfAgentTest, SanitizedLongTaskName) {
- HeapHashSet<Member<Location>> frameContextLocations;
+ HeapHashSet<Member<Frame>> frameContexts;
// Unable to attribute, when no execution contents are available.
- EXPECT_EQ("unknown", sanitizedLongTaskName(frameContextLocations, frame()));
+ EXPECT_EQ("unknown", sanitizedLongTaskName(frameContexts, frame()));
// Attribute for same context (and same origin).
- frameContextLocations.add(Location::create(frame()));
- EXPECT_EQ("same-origin",
- sanitizedLongTaskName(frameContextLocations, frame()));
+ frameContexts.add(frame());
+ EXPECT_EQ("same-origin", sanitizedLongTaskName(frameContexts, frame()));
// Unable to attribute, when multiple script execution contents are involved.
- frameContextLocations.add(Location::create(frame()));
- EXPECT_EQ("multiple-contexts",
- sanitizedLongTaskName(frameContextLocations, frame()));
+ frameContexts.add(anotherFrame());
+ EXPECT_EQ("multiple-contexts", sanitizedLongTaskName(frameContexts, frame()));
}
TEST_F(InspectorWebPerfAgentTest, SanitizedLongTaskName_CrossOrigin) {
- HeapHashSet<Member<Location>> frameContextLocations;
+ HeapHashSet<Member<Frame>> frameContexts;
// Unable to attribute, when no execution contents are available.
- EXPECT_EQ("unknown", sanitizedLongTaskName(frameContextLocations, frame()));
+ EXPECT_EQ("unknown", sanitizedLongTaskName(frameContexts, frame()));
// Attribute for same context (and same origin).
- frameContextLocations.add(Location::create(anotherFrame()));
+ frameContexts.add(anotherFrame());
EXPECT_EQ("cross-origin-unreachable",
- sanitizedLongTaskName(frameContextLocations, frame()));
+ sanitizedLongTaskName(frameContexts, frame()));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698