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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2416523002: Expose the initiating origin/URL of a navigation in the Blink public API (Closed)
Patch Set: Use less memory, add tests, etc. 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/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

Powered by Google App Engine
This is Rietveld 408576698