Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10648 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); | 10648 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); |
| 10649 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); | 10649 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); |
| 10650 HashSet<AtomicString> names; | 10650 HashSet<AtomicString> names; |
| 10651 for (Frame* frame = mainFrame->tree().firstChild(); frame; | 10651 for (Frame* frame = mainFrame->tree().firstChild(); frame; |
| 10652 frame = frame->tree().traverseNext()) { | 10652 frame = frame->tree().traverseNext()) { |
| 10653 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); | 10653 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); |
| 10654 } | 10654 } |
| 10655 EXPECT_EQ(10u, names.size()); | 10655 EXPECT_EQ(10u, names.size()); |
| 10656 } | 10656 } |
| 10657 | 10657 |
| 10658 TEST_F(WebFrameTest, RequestorURL) { | |
| 10659 registerMockedHttpURLLoad("single_iframe.html"); | |
| 10660 registerMockedHttpURLLoad("visible_iframe.html"); | |
| 10661 | |
| 10662 class RequestorURLTrackingClient | |
| 10663 : public FrameTestHelpers::TestWebFrameClient { | |
| 10664 public: | |
| 10665 // WebFrameClient overrides: | |
| 10666 void didCommitProvisionalLoad(WebLocalFrame* frame, | |
| 10667 const WebHistoryItem&, | |
| 10668 WebHistoryCommitType) override { | |
| 10669 m_trackedFrames.add(frame, frame->dataSource()->requestorURL()); | |
| 10670 } | |
| 10671 | |
| 10672 WebURL requestorURLForFrame(WebLocalFrame* frame) { | |
| 10673 return m_trackedFrames.get(frame); | |
| 10674 } | |
| 10675 | |
| 10676 private: | |
| 10677 HashMap<WebLocalFrame*, WebURL> m_trackedFrames; | |
| 10678 }; | |
| 10679 | |
| 10680 RequestorURLTrackingClient trackingClient; | |
| 10681 | |
| 10682 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 10683 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, | |
| 10684 &trackingClient); | |
| 10685 | |
| 10686 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | |
| 10687 WebLocalFrameImpl* subFrame = toWebLocalFrameImpl(mainFrame->firstChild()); | |
| 10688 | |
| 10689 // 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.
| |
| 10690 EXPECT_EQ(WebURL(), trackingClient.requestorURLForFrame(mainFrame)); | |
| 10691 // The sub frame should have the main frame's URL as the requestor URL. | |
| 10692 EXPECT_EQ(WebURL(mainFrame->frame()->document()->url()), | |
| 10693 trackingClient.requestorURLForFrame(subFrame)); | |
| 10694 | |
| 10695 // Once the load has committed, the requestor URL should no longer be | |
| 10696 // accessible, to avoid keeping potentially unreachable Documents alive. | |
| 10697 EXPECT_EQ(WebURL(), subFrame->dataSource()->requestorURL()); | |
| 10698 | |
| 10699 webViewHelper.reset(); | |
| 10700 } | |
| 10701 | |
| 10658 } // namespace blink | 10702 } // namespace blink |
| OLD | NEW |