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

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

Issue 2385873003: attempt at iframe unittest
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 066e35ba5fabba1a789e8daa14479f47dd0a5391..634aa72310ee8cff2acb322c32d4f7fdef92f7ce 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgentTest.cpp
@@ -10,18 +10,53 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/PtrUtil.h"
+#include "core/loader/EmptyClients.h"
+#include "core/frame/FrameOwner.h"
+#include "core/frame/FrameView.h"
+#include "core/loader/DocumentLoader.h"
+#include "platform/network/ResourceRequest.h"
+#include "core/fetch/SubstituteData.h"
+
#include <memory>
namespace blink {
+class StubFrameLoaderClientWithParent final : public EmptyFrameLoaderClient {
+public:
+ static StubFrameLoaderClientWithParent* create(Frame* parent)
+ {
+ return new StubFrameLoaderClientWithParent(parent);
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ visitor->trace(m_parent);
+ EmptyFrameLoaderClient::trace(visitor);
+ }
+
+ Frame* parent() const override { return m_parent.get(); }
+
+private:
+ explicit StubFrameLoaderClientWithParent(Frame* parent)
+ : m_parent(parent)
+ {
+ }
+
+ Member<Frame> m_parent;
+};
+
class InspectorWebPerfAgentTest : public ::testing::Test {
protected:
void SetUp() override;
+ void TearDown() override;
+ Document& document() const { return m_pageHolder->document(); }
LocalFrame* frame() const { return m_pageHolder->document().frame(); }
ExecutionContext* executionContext() const { return &m_pageHolder->document(); }
LocalFrame* anotherFrame() const { return m_anotherPageHolder->document().frame(); }
ExecutionContext* anotherExecutionContext() const { return &m_anotherPageHolder->document(); }
+ LocalFrame* makeChildIframe();
+
String frameContextURL();
int numUniqueFrameContextsSeen();
@@ -33,6 +68,11 @@ protected:
Persistent<InspectorWebPerfAgent> m_agent;
std::unique_ptr<DummyPageHolder> m_pageHolder;
std::unique_ptr<DummyPageHolder> m_anotherPageHolder;
+
+ Persistent<DummyFrameOwner> owner;
+ Persistent<StubFrameLoaderClientWithParent> m_childFrameLoaderClient;
+ Persistent<LocalFrame> m_childIframe;
+ Persistent<DocumentLoader> m_childDocumentLoader;
};
void InspectorWebPerfAgentTest::SetUp()
@@ -44,6 +84,30 @@ void InspectorWebPerfAgentTest::SetUp()
// Create another dummy page holder and pretend this is the iframe.
m_anotherPageHolder = DummyPageHolder::create(IntSize(400, 300));
m_anotherPageHolder->document().setURL(KURL(KURL(), "https://iframed.com/bar"));
+
+ owner = DummyFrameOwner::create();
+}
+
+void InspectorWebPerfAgentTest::TearDown()
+{
+ if (m_childIframe) {
+ m_childDocumentLoader->detachFromFrame();
+ m_childDocumentLoader.clear();
+ m_childIframe->detach(FrameDetachType::Remove);
+ }
+}
+
+LocalFrame* InspectorWebPerfAgentTest::makeChildIframe()
+{
+ m_childFrameLoaderClient = StubFrameLoaderClientWithParent::create(frame());
+ m_childIframe = LocalFrame::create(
+ m_childFrameLoaderClient.get(), frame()->host(), owner);
+ m_childIframe->setView(FrameView::create(m_childIframe.get(), IntSize(500, 500)));
+ m_childIframe->init();
+ m_childDocumentLoader = DocumentLoader::create(
+ m_childIframe.get(), ResourceRequest("http://www.iframed.com/bar"), SubstituteData());
+ //m_childIframe->document()->setBaseURLOverride(KURL(KURL(), "http://www.iframed.com/bar"));
+ return m_childIframe.get();
}
String InspectorWebPerfAgentTest::frameContextURL()
@@ -141,4 +205,16 @@ TEST_F(InspectorWebPerfAgentTest, SanitizedLongTaskName)
sanitizedLongTaskName(frameContextLocations, frame()));
}
+TEST_F(InspectorWebPerfAgentTest, SanitizedLongTaskName_CrossOriginChildIframe)
+{
+ HeapHashSet<Member<Location>> frameContextLocations;
+ // Unable to attribute, when no execution contents are available.
+ EXPECT_EQ("unknown",
+ sanitizedLongTaskName(frameContextLocations, frame()));
+
+ frameContextLocations.add(Location::create(makeChildIframe()));
+ EXPECT_EQ("cross-origin",
+ sanitizedLongTaskName(frameContextLocations, frame()));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698