Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| index 190c5c7e242c96804b85905e39ea7b9278c24185..029e45da5e81e74c242429429521fd8f94219a51 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| @@ -10655,4 +10655,48 @@ TEST_F(WebFrameTest, UniqueNames) { |
| EXPECT_EQ(10u, names.size()); |
| } |
| +TEST_F(WebFrameTest, RequestorURL) { |
| + registerMockedHttpURLLoad("single_iframe.html"); |
| + registerMockedHttpURLLoad("visible_iframe.html"); |
| + |
| + class RequestorURLTrackingClient |
| + : public FrameTestHelpers::TestWebFrameClient { |
| + public: |
| + // WebFrameClient overrides: |
| + void didCommitProvisionalLoad(WebLocalFrame* frame, |
| + const WebHistoryItem&, |
| + WebHistoryCommitType) override { |
| + m_trackedFrames.add(frame, frame->dataSource()->requestorURL()); |
| + } |
| + |
| + WebURL requestorURLForFrame(WebLocalFrame* frame) { |
| + return m_trackedFrames.get(frame); |
| + } |
| + |
| + private: |
| + HashMap<WebLocalFrame*, WebURL> m_trackedFrames; |
| + }; |
| + |
| + RequestorURLTrackingClient trackingClient; |
| + |
| + FrameTestHelpers::WebViewHelper webViewHelper; |
| + webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, |
| + &trackingClient); |
| + |
| + WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
| + WebLocalFrameImpl* subFrame = toWebLocalFrameImpl(mainFrame->firstChild()); |
| + |
| + // The main frame should have no requestor URL. |
|
Mike West
2016/11/23 11:11:20
Should the main frame have a requestor URL during
dcheng
2016/11/23 14:41:44
Done.
|
| + EXPECT_EQ(WebURL(), trackingClient.requestorURLForFrame(mainFrame)); |
| + // The sub frame should have the main frame's URL as the requestor URL. |
| + EXPECT_EQ(WebURL(mainFrame->frame()->document()->url()), |
| + trackingClient.requestorURLForFrame(subFrame)); |
| + |
| + // Once the load has committed, the requestor URL should no longer be |
| + // accessible, to avoid keeping potentially unreachable Documents alive. |
| + EXPECT_EQ(WebURL(), subFrame->dataSource()->requestorURL()); |
| + |
| + webViewHelper.reset(); |
| +} |
| + |
| } // namespace blink |