| 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 4329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4340 | 4340 |
| 4341 FrameTestHelpers::WebViewHelper web_view_helper; | 4341 FrameTestHelpers::WebViewHelper web_view_helper; |
| 4342 web_view_helper.Initialize(); | 4342 web_view_helper.Initialize(); |
| 4343 WebURLRequest request(ToKURL(base_url_ + "fixed_layout.html")); | 4343 WebURLRequest request(ToKURL(base_url_ + "fixed_layout.html")); |
| 4344 web_view_helper.WebView()->MainFrame()->LoadRequest(request); | 4344 web_view_helper.WebView()->MainFrame()->LoadRequest(request); |
| 4345 // start reload before first request is delivered. | 4345 // start reload before first request is delivered. |
| 4346 FrameTestHelpers::ReloadFrameBypassingCache( | 4346 FrameTestHelpers::ReloadFrameBypassingCache( |
| 4347 web_view_helper.WebView()->MainFrame()); | 4347 web_view_helper.WebView()->MainFrame()); |
| 4348 | 4348 |
| 4349 WebDataSource* data_source = | 4349 WebDataSource* data_source = |
| 4350 web_view_helper.WebView()->MainFrame()->DataSource(); | 4350 web_view_helper.WebView()->MainFrameImpl()->DataSource(); |
| 4351 ASSERT_TRUE(data_source); | 4351 ASSERT_TRUE(data_source); |
| 4352 EXPECT_EQ(ToKURL(base_url_ + "fixed_layout.html"), | 4352 EXPECT_EQ(ToKURL(base_url_ + "fixed_layout.html"), |
| 4353 KURL(data_source->GetRequest().Url())); | 4353 KURL(data_source->GetRequest().Url())); |
| 4354 } | 4354 } |
| 4355 | 4355 |
| 4356 TEST_P(ParameterizedWebFrameTest, AppendRedirects) { | 4356 TEST_P(ParameterizedWebFrameTest, AppendRedirects) { |
| 4357 const std::string first_url = "about:blank"; | 4357 const std::string first_url = "about:blank"; |
| 4358 const std::string second_url = "http://internal.test"; | 4358 const std::string second_url = "http://internal.test"; |
| 4359 | 4359 |
| 4360 FrameTestHelpers::WebViewHelper web_view_helper; | 4360 FrameTestHelpers::WebViewHelper web_view_helper; |
| 4361 web_view_helper.InitializeAndLoad(first_url, true); | 4361 web_view_helper.InitializeAndLoad(first_url, true); |
| 4362 | 4362 |
| 4363 WebDataSource* data_source = | 4363 WebDataSource* data_source = |
| 4364 web_view_helper.WebView()->MainFrame()->DataSource(); | 4364 web_view_helper.WebView()->MainFrameImpl()->DataSource(); |
| 4365 ASSERT_TRUE(data_source); | 4365 ASSERT_TRUE(data_source); |
| 4366 data_source->AppendRedirect(ToKURL(second_url)); | 4366 data_source->AppendRedirect(ToKURL(second_url)); |
| 4367 | 4367 |
| 4368 WebVector<WebURL> redirects; | 4368 WebVector<WebURL> redirects; |
| 4369 data_source->RedirectChain(redirects); | 4369 data_source->RedirectChain(redirects); |
| 4370 ASSERT_EQ(2U, redirects.size()); | 4370 ASSERT_EQ(2U, redirects.size()); |
| 4371 EXPECT_EQ(ToKURL(first_url), KURL(redirects[0])); | 4371 EXPECT_EQ(ToKURL(first_url), KURL(redirects[0])); |
| 4372 EXPECT_EQ(ToKURL(second_url), KURL(redirects[1])); | 4372 EXPECT_EQ(ToKURL(second_url), KURL(redirects[1])); |
| 4373 } | 4373 } |
| 4374 | 4374 |
| 4375 TEST_P(ParameterizedWebFrameTest, IframeRedirect) { | 4375 TEST_P(ParameterizedWebFrameTest, IframeRedirect) { |
| 4376 RegisterMockedHttpURLLoad("iframe_redirect.html"); | 4376 RegisterMockedHttpURLLoad("iframe_redirect.html"); |
| 4377 RegisterMockedHttpURLLoad("visible_iframe.html"); | 4377 RegisterMockedHttpURLLoad("visible_iframe.html"); |
| 4378 | 4378 |
| 4379 FrameTestHelpers::WebViewHelper web_view_helper; | 4379 FrameTestHelpers::WebViewHelper web_view_helper; |
| 4380 web_view_helper.InitializeAndLoad(base_url_ + "iframe_redirect.html", true); | 4380 web_view_helper.InitializeAndLoad(base_url_ + "iframe_redirect.html", true); |
| 4381 // Pump pending requests one more time. The test page loads script that | 4381 // Pump pending requests one more time. The test page loads script that |
| 4382 // navigates. | 4382 // navigates. |
| 4383 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( | 4383 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( |
| 4384 web_view_helper.WebView()->MainFrame()); | 4384 web_view_helper.WebView()->MainFrame()); |
| 4385 | 4385 |
| 4386 WebFrame* iframe = | 4386 WebFrame* iframe = |
| 4387 web_view_helper.WebView()->MainFrameImpl()->FindFrameByName( | 4387 web_view_helper.WebView()->MainFrameImpl()->FindFrameByName( |
| 4388 WebString::FromUTF8("ifr")); | 4388 WebString::FromUTF8("ifr")); |
| 4389 ASSERT_TRUE(iframe); | 4389 ASSERT_TRUE(iframe && iframe->IsWebLocalFrame()); |
| 4390 WebDataSource* iframe_data_source = iframe->DataSource(); | 4390 WebDataSource* iframe_data_source = iframe->ToWebLocalFrame()->DataSource(); |
| 4391 ASSERT_TRUE(iframe_data_source); | 4391 ASSERT_TRUE(iframe_data_source); |
| 4392 WebVector<WebURL> redirects; | 4392 WebVector<WebURL> redirects; |
| 4393 iframe_data_source->RedirectChain(redirects); | 4393 iframe_data_source->RedirectChain(redirects); |
| 4394 ASSERT_EQ(2U, redirects.size()); | 4394 ASSERT_EQ(2U, redirects.size()); |
| 4395 EXPECT_EQ(ToKURL("about:blank"), KURL(redirects[0])); | 4395 EXPECT_EQ(ToKURL("about:blank"), KURL(redirects[0])); |
| 4396 EXPECT_EQ(ToKURL("http://internal.test/visible_iframe.html"), | 4396 EXPECT_EQ(ToKURL("http://internal.test/visible_iframe.html"), |
| 4397 KURL(redirects[1])); | 4397 KURL(redirects[1])); |
| 4398 } | 4398 } |
| 4399 | 4399 |
| 4400 TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) { | 4400 TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) { |
| (...skipping 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7334 // decidePolicyForNavigation should be called both for the original request | 7334 // decidePolicyForNavigation should be called both for the original request |
| 7335 // and the ctrl+click. | 7335 // and the ctrl+click. |
| 7336 EXPECT_EQ(2, web_frame_client.DecidePolicyCallCount()); | 7336 EXPECT_EQ(2, web_frame_client.DecidePolicyCallCount()); |
| 7337 } | 7337 } |
| 7338 | 7338 |
| 7339 TEST_P(ParameterizedWebFrameTest, BackToReload) { | 7339 TEST_P(ParameterizedWebFrameTest, BackToReload) { |
| 7340 RegisterMockedHttpURLLoad("fragment_middle_click.html"); | 7340 RegisterMockedHttpURLLoad("fragment_middle_click.html"); |
| 7341 FrameTestHelpers::WebViewHelper web_view_helper; | 7341 FrameTestHelpers::WebViewHelper web_view_helper; |
| 7342 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html", | 7342 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html", |
| 7343 true); | 7343 true); |
| 7344 WebFrame* frame = web_view_helper.WebView()->MainFrame(); | 7344 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); |
| 7345 const FrameLoader& main_frame_loader = | 7345 const FrameLoader& main_frame_loader = |
| 7346 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); | 7346 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); |
| 7347 Persistent<HistoryItem> first_item = | 7347 Persistent<HistoryItem> first_item = |
| 7348 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); | 7348 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); |
| 7349 EXPECT_TRUE(first_item); | 7349 EXPECT_TRUE(first_item); |
| 7350 | 7350 |
| 7351 RegisterMockedHttpURLLoad("white-1x1.png"); | 7351 RegisterMockedHttpURLLoad("white-1x1.png"); |
| 7352 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); | 7352 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); |
| 7353 EXPECT_NE(first_item.Get(), | 7353 EXPECT_NE(first_item.Get(), |
| 7354 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); | 7354 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7393 EXPECT_EQ(item.UrlString(), main_frame->GetDocument().Url().GetString()); | 7393 EXPECT_EQ(item.UrlString(), main_frame->GetDocument().Url().GetString()); |
| 7394 EXPECT_EQ(item.UrlString(), WebString(main_frame_loader.GetDocumentLoader() | 7394 EXPECT_EQ(item.UrlString(), WebString(main_frame_loader.GetDocumentLoader() |
| 7395 ->GetHistoryItem() | 7395 ->GetHistoryItem() |
| 7396 ->UrlString())); | 7396 ->UrlString())); |
| 7397 } | 7397 } |
| 7398 | 7398 |
| 7399 TEST_P(ParameterizedWebFrameTest, ReloadPost) { | 7399 TEST_P(ParameterizedWebFrameTest, ReloadPost) { |
| 7400 RegisterMockedHttpURLLoad("reload_post.html"); | 7400 RegisterMockedHttpURLLoad("reload_post.html"); |
| 7401 FrameTestHelpers::WebViewHelper web_view_helper; | 7401 FrameTestHelpers::WebViewHelper web_view_helper; |
| 7402 web_view_helper.InitializeAndLoad(base_url_ + "reload_post.html", true); | 7402 web_view_helper.InitializeAndLoad(base_url_ + "reload_post.html", true); |
| 7403 WebFrame* frame = web_view_helper.WebView()->MainFrame(); | 7403 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); |
| 7404 | 7404 |
| 7405 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrame(), | 7405 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrame(), |
| 7406 "javascript:document.forms[0].submit()"); | 7406 "javascript:document.forms[0].submit()"); |
| 7407 // Pump requests one more time after the javascript URL has executed to | 7407 // Pump requests one more time after the javascript URL has executed to |
| 7408 // trigger the actual POST load request. | 7408 // trigger the actual POST load request. |
| 7409 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( | 7409 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( |
| 7410 web_view_helper.WebView()->MainFrame()); | 7410 web_view_helper.WebView()->MainFrame()); |
| 7411 EXPECT_EQ(WebString::FromUTF8("POST"), | 7411 EXPECT_EQ(WebString::FromUTF8("POST"), |
| 7412 frame->DataSource()->GetRequest().HttpMethod()); | 7412 frame->DataSource()->GetRequest().HttpMethod()); |
| 7413 | 7413 |
| 7414 FrameTestHelpers::ReloadFrame(frame); | 7414 FrameTestHelpers::ReloadFrame(frame); |
| 7415 EXPECT_EQ(WebCachePolicy::kValidatingCacheData, | 7415 EXPECT_EQ(WebCachePolicy::kValidatingCacheData, |
| 7416 frame->DataSource()->GetRequest().GetCachePolicy()); | 7416 frame->DataSource()->GetRequest().GetCachePolicy()); |
| 7417 EXPECT_EQ(kWebNavigationTypeFormResubmitted, | 7417 EXPECT_EQ(kWebNavigationTypeFormResubmitted, |
| 7418 frame->DataSource()->GetNavigationType()); | 7418 frame->DataSource()->GetNavigationType()); |
| 7419 } | 7419 } |
| 7420 | 7420 |
| 7421 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { | 7421 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { |
| 7422 RegisterMockedHttpURLLoad("fragment_middle_click.html"); | 7422 RegisterMockedHttpURLLoad("fragment_middle_click.html"); |
| 7423 FrameTestHelpers::WebViewHelper web_view_helper; | 7423 FrameTestHelpers::WebViewHelper web_view_helper; |
| 7424 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html", | 7424 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html", |
| 7425 true); | 7425 true); |
| 7426 WebFrame* frame = web_view_helper.WebView()->MainFrame(); | 7426 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); |
| 7427 const FrameLoader& main_frame_loader = | 7427 const FrameLoader& main_frame_loader = |
| 7428 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); | 7428 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); |
| 7429 Persistent<HistoryItem> first_item = | 7429 Persistent<HistoryItem> first_item = |
| 7430 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); | 7430 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); |
| 7431 EXPECT_TRUE(first_item); | 7431 EXPECT_TRUE(first_item); |
| 7432 | 7432 |
| 7433 RegisterMockedHttpURLLoad("white-1x1.png"); | 7433 RegisterMockedHttpURLLoad("white-1x1.png"); |
| 7434 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); | 7434 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); |
| 7435 EXPECT_NE(first_item.Get(), | 7435 EXPECT_NE(first_item.Get(), |
| 7436 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); | 7436 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8722 | 8722 |
| 8723 EXPECT_TRUE(resource->IsLoaded()); | 8723 EXPECT_TRUE(resource->IsLoaded()); |
| 8724 } | 8724 } |
| 8725 | 8725 |
| 8726 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) { | 8726 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) { |
| 8727 // Check that a reload bypassing cache on a frame will result in the cache | 8727 // Check that a reload bypassing cache on a frame will result in the cache |
| 8728 // policy of the request being set to ReloadBypassingCache. | 8728 // policy of the request being set to ReloadBypassingCache. |
| 8729 RegisterMockedHttpURLLoad("foo.html"); | 8729 RegisterMockedHttpURLLoad("foo.html"); |
| 8730 FrameTestHelpers::WebViewHelper web_view_helper; | 8730 FrameTestHelpers::WebViewHelper web_view_helper; |
| 8731 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); | 8731 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); |
| 8732 WebFrame* frame = web_view_helper.WebView()->MainFrame(); | 8732 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); |
| 8733 FrameTestHelpers::ReloadFrameBypassingCache(frame); | 8733 FrameTestHelpers::ReloadFrameBypassingCache(frame); |
| 8734 EXPECT_EQ(WebCachePolicy::kBypassingCache, | 8734 EXPECT_EQ(WebCachePolicy::kBypassingCache, |
| 8735 frame->DataSource()->GetRequest().GetCachePolicy()); | 8735 frame->DataSource()->GetRequest().GetCachePolicy()); |
| 8736 } | 8736 } |
| 8737 | 8737 |
| 8738 static void NodeImageTestValidation(const IntSize& reference_bitmap_size, | 8738 static void NodeImageTestValidation(const IntSize& reference_bitmap_size, |
| 8739 DragImage* drag_image) { | 8739 DragImage* drag_image) { |
| 8740 // Prepare the reference bitmap. | 8740 // Prepare the reference bitmap. |
| 8741 SkBitmap bitmap; | 8741 SkBitmap bitmap; |
| 8742 bitmap.allocN32Pixels(reference_bitmap_size.Width(), | 8742 bitmap.allocN32Pixels(reference_bitmap_size.Width(), |
| (...skipping 3438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12181 if (obj->IsText()) { | 12181 if (obj->IsText()) { |
| 12182 LayoutText* layout_text = ToLayoutText(obj); | 12182 LayoutText* layout_text = ToLayoutText(obj); |
| 12183 text = layout_text->GetText(); | 12183 text = layout_text->GetText(); |
| 12184 break; | 12184 break; |
| 12185 } | 12185 } |
| 12186 } | 12186 } |
| 12187 EXPECT_EQ("foo alt", text.Utf8()); | 12187 EXPECT_EQ("foo alt", text.Utf8()); |
| 12188 } | 12188 } |
| 12189 | 12189 |
| 12190 } // namespace blink | 12190 } // namespace blink |
| OLD | NEW |