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

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

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Rebasing... Created 3 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "public/web/WebFrame.h" 31 #include "public/web/WebFrame.h"
32 32
33 #include <stdarg.h> 33 #include <stdarg.h>
34 34
35 #include <limits>
35 #include <map> 36 #include <map>
36 #include <memory> 37 #include <memory>
38 #include <set>
37 39
38 #include "SkBitmap.h" 40 #include "SkBitmap.h"
39 #include "SkCanvas.h" 41 #include "SkCanvas.h"
40 #include "bindings/core/v8/V8BindingForCore.h" 42 #include "bindings/core/v8/V8BindingForCore.h"
41 #include "bindings/core/v8/V8Node.h" 43 #include "bindings/core/v8/V8Node.h"
42 #include "bindings/core/v8/serialization/SerializedScriptValueFactory.h" 44 #include "bindings/core/v8/serialization/SerializedScriptValueFactory.h"
43 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h" 45 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h"
44 #include "core/clipboard/DataTransfer.h" 46 #include "core/clipboard/DataTransfer.h"
45 #include "core/css/StyleSheetContents.h" 47 #include "core/css/StyleSheetContents.h"
46 #include "core/css/resolver/StyleResolver.h" 48 #include "core/css/resolver/StyleResolver.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 EXPECT_EQ(String(), callback_helper.StringValue()); 616 EXPECT_EQ(String(), callback_helper.StringValue());
615 } 617 }
616 618
617 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) { 619 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) {
618 RegisterMockedHttpURLLoad("form.html"); 620 RegisterMockedHttpURLLoad("form.html");
619 621
620 FrameTestHelpers::WebViewHelper web_view_helper; 622 FrameTestHelpers::WebViewHelper web_view_helper;
621 web_view_helper.InitializeAndLoad(base_url_ + "form.html"); 623 web_view_helper.InitializeAndLoad(base_url_ + "form.html");
622 624
623 WebVector<WebFormElement> forms; 625 WebVector<WebFormElement> forms;
624 web_view_helper.WebView()->MainFrame()->GetDocument().Forms(forms); 626 web_view_helper.WebView()->MainFrameImpl()->GetDocument().Forms(forms);
625 web_view_helper.Reset(); 627 web_view_helper.Reset();
626 628
627 EXPECT_EQ(forms.size(), 1U); 629 EXPECT_EQ(forms.size(), 1U);
628 630
629 // This test passes if this doesn't crash. 631 // This test passes if this doesn't crash.
630 WebSearchableFormData searchable_data_form(forms[0]); 632 WebSearchableFormData searchable_data_form(forms[0]);
631 } 633 }
632 634
633 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) { 635 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) {
634 RegisterMockedChromeURLLoad("history.html"); 636 RegisterMockedChromeURLLoad("history.html");
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) { 1011 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) {
1010 RegisterMockedHttpURLLoad("postmessage_test.html"); 1012 RegisterMockedHttpURLLoad("postmessage_test.html");
1011 1013
1012 // Pass true to enable JavaScript. 1014 // Pass true to enable JavaScript.
1013 FrameTestHelpers::WebViewHelper web_view_helper; 1015 FrameTestHelpers::WebViewHelper web_view_helper;
1014 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html", true); 1016 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html", true);
1015 1017
1016 // Send a message with the correct origin. 1018 // Send a message with the correct origin.
1017 WebSecurityOrigin correct_origin( 1019 WebSecurityOrigin correct_origin(
1018 WebSecurityOrigin::Create(ToKURL(base_url_))); 1020 WebSecurityOrigin::Create(ToKURL(base_url_)));
1019 WebDocument document = web_view_helper.WebView()->MainFrame()->GetDocument(); 1021 WebDocument document =
1022 web_view_helper.WebView()->MainFrameImpl()->GetDocument();
1020 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid()); 1023 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid());
1021 WebDOMMessageEvent message(data, "http://origin.com"); 1024 WebDOMMessageEvent message(data, "http://origin.com");
1022 web_view_helper.WebView() 1025 web_view_helper.WebView()
1023 ->MainFrameImpl() 1026 ->MainFrameImpl()
1024 ->DispatchMessageEventWithOriginCheck(correct_origin, message); 1027 ->DispatchMessageEventWithOriginCheck(correct_origin, message);
1025 1028
1026 // Send another message with incorrect origin. 1029 // Send another message with incorrect origin.
1027 WebSecurityOrigin incorrect_origin( 1030 WebSecurityOrigin incorrect_origin(
1028 WebSecurityOrigin::Create(ToKURL(chrome_url_))); 1031 WebSecurityOrigin::Create(ToKURL(chrome_url_)));
1029 web_view_helper.WebView() 1032 web_view_helper.WebView()
(...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after
3944 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 3947 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
3945 3948
3946 WebRect edit_box_with_text(200, 200, 250, 20); 3949 WebRect edit_box_with_text(200, 200, 250, 20);
3947 WebRect edit_box_with_no_text(200, 250, 250, 20); 3950 WebRect edit_box_with_no_text(200, 250, 250, 20);
3948 3951
3949 // Test scrolling the focused node 3952 // Test scrolling the focused node
3950 // The edit box is shorter and narrower than the viewport when legible. 3953 // The edit box is shorter and narrower than the viewport when legible.
3951 web_view_helper.WebView()->AdvanceFocus(false); 3954 web_view_helper.WebView()->AdvanceFocus(false);
3952 // Set the caret to the end of the input box. 3955 // Set the caret to the end of the input box.
3953 web_view_helper.WebView() 3956 web_view_helper.WebView()
3954 ->MainFrame() 3957 ->MainFrameImpl()
3955 ->GetDocument() 3958 ->GetDocument()
3956 .GetElementById("EditBoxWithText") 3959 .GetElementById("EditBoxWithText")
3957 .To<WebInputElement>() 3960 .To<WebInputElement>()
3958 .SetSelectionRange(1000, 1000); 3961 .SetSelectionRange(1000, 1000);
3959 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 3962 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
3960 WebRect rect, caret; 3963 WebRect rect, caret;
3961 web_view_helper.WebView()->SelectionBounds(caret, rect); 3964 web_view_helper.WebView()->SelectionBounds(caret, rect);
3962 3965
3963 // Set the page scale to be smaller than the minimal readable scale. 3966 // Set the page scale to be smaller than the minimal readable scale.
3964 float initial_scale = min_readable_caret_height / caret.height * 0.5f; 3967 float initial_scale = min_readable_caret_height / caret.height * 0.5f;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4041 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled( 4044 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled(
4042 false); 4045 false);
4043 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight)); 4046 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight));
4044 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 4047 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
4045 4048
4046 const WebRect edit_box_with_text(200, 200, 250, 20); 4049 const WebRect edit_box_with_text(200, 200, 250, 20);
4047 4050
4048 web_view_helper.WebView()->AdvanceFocus(false); 4051 web_view_helper.WebView()->AdvanceFocus(false);
4049 // Set the caret to the begining of the input box. 4052 // Set the caret to the begining of the input box.
4050 web_view_helper.WebView() 4053 web_view_helper.WebView()
4051 ->MainFrame() 4054 ->MainFrameImpl()
4052 ->GetDocument() 4055 ->GetDocument()
4053 .GetElementById("EditBoxWithText") 4056 .GetElementById("EditBoxWithText")
4054 .To<WebInputElement>() 4057 .To<WebInputElement>()
4055 .SetSelectionRange(0, 0); 4058 .SetSelectionRange(0, 0);
4056 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 4059 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
4057 WebRect rect, caret; 4060 WebRect rect, caret;
4058 web_view_helper.WebView()->SelectionBounds(caret, rect); 4061 web_view_helper.WebView()->SelectionBounds(caret, rect);
4059 4062
4060 // Set the page scale to be twice as large as the minimal readable scale. 4063 // Set the page scale to be twice as large as the minimal readable scale.
4061 float new_scale = kMinReadableCaretHeight / caret.height * 2.0; 4064 float new_scale = kMinReadableCaretHeight / caret.height * 2.0;
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
5348 } 5351 }
5349 5352
5350 static WebPoint BottomRightMinusOne(const WebRect& rect) { 5353 static WebPoint BottomRightMinusOne(const WebRect& rect) {
5351 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the 5354 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the
5352 // selection bounds, selectRange() will select the *next* element. That's 5355 // selection bounds, selectRange() will select the *next* element. That's
5353 // strictly correct, as hit-testing checks the pixel to the lower-right of 5356 // strictly correct, as hit-testing checks the pixel to the lower-right of
5354 // the input coordinate, but it's a wart on the API. 5357 // the input coordinate, but it's a wart on the API.
5355 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 5358 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
5356 } 5359 }
5357 5360
5358 static WebRect ElementBounds(WebFrame* frame, const WebString& id) { 5361 static WebRect ElementBounds(WebLocalFrame* frame, const WebString& id) {
5359 return frame->GetDocument().GetElementById(id).BoundsInViewport(); 5362 return frame->GetDocument().GetElementById(id).BoundsInViewport();
5360 } 5363 }
5361 5364
5362 static std::string SelectionAsString(WebFrame* frame) { 5365 static std::string SelectionAsString(WebFrame* frame) {
5363 return frame->ToWebLocalFrame()->SelectionAsText().Utf8(); 5366 return frame->ToWebLocalFrame()->SelectionAsText().Utf8();
5364 } 5367 }
5365 5368
5366 TEST_P(ParameterizedWebFrameTest, SelectRange) { 5369 TEST_P(ParameterizedWebFrameTest, SelectRange) {
5367 WebLocalFrame* frame; 5370 WebLocalFrame* frame;
5368 WebRect start_web_rect; 5371 WebRect start_web_rect;
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
6726 WebVector<unsigned> offsets2; 6729 WebVector<unsigned> offsets2;
6727 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument()); 6730 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument());
6728 EXPECT_EQ(0U, offsets2.size()); 6731 EXPECT_EQ(0U, offsets2.size());
6729 } 6732 }
6730 6733
6731 class StubbornTextCheckClient : public WebTextCheckClient { 6734 class StubbornTextCheckClient : public WebTextCheckClient {
6732 public: 6735 public:
6733 StubbornTextCheckClient() : completion_(0) {} 6736 StubbornTextCheckClient() : completion_(0) {}
6734 virtual ~StubbornTextCheckClient() {} 6737 virtual ~StubbornTextCheckClient() {}
6735 6738
6736 virtual void RequestCheckingOfText( 6739 void RequestCheckingOfText(const WebString&,
6737 const WebString&, 6740 WebTextCheckingCompletion* completion) override {
6738 WebTextCheckingCompletion* completion) override {
6739 completion_ = completion; 6741 completion_ = completion;
6740 } 6742 }
6741 6743
6742 void CancelAllPendingRequests() override { 6744 void CancelAllPendingRequests() override {
6743 if (!completion_) 6745 if (!completion_)
6744 return; 6746 return;
6745 completion_->DidCancelCheckingText(); 6747 completion_->DidCancelCheckingText();
6746 completion_ = nullptr; 6748 completion_ = nullptr;
6747 } 6749 }
6748 6750
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
7199 7201
7200 WebURLResponse final_response; 7202 WebURLResponse final_response;
7201 final_response.SetMIMEType("text/html"); 7203 final_response.SetMIMEType("text/html");
7202 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL( 7204 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL(
7203 redirect_url, final_response, file_path); 7205 redirect_url, final_response, file_path);
7204 7206
7205 FrameTestHelpers::WebViewHelper web_view_helper; 7207 FrameTestHelpers::WebViewHelper web_view_helper;
7206 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html", 7208 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html",
7207 true); 7209 true);
7208 EXPECT_TRUE(web_view_helper.WebView() 7210 EXPECT_TRUE(web_view_helper.WebView()
7209 ->MainFrame() 7211 ->MainFrameImpl()
7210 ->GetDocument() 7212 ->GetDocument()
7211 .FirstPartyForCookies() == redirect_url); 7213 .FirstPartyForCookies() == redirect_url);
7212 } 7214 }
7213 7215
7214 class TestNavigationPolicyWebFrameClient 7216 class TestNavigationPolicyWebFrameClient
7215 : public FrameTestHelpers::TestWebFrameClient { 7217 : public FrameTestHelpers::TestWebFrameClient {
7216 public: 7218 public:
7217 void DidNavigateWithinPage(const WebHistoryItem&, 7219 void DidNavigateWithinPage(const WebHistoryItem&,
7218 WebHistoryCommitType, 7220 WebHistoryCommitType,
7219 bool) override { 7221 bool) override {
(...skipping 22 matching lines...) Expand all
7242 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer); 7244 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer);
7243 FrameLoadRequest frame_request(document, ResourceRequest(destination)); 7245 FrameLoadRequest frame_request(document, ResourceRequest(destination));
7244 frame_request.SetTriggeringEvent(event); 7246 frame_request.SetTriggeringEvent(event);
7245 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame()) 7247 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame())
7246 ->Loader() 7248 ->Loader()
7247 .Load(frame_request); 7249 .Load(frame_request);
7248 } 7250 }
7249 7251
7250 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { 7252 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient {
7251 public: 7253 public:
7252 virtual WebView* CreateView(WebLocalFrame*, 7254 WebView* CreateView(WebLocalFrame*,
7253 const WebURLRequest&, 7255 const WebURLRequest&,
7254 const WebWindowFeatures&, 7256 const WebWindowFeatures&,
7255 const WebString&, 7257 const WebString&,
7256 WebNavigationPolicy, 7258 WebNavigationPolicy,
7257 bool) override { 7259 bool) override {
7258 EXPECT_TRUE(false); 7260 EXPECT_TRUE(false);
7259 return 0; 7261 return 0;
7260 } 7262 }
7261 }; 7263 };
7262 7264
7263 class TestNewWindowWebFrameClient 7265 class TestNewWindowWebFrameClient
7264 : public FrameTestHelpers::TestWebFrameClient { 7266 : public FrameTestHelpers::TestWebFrameClient {
7265 public: 7267 public:
7266 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {} 7268 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {}
7267 7269
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
7730 7732
7731 TestHistoryWebFrameClient client; 7733 TestHistoryWebFrameClient client;
7732 FrameTestHelpers::WebViewHelper web_view_helper; 7734 FrameTestHelpers::WebViewHelper web_view_helper;
7733 web_view_helper.InitializeAndLoad("about:blank", true, &client); 7735 web_view_helper.InitializeAndLoad("about:blank", true, &client);
7734 7736
7735 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); 7737 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl();
7736 7738
7737 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( 7739 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8(
7738 "document.body.appendChild(document.createElement('iframe'))"))); 7740 "document.body.appendChild(document.createElement('iframe'))")));
7739 7741
7740 WebFrame* iframe = frame->FirstChild(); 7742 WebLocalFrameBase* iframe = ToWebLocalFrameBase(frame->FirstChild());
7741 ASSERT_EQ(&client.ChildClient(), ToWebLocalFrameBase(iframe)->Client()); 7743 ASSERT_EQ(&client.ChildClient(), iframe->Client());
7742 7744
7743 std::string url1 = base_url_ + "history.html"; 7745 std::string url1 = base_url_ + "history.html";
7744 FrameTestHelpers::LoadFrame(iframe, url1); 7746 FrameTestHelpers::LoadFrame(iframe, url1);
7745 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); 7747 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8());
7746 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem()); 7748 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem());
7747 7749
7748 std::string url2 = base_url_ + "find.html"; 7750 std::string url2 = base_url_ + "find.html";
7749 FrameTestHelpers::LoadFrame(iframe, url2); 7751 FrameTestHelpers::LoadFrame(iframe, url2);
7750 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); 7752 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8());
7751 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); 7753 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem());
7752 } 7754 }
7753 7755
7754 // Tests that a navigation in a frame with a non-blank initial URL will create 7756 // Tests that a navigation in a frame with a non-blank initial URL will create
7755 // a new history item, unlike the case above. 7757 // a new history item, unlike the case above.
7756 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { 7758 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) {
7757 RegisterMockedHttpURLLoad("history.html"); 7759 RegisterMockedHttpURLLoad("history.html");
7758 RegisterMockedHttpURLLoad("find.html"); 7760 RegisterMockedHttpURLLoad("find.html");
7759 7761
7760 TestHistoryWebFrameClient client; 7762 TestHistoryWebFrameClient client;
7761 FrameTestHelpers::WebViewHelper web_view_helper; 7763 FrameTestHelpers::WebViewHelper web_view_helper;
7762 web_view_helper.InitializeAndLoad("about:blank", true, &client); 7764 web_view_helper.InitializeAndLoad("about:blank", true, &client);
7763 7765
7764 WebFrame* frame = web_view_helper.WebView()->MainFrame(); 7766 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl();
7765 7767
7766 std::string url1 = base_url_ + "history.html"; 7768 std::string url1 = base_url_ + "history.html";
7767 FrameTestHelpers::LoadFrame( 7769 FrameTestHelpers::LoadFrame(
7768 frame, 7770 frame,
7769 "javascript:var f = document.createElement('iframe'); " 7771 "javascript:var f = document.createElement('iframe'); "
7770 "f.src = '" + 7772 "f.src = '" +
7771 url1 + 7773 url1 +
7772 "';" 7774 "';"
7773 "document.body.appendChild(f)"); 7775 "document.body.appendChild(f)");
7774 7776
7775 WebFrame* iframe = frame->FirstChild(); 7777 WebLocalFrame* iframe = frame->FirstChild()->ToWebLocalFrame();
7776 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); 7778 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8());
7777 7779
7778 std::string url2 = base_url_ + "find.html"; 7780 std::string url2 = base_url_ + "find.html";
7779 FrameTestHelpers::LoadFrame(iframe, url2); 7781 FrameTestHelpers::LoadFrame(iframe, url2);
7780 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); 7782 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8());
7781 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); 7783 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem());
7782 } 7784 }
7783 7785
7784 // Test verifies that layout will change a layer's scrollable attibutes 7786 // Test verifies that layout will change a layer's scrollable attibutes
7785 TEST_F(WebFrameTest, overflowHiddenRewrite) { 7787 TEST_F(WebFrameTest, overflowHiddenRewrite) {
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
9627 remote_frame->Swap(local_frame); 9629 remote_frame->Swap(local_frame);
9628 9630
9629 // And the opener cycle should still be preserved. 9631 // And the opener cycle should still be preserved.
9630 EXPECT_EQ(local_frame, local_frame->Opener()); 9632 EXPECT_EQ(local_frame, local_frame->Opener());
9631 9633
9632 view->Close(); 9634 view->Close();
9633 } 9635 }
9634 9636
9635 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 9637 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
9636 public: 9638 public:
9637 explicit CommitTypeWebFrameClient() 9639 CommitTypeWebFrameClient() : history_commit_type_(kWebHistoryInertCommit) {}
9638 : history_commit_type_(kWebHistoryInertCommit) {}
9639 9640
9640 void DidCommitProvisionalLoad( 9641 void DidCommitProvisionalLoad(
9641 const WebHistoryItem&, 9642 const WebHistoryItem&,
9642 WebHistoryCommitType history_commit_type) override { 9643 WebHistoryCommitType history_commit_type) override {
9643 history_commit_type_ = history_commit_type; 9644 history_commit_type_ = history_commit_type;
9644 } 9645 }
9645 9646
9646 WebHistoryCommitType HistoryCommitType() const { 9647 WebHistoryCommitType HistoryCommitType() const {
9647 return history_commit_type_; 9648 return history_commit_type_;
9648 } 9649 }
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
10736 local_frame->CopyImageAt(WebPoint(50, 50)); 10737 local_frame->CopyImageAt(WebPoint(50, 50));
10737 10738
10738 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10739 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10739 WebClipboard::kBufferStandard)); 10740 WebClipboard::kBufferStandard));
10740 10741
10741 WebImage image = 10742 WebImage image =
10742 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10743 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10743 ->ReadRawImage(WebClipboard::Buffer()); 10744 ->ReadRawImage(WebClipboard::Buffer());
10744 10745
10745 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10746 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10746 }; 10747 }
10747 10748
10748 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { 10749 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) {
10749 std::string url = base_url_ + "canvas-copy-image.html"; 10750 std::string url = base_url_ + "canvas-copy-image.html";
10750 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html"); 10751 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html");
10751 10752
10752 FrameTestHelpers::WebViewHelper helper; 10753 FrameTestHelpers::WebViewHelper helper;
10753 WebViewBase* web_view = helper.InitializeAndLoad(url, true, 0); 10754 WebViewBase* web_view = helper.InitializeAndLoad(url, true, 0);
10754 web_view->Resize(WebSize(400, 400)); 10755 web_view->Resize(WebSize(400, 400));
10755 web_view->UpdateAllLifecyclePhases(); 10756 web_view->UpdateAllLifecyclePhases();
10756 web_view->SetPageScaleFactor(2); 10757 web_view->SetPageScaleFactor(2);
10757 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200)); 10758 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200));
10758 10759
10759 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber( 10760 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber(
10760 WebClipboard::kBufferStandard); 10761 WebClipboard::kBufferStandard);
10761 10762
10762 WebLocalFrame* local_frame = web_view->MainFrameImpl(); 10763 WebLocalFrame* local_frame = web_view->MainFrameImpl();
10763 local_frame->CopyImageAt(WebPoint(0, 0)); 10764 local_frame->CopyImageAt(WebPoint(0, 0));
10764 10765
10765 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10766 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10766 WebClipboard::kBufferStandard)); 10767 WebClipboard::kBufferStandard));
10767 10768
10768 WebImage image = 10769 WebImage image =
10769 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10770 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10770 ->ReadRawImage(WebClipboard::Buffer()); 10771 ->ReadRawImage(WebClipboard::Buffer());
10771 10772
10772 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10773 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10773 }; 10774 }
10774 10775
10775 TEST_F(WebFrameTest, CopyImageWithImageMap) { 10776 TEST_F(WebFrameTest, CopyImageWithImageMap) {
10776 SaveImageFromDataURLWebFrameClient client; 10777 SaveImageFromDataURLWebFrameClient client;
10777 10778
10778 std::string url = base_url_ + "image-map.html"; 10779 std::string url = base_url_ + "image-map.html";
10779 RegisterMockedURLLoadFromBase(base_url_, "image-map.html"); 10780 RegisterMockedURLLoadFromBase(base_url_, "image-map.html");
10780 10781
10781 FrameTestHelpers::WebViewHelper helper; 10782 FrameTestHelpers::WebViewHelper helper;
10782 WebViewBase* web_view = helper.InitializeAndLoad(url, true, &client); 10783 WebViewBase* web_view = helper.InitializeAndLoad(url, true, &client);
10783 web_view->Resize(WebSize(400, 400)); 10784 web_view->Resize(WebSize(400, 400));
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
12072 12073
12073 // Verify that the right WebWidgetClient has been notified. 12074 // Verify that the right WebWidgetClient has been notified.
12074 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard()); 12075 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard());
12075 12076
12076 remote_frame->Close(); 12077 remote_frame->Close();
12077 web_view_helper.Reset(); 12078 web_view_helper.Reset();
12078 } 12079 }
12079 12080
12080 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 12081 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
12081 public: 12082 public:
12082 ContextMenuWebFrameClient(){}; 12083 ContextMenuWebFrameClient() {}
12083 // WebFrameClient methods 12084 // WebFrameClient methods
12084 void ShowContextMenu(const WebContextMenuData& data) override { 12085 void ShowContextMenu(const WebContextMenuData& data) override {
12085 menu_data_ = data; 12086 menu_data_ = data;
12086 } 12087 }
12087 12088
12088 WebContextMenuData GetMenuData() { return menu_data_; } 12089 WebContextMenuData GetMenuData() { return menu_data_; }
12089 12090
12090 private: 12091 private:
12091 WebContextMenuData menu_data_; 12092 WebContextMenuData menu_data_;
12092 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient); 12093 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
12169 12170
12170 // Local frame with remote parent should have transparent baseBackgroundColor. 12171 // Local frame with remote parent should have transparent baseBackgroundColor.
12171 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); 12172 Color color = local_frame->GetFrameView()->BaseBackgroundColor();
12172 EXPECT_EQ(Color::kTransparent, color); 12173 EXPECT_EQ(Color::kTransparent, color);
12173 12174
12174 view->Close(); 12175 view->Close();
12175 } 12176 }
12176 12177
12177 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 12178 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
12178 public: 12179 public:
12179 explicit TestFallbackWebFrameClient() : child_client_(nullptr) {} 12180 TestFallbackWebFrameClient() : child_client_(nullptr) {}
12180 12181
12181 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) { 12182 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) {
12182 child_client_ = client; 12183 child_client_ = client;
12183 } 12184 }
12184 12185
12185 WebLocalFrame* CreateChildFrame( 12186 WebLocalFrame* CreateChildFrame(
12186 WebLocalFrame* parent, 12187 WebLocalFrame* parent,
12187 WebTreeScopeType scope, 12188 WebTreeScopeType scope,
12188 const WebString&, 12189 const WebString&,
12189 const WebString&, 12190 const WebString&,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
12258 if (obj->IsText()) { 12259 if (obj->IsText()) {
12259 LayoutText* layout_text = ToLayoutText(obj); 12260 LayoutText* layout_text = ToLayoutText(obj);
12260 text = layout_text->GetText(); 12261 text = layout_text->GetText();
12261 break; 12262 break;
12262 } 12263 }
12263 } 12264 }
12264 EXPECT_EQ("foo alt", text.Utf8()); 12265 EXPECT_EQ("foo alt", text.Utf8());
12265 } 12266 }
12266 12267
12267 } // namespace blink 12268 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698