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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 339593005: Set the target type when creating the request for main resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Made the setter method private Created 6 years, 6 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 unified diff | Download patch
OLDNEW
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 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 } 2722 }
2723 2723
2724 TEST_F(WebFrameTest, ReloadWhileProvisional) 2724 TEST_F(WebFrameTest, ReloadWhileProvisional)
2725 { 2725 {
2726 // Test that reloading while the previous load is still pending does not cau se the initial 2726 // Test that reloading while the previous load is still pending does not cau se the initial
2727 // request to get lost. 2727 // request to get lost.
2728 registerMockedHttpURLLoad("fixed_layout.html"); 2728 registerMockedHttpURLLoad("fixed_layout.html");
2729 2729
2730 FrameTestHelpers::WebViewHelper webViewHelper; 2730 FrameTestHelpers::WebViewHelper webViewHelper;
2731 webViewHelper.initialize(); 2731 webViewHelper.initialize();
2732 WebURLRequest request; 2732 WebURLRequest request(toKURL(m_baseURL + "fixed_layout.html"), true, true);
2733 request.initialize();
2734 request.setURL(toKURL(m_baseURL + "fixed_layout.html"));
2735 webViewHelper.webView()->mainFrame()->loadRequest(request); 2733 webViewHelper.webView()->mainFrame()->loadRequest(request);
2736 // start reload before first request is delivered. 2734 // start reload before first request is delivered.
2737 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram e()); 2735 FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFram e());
2738 2736
2739 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource (); 2737 WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource ();
2740 ASSERT_TRUE(dataSource); 2738 ASSERT_TRUE(dataSource);
2741 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->reques t().url().spec())); 2739 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->reques t().url().spec()));
2742 } 2740 }
2743 2741
2744 TEST_F(WebFrameTest, AppendRedirects) 2742 TEST_F(WebFrameTest, AppendRedirects)
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
4789 TestNavigationPolicyWebFrameClient client; 4787 TestNavigationPolicyWebFrameClient client;
4790 FrameTestHelpers::WebViewHelper webViewHelper; 4788 FrameTestHelpers::WebViewHelper webViewHelper;
4791 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue, &client); 4789 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue, &client);
4792 4790
4793 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page ()->mainFrame())->document(); 4791 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page ()->mainFrame())->document();
4794 WebCore::KURL destination = document->url(); 4792 WebCore::KURL destination = document->url();
4795 destination.setFragmentIdentifier("test"); 4793 destination.setFragmentIdentifier("test");
4796 4794
4797 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo re::EventTypeNames::click, false, false, 4795 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo re::EventTypeNames::click, false, false,
4798 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 1, nullptr, nullptr); 4796 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 1, nullptr, nullptr);
4799 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de stination)); 4797 WebCore::ResourceRequest resourceRequest = WebCore::ResourceRequest::createM ainResourceRequest(
4798 destination, true);
4799 WebCore::FrameLoadRequest frameRequest(document, resourceRequest);
4800 frameRequest.setTriggeringEvent(event); 4800 frameRequest.setTriggeringEvent(event);
4801 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 4801 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest);
4802 } 4802 }
4803 4803
4804 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { 4804 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient {
4805 public: 4805 public:
4806 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW indowFeatures&, 4806 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW indowFeatures&,
4807 const WebString&, WebNavigationPolicy, bool) OVERRIDE 4807 const WebString&, WebNavigationPolicy, bool) OVERRIDE
4808 { 4808 {
4809 EXPECT_TRUE(false); 4809 EXPECT_TRUE(false);
(...skipping 29 matching lines...) Expand all
4839 TestNewWindowWebFrameClient webFrameClient; 4839 TestNewWindowWebFrameClient webFrameClient;
4840 FrameTestHelpers::WebViewHelper webViewHelper; 4840 FrameTestHelpers::WebViewHelper webViewHelper;
4841 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra meClient, &webViewClient); 4841 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra meClient, &webViewClient);
4842 4842
4843 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page ()->mainFrame())->document(); 4843 WebCore::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page ()->mainFrame())->document();
4844 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html"); 4844 WebCore::KURL destination = toKURL(m_baseURL + "hello_world.html");
4845 4845
4846 // ctrl+click event 4846 // ctrl+click event
4847 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo re::EventTypeNames::click, false, false, 4847 RefPtrWillBeRawPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCo re::EventTypeNames::click, false, false,
4848 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0 , nullptr, nullptr); 4848 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0 , nullptr, nullptr);
4849 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de stination)); 4849 WebCore::ResourceRequest resourceRequest = WebCore::ResourceRequest::createM ainResourceRequest(
4850 destination, true);
4851 WebCore::FrameLoadRequest frameRequest(document, resourceRequest);
4850 frameRequest.setTriggeringEvent(event); 4852 frameRequest.setTriggeringEvent(event);
4851 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu re); 4853 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu re);
4852 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 4854 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest);
4853 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF rame()); 4855 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF rame());
4854 4856
4855 // decidePolicyForNavigation should be called both for the original request and the ctrl+click. 4857 // decidePolicyForNavigation should be called both for the original request and the ctrl+click.
4856 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); 4858 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount());
4857 } 4859 }
4858 4860
4859 TEST_F(WebFrameTest, BackToReload) 4861 TEST_F(WebFrameTest, BackToReload)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 }; 5051 };
5050 5052
5051 TEST_F(WebFrameTest, NavigateToSame) 5053 TEST_F(WebFrameTest, NavigateToSame)
5052 { 5054 {
5053 registerMockedHttpURLLoad("navigate_to_same.html"); 5055 registerMockedHttpURLLoad("navigate_to_same.html");
5054 TestSameDocumentWebFrameClient client; 5056 TestSameDocumentWebFrameClient client;
5055 FrameTestHelpers::WebViewHelper webViewHelper; 5057 FrameTestHelpers::WebViewHelper webViewHelper;
5056 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, & client); 5058 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, & client);
5057 EXPECT_FALSE(client.frameLoadTypeSameSeen()); 5059 EXPECT_FALSE(client.frameLoadTypeSameSeen());
5058 5060
5059 WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(toLocalFr ame(webViewHelper.webViewImpl()->page()->mainFrame())->document()->url())); 5061 WebCore::ResourceRequest request = WebCore::ResourceRequest::createMainResou rceRequest(
5062 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->document ()->url(), true);
5063 WebCore::FrameLoadRequest frameRequest(0, request);
5060 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 5064 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest);
5061 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF rame()); 5065 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF rame());
5062 5066
5063 EXPECT_TRUE(client.frameLoadTypeSameSeen()); 5067 EXPECT_TRUE(client.frameLoadTypeSameSeen());
5064 } 5068 }
5065 5069
5066 TEST_F(WebFrameTest, WebNodeImageContents) 5070 TEST_F(WebFrameTest, WebNodeImageContents)
5067 { 5071 {
5068 FrameTestHelpers::WebViewHelper webViewHelper; 5072 FrameTestHelpers::WebViewHelper webViewHelper;
5069 webViewHelper.initializeAndLoad("about:blank", true); 5073 webViewHelper.initializeAndLoad("about:blank", true);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
5266 // Test that currentHistoryItem reflects the current page, not the provisional l oad. 5270 // Test that currentHistoryItem reflects the current page, not the provisional l oad.
5267 TEST_F(WebFrameTest, CurrentHistoryItem) 5271 TEST_F(WebFrameTest, CurrentHistoryItem)
5268 { 5272 {
5269 registerMockedHttpURLLoad("fixed_layout.html"); 5273 registerMockedHttpURLLoad("fixed_layout.html");
5270 std::string url = m_baseURL + "fixed_layout.html"; 5274 std::string url = m_baseURL + "fixed_layout.html";
5271 5275
5272 FrameTestHelpers::WebViewHelper webViewHelper; 5276 FrameTestHelpers::WebViewHelper webViewHelper;
5273 webViewHelper.initialize(); 5277 webViewHelper.initialize();
5274 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5278 WebFrame* frame = webViewHelper.webView()->mainFrame();
5275 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m ainFrameImpl()->frame()->loader(); 5279 const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->m ainFrameImpl()->frame()->loader();
5276 WebURLRequest request; 5280 WebURLRequest request(toKURL(url), true);
5277 request.initialize();
5278 request.setURL(toKURL(url));
5279 frame->loadRequest(request); 5281 frame->loadRequest(request);
5280 5282
5281 // Before commit, there is no history item. 5283 // Before commit, there is no history item.
5282 EXPECT_FALSE(mainFrameLoader.currentItem()); 5284 EXPECT_FALSE(mainFrameLoader.currentItem());
5283 5285
5284 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); 5286 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
5285 5287
5286 // After commit, there is. 5288 // After commit, there is.
5287 WebCore::HistoryItem* item = mainFrameLoader.currentItem(); 5289 WebCore::HistoryItem* item = mainFrameLoader.currentItem();
5288 ASSERT_TRUE(item); 5290 ASSERT_TRUE(item);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
5607 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); 5609 EXPECT_EQ(0xff0000ff, frame->document().brandColor());
5608 // Change of second brand-color meta tag will not change frame's brand 5610 // Change of second brand-color meta tag will not change frame's brand
5609 // color. 5611 // color.
5610 client.reset(); 5612 client.reset();
5611 frame->executeScript(WebScriptSource("document.getElementById('bc2').setAttr ibute('content', '#00FF00');")); 5613 frame->executeScript(WebScriptSource("document.getElementById('bc2').setAttr ibute('content', '#00FF00');"));
5612 EXPECT_TRUE(client.didNotify()); 5614 EXPECT_TRUE(client.didNotify());
5613 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); 5615 EXPECT_EQ(0xff0000ff, frame->document().brandColor());
5614 } 5616 }
5615 5617
5616 } // namespace 5618 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698