| Index: third_party/WebKit/Source/core/timing/PerformanceTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/timing/PerformanceTest.cpp b/third_party/WebKit/Source/core/timing/PerformanceTest.cpp
|
| index 8a7bc32b34f7b681871649146d9c2f252829c246..5f2807cca69cd9983d6ef8ad54a45b481fbab9d8 100644
|
| --- a/third_party/WebKit/Source/core/timing/PerformanceTest.cpp
|
| +++ b/third_party/WebKit/Source/core/timing/PerformanceTest.cpp
|
| @@ -16,6 +16,11 @@ class PerformanceTest : public ::testing::Test {
|
| m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
|
| m_pageHolder->document().setURL(KURL(KURL(), "https://example.com"));
|
| m_performance = Performance::create(&m_pageHolder->frame());
|
| +
|
| + // 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"));
|
| }
|
|
|
| bool observingLongTasks() {
|
| @@ -33,8 +38,20 @@ class PerformanceTest : public ::testing::Test {
|
| m_performance->m_observerFilterOptions = PerformanceEntry::Invalid;
|
| }
|
|
|
| + LocalFrame* frame() const { return m_pageHolder->document().frame(); }
|
| +
|
| + LocalFrame* anotherFrame() const {
|
| + return m_anotherPageHolder->document().frame();
|
| + }
|
| +
|
| + String sanitizedAttribution(const HeapHashSet<Member<Frame>>& frames,
|
| + Frame* observerFrame) {
|
| + return Performance::sanitizedAttribution(frames, observerFrame).first;
|
| + }
|
| +
|
| Persistent<Performance> m_performance;
|
| std::unique_ptr<DummyPageHolder> m_pageHolder;
|
| + std::unique_ptr<DummyPageHolder> m_anotherPageHolder;
|
| };
|
|
|
| TEST_F(PerformanceTest, LongTaskObserverInstrumentation) {
|
| @@ -51,4 +68,29 @@ TEST_F(PerformanceTest, LongTaskObserverInstrumentation) {
|
| m_performance->updateLongTaskInstrumentation();
|
| EXPECT_FALSE(observingLongTasks());
|
| }
|
| +
|
| +TEST_F(PerformanceTest, SanitizedLongTaskName) {
|
| + HeapHashSet<Member<Frame>> frameContexts;
|
| + // Unable to attribute, when no execution contents are available.
|
| + EXPECT_EQ("unknown", sanitizedAttribution(frameContexts, frame()));
|
| +
|
| + // Attribute for same context (and same origin).
|
| + frameContexts.add(frame());
|
| + EXPECT_EQ("same-origin", sanitizedAttribution(frameContexts, frame()));
|
| +
|
| + // Unable to attribute, when multiple script execution contents are involved.
|
| + frameContexts.add(anotherFrame());
|
| + EXPECT_EQ("multiple-contexts", sanitizedAttribution(frameContexts, frame()));
|
| +}
|
| +
|
| +TEST_F(PerformanceTest, SanitizedLongTaskName_CrossOrigin) {
|
| + HeapHashSet<Member<Frame>> frameContexts;
|
| + // Unable to attribute, when no execution contents are available.
|
| + EXPECT_EQ("unknown", sanitizedAttribution(frameContexts, frame()));
|
| +
|
| + // Attribute for same context (and same origin).
|
| + frameContexts.add(anotherFrame());
|
| + EXPECT_EQ("cross-origin-unreachable",
|
| + sanitizedAttribution(frameContexts, frame()));
|
| +}
|
| }
|
|
|