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

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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 1004
1003 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) { 1005 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) {
1004 RegisterMockedHttpURLLoad("postmessage_test.html"); 1006 RegisterMockedHttpURLLoad("postmessage_test.html");
1005 1007
1006 FrameTestHelpers::WebViewHelper web_view_helper; 1008 FrameTestHelpers::WebViewHelper web_view_helper;
1007 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html"); 1009 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html");
1008 1010
1009 // Send a message with the correct origin. 1011 // Send a message with the correct origin.
1010 WebSecurityOrigin correct_origin( 1012 WebSecurityOrigin correct_origin(
1011 WebSecurityOrigin::Create(ToKURL(base_url_))); 1013 WebSecurityOrigin::Create(ToKURL(base_url_)));
1012 WebDocument document = web_view_helper.WebView()->MainFrame()->GetDocument(); 1014 WebDocument document =
1015 web_view_helper.WebView()->MainFrameImpl()->GetDocument();
1013 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid()); 1016 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid());
1014 WebDOMMessageEvent message(data, "http://origin.com"); 1017 WebDOMMessageEvent message(data, "http://origin.com");
1015 web_view_helper.WebView() 1018 web_view_helper.WebView()
1016 ->MainFrameImpl() 1019 ->MainFrameImpl()
1017 ->DispatchMessageEventWithOriginCheck(correct_origin, message); 1020 ->DispatchMessageEventWithOriginCheck(correct_origin, message);
1018 1021
1019 // Send another message with incorrect origin. 1022 // Send another message with incorrect origin.
1020 WebSecurityOrigin incorrect_origin( 1023 WebSecurityOrigin incorrect_origin(
1021 WebSecurityOrigin::Create(ToKURL(chrome_url_))); 1024 WebSecurityOrigin::Create(ToKURL(chrome_url_)));
1022 web_view_helper.WebView() 1025 web_view_helper.WebView()
(...skipping 2897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3920 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 3923 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
3921 3924
3922 WebRect edit_box_with_text(200, 200, 250, 20); 3925 WebRect edit_box_with_text(200, 200, 250, 20);
3923 WebRect edit_box_with_no_text(200, 250, 250, 20); 3926 WebRect edit_box_with_no_text(200, 250, 250, 20);
3924 3927
3925 // Test scrolling the focused node 3928 // Test scrolling the focused node
3926 // The edit box is shorter and narrower than the viewport when legible. 3929 // The edit box is shorter and narrower than the viewport when legible.
3927 web_view_helper.WebView()->AdvanceFocus(false); 3930 web_view_helper.WebView()->AdvanceFocus(false);
3928 // Set the caret to the end of the input box. 3931 // Set the caret to the end of the input box.
3929 web_view_helper.WebView() 3932 web_view_helper.WebView()
3930 ->MainFrame() 3933 ->MainFrameImpl()
3931 ->GetDocument() 3934 ->GetDocument()
3932 .GetElementById("EditBoxWithText") 3935 .GetElementById("EditBoxWithText")
3933 .To<WebInputElement>() 3936 .To<WebInputElement>()
3934 .SetSelectionRange(1000, 1000); 3937 .SetSelectionRange(1000, 1000);
3935 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 3938 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
3936 WebRect rect, caret; 3939 WebRect rect, caret;
3937 web_view_helper.WebView()->SelectionBounds(caret, rect); 3940 web_view_helper.WebView()->SelectionBounds(caret, rect);
3938 3941
3939 // Set the page scale to be smaller than the minimal readable scale. 3942 // Set the page scale to be smaller than the minimal readable scale.
3940 float initial_scale = min_readable_caret_height / caret.height * 0.5f; 3943 float initial_scale = min_readable_caret_height / caret.height * 0.5f;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4017 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled( 4020 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled(
4018 false); 4021 false);
4019 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight)); 4022 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight));
4020 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 4023 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
4021 4024
4022 const WebRect edit_box_with_text(200, 200, 250, 20); 4025 const WebRect edit_box_with_text(200, 200, 250, 20);
4023 4026
4024 web_view_helper.WebView()->AdvanceFocus(false); 4027 web_view_helper.WebView()->AdvanceFocus(false);
4025 // Set the caret to the begining of the input box. 4028 // Set the caret to the begining of the input box.
4026 web_view_helper.WebView() 4029 web_view_helper.WebView()
4027 ->MainFrame() 4030 ->MainFrameImpl()
4028 ->GetDocument() 4031 ->GetDocument()
4029 .GetElementById("EditBoxWithText") 4032 .GetElementById("EditBoxWithText")
4030 .To<WebInputElement>() 4033 .To<WebInputElement>()
4031 .SetSelectionRange(0, 0); 4034 .SetSelectionRange(0, 0);
4032 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 4035 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
4033 WebRect rect, caret; 4036 WebRect rect, caret;
4034 web_view_helper.WebView()->SelectionBounds(caret, rect); 4037 web_view_helper.WebView()->SelectionBounds(caret, rect);
4035 4038
4036 // Set the page scale to be twice as large as the minimal readable scale. 4039 // Set the page scale to be twice as large as the minimal readable scale.
4037 float new_scale = kMinReadableCaretHeight / caret.height * 2.0; 4040 float new_scale = kMinReadableCaretHeight / caret.height * 2.0;
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 } 5323 }
5321 5324
5322 static WebPoint BottomRightMinusOne(const WebRect& rect) { 5325 static WebPoint BottomRightMinusOne(const WebRect& rect) {
5323 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the 5326 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the
5324 // selection bounds, selectRange() will select the *next* element. That's 5327 // selection bounds, selectRange() will select the *next* element. That's
5325 // strictly correct, as hit-testing checks the pixel to the lower-right of 5328 // strictly correct, as hit-testing checks the pixel to the lower-right of
5326 // the input coordinate, but it's a wart on the API. 5329 // the input coordinate, but it's a wart on the API.
5327 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 5330 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
5328 } 5331 }
5329 5332
5330 static WebRect ElementBounds(WebFrame* frame, const WebString& id) { 5333 static WebRect ElementBounds(WebLocalFrame* frame, const WebString& id) {
5331 return frame->GetDocument().GetElementById(id).BoundsInViewport(); 5334 return frame->GetDocument().GetElementById(id).BoundsInViewport();
5332 } 5335 }
5333 5336
5334 static std::string SelectionAsString(WebFrame* frame) { 5337 static std::string SelectionAsString(WebFrame* frame) {
5335 return frame->ToWebLocalFrame()->SelectionAsText().Utf8(); 5338 return frame->ToWebLocalFrame()->SelectionAsText().Utf8();
5336 } 5339 }
5337 5340
5338 TEST_P(ParameterizedWebFrameTest, SelectRange) { 5341 TEST_P(ParameterizedWebFrameTest, SelectRange) {
5339 WebLocalFrame* frame; 5342 WebLocalFrame* frame;
5340 WebRect start_web_rect; 5343 WebRect start_web_rect;
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
6697 WebVector<unsigned> offsets2; 6700 WebVector<unsigned> offsets2;
6698 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument()); 6701 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument());
6699 EXPECT_EQ(0U, offsets2.size()); 6702 EXPECT_EQ(0U, offsets2.size());
6700 } 6703 }
6701 6704
6702 class StubbornTextCheckClient : public WebTextCheckClient { 6705 class StubbornTextCheckClient : public WebTextCheckClient {
6703 public: 6706 public:
6704 StubbornTextCheckClient() : completion_(0) {} 6707 StubbornTextCheckClient() : completion_(0) {}
6705 virtual ~StubbornTextCheckClient() {} 6708 virtual ~StubbornTextCheckClient() {}
6706 6709
6707 virtual void RequestCheckingOfText( 6710 void RequestCheckingOfText(const WebString&,
6708 const WebString&, 6711 WebTextCheckingCompletion* completion) override {
6709 WebTextCheckingCompletion* completion) override {
6710 completion_ = completion; 6712 completion_ = completion;
6711 } 6713 }
6712 6714
6713 void CancelAllPendingRequests() override { 6715 void CancelAllPendingRequests() override {
6714 if (!completion_) 6716 if (!completion_)
6715 return; 6717 return;
6716 completion_->DidCancelCheckingText(); 6718 completion_->DidCancelCheckingText();
6717 completion_ = nullptr; 6719 completion_ = nullptr;
6718 } 6720 }
6719 6721
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
7168 test_url, redirect_response, file_path); 7170 test_url, redirect_response, file_path);
7169 7171
7170 WebURLResponse final_response; 7172 WebURLResponse final_response;
7171 final_response.SetMIMEType("text/html"); 7173 final_response.SetMIMEType("text/html");
7172 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL( 7174 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL(
7173 redirect_url, final_response, file_path); 7175 redirect_url, final_response, file_path);
7174 7176
7175 FrameTestHelpers::WebViewHelper web_view_helper; 7177 FrameTestHelpers::WebViewHelper web_view_helper;
7176 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html"); 7178 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html");
7177 EXPECT_TRUE(web_view_helper.WebView() 7179 EXPECT_TRUE(web_view_helper.WebView()
7178 ->MainFrame() 7180 ->MainFrameImpl()
7179 ->GetDocument() 7181 ->GetDocument()
7180 .FirstPartyForCookies() == redirect_url); 7182 .FirstPartyForCookies() == redirect_url);
7181 } 7183 }
7182 7184
7183 class TestNavigationPolicyWebFrameClient 7185 class TestNavigationPolicyWebFrameClient
7184 : public FrameTestHelpers::TestWebFrameClient { 7186 : public FrameTestHelpers::TestWebFrameClient {
7185 public: 7187 public:
7186 void DidNavigateWithinPage(const WebHistoryItem&, 7188 void DidNavigateWithinPage(const WebHistoryItem&,
7187 WebHistoryCommitType, 7189 WebHistoryCommitType,
7188 bool) override { 7190 bool) override {
(...skipping 22 matching lines...) Expand all
7211 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer); 7213 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer);
7212 FrameLoadRequest frame_request(document, ResourceRequest(destination)); 7214 FrameLoadRequest frame_request(document, ResourceRequest(destination));
7213 frame_request.SetTriggeringEvent(event); 7215 frame_request.SetTriggeringEvent(event);
7214 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame()) 7216 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame())
7215 ->Loader() 7217 ->Loader()
7216 .Load(frame_request); 7218 .Load(frame_request);
7217 } 7219 }
7218 7220
7219 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { 7221 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient {
7220 public: 7222 public:
7221 virtual WebView* CreateView(WebLocalFrame*, 7223 WebView* CreateView(WebLocalFrame*,
7222 const WebURLRequest&, 7224 const WebURLRequest&,
7223 const WebWindowFeatures&, 7225 const WebWindowFeatures&,
7224 const WebString&, 7226 const WebString&,
7225 WebNavigationPolicy, 7227 WebNavigationPolicy,
7226 bool) override { 7228 bool) override {
7227 EXPECT_TRUE(false); 7229 EXPECT_TRUE(false);
7228 return 0; 7230 return 0;
7229 } 7231 }
7230 }; 7232 };
7231 7233
7232 class TestNewWindowWebFrameClient 7234 class TestNewWindowWebFrameClient
7233 : public FrameTestHelpers::TestWebFrameClient { 7235 : public FrameTestHelpers::TestWebFrameClient {
7234 public: 7236 public:
7235 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {} 7237 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {}
7236 7238
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
7695 7697
7696 TestHistoryWebFrameClient client; 7698 TestHistoryWebFrameClient client;
7697 FrameTestHelpers::WebViewHelper web_view_helper; 7699 FrameTestHelpers::WebViewHelper web_view_helper;
7698 web_view_helper.InitializeAndLoad("about:blank", &client); 7700 web_view_helper.InitializeAndLoad("about:blank", &client);
7699 7701
7700 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); 7702 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl();
7701 7703
7702 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( 7704 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8(
7703 "document.body.appendChild(document.createElement('iframe'))"))); 7705 "document.body.appendChild(document.createElement('iframe'))")));
7704 7706
7705 WebFrame* iframe = frame->FirstChild(); 7707 WebLocalFrameBase* iframe = ToWebLocalFrameBase(frame->FirstChild());
7706 ASSERT_EQ(&client.ChildClient(), ToWebLocalFrameBase(iframe)->Client()); 7708 ASSERT_EQ(&client.ChildClient(), iframe->Client());
7707 7709
7708 std::string url1 = base_url_ + "history.html"; 7710 std::string url1 = base_url_ + "history.html";
7709 FrameTestHelpers::LoadFrame(iframe, url1); 7711 FrameTestHelpers::LoadFrame(iframe, url1);
7710 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); 7712 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8());
7711 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem()); 7713 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem());
7712 7714
7713 std::string url2 = base_url_ + "find.html"; 7715 std::string url2 = base_url_ + "find.html";
7714 FrameTestHelpers::LoadFrame(iframe, url2); 7716 FrameTestHelpers::LoadFrame(iframe, url2);
7715 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); 7717 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8());
7716 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); 7718 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem());
7717 } 7719 }
7718 7720
7719 // Tests that a navigation in a frame with a non-blank initial URL will create 7721 // Tests that a navigation in a frame with a non-blank initial URL will create
7720 // a new history item, unlike the case above. 7722 // a new history item, unlike the case above.
7721 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { 7723 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) {
7722 RegisterMockedHttpURLLoad("history.html"); 7724 RegisterMockedHttpURLLoad("history.html");
7723 RegisterMockedHttpURLLoad("find.html"); 7725 RegisterMockedHttpURLLoad("find.html");
7724 7726
7725 TestHistoryWebFrameClient client; 7727 TestHistoryWebFrameClient client;
7726 FrameTestHelpers::WebViewHelper web_view_helper; 7728 FrameTestHelpers::WebViewHelper web_view_helper;
7727 web_view_helper.InitializeAndLoad("about:blank", &client); 7729 web_view_helper.InitializeAndLoad("about:blank", &client);
7728 7730
7729 WebFrame* frame = web_view_helper.WebView()->MainFrame(); 7731 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl();
dcheng 2017/06/20 09:02:21 Nit: this can just be web_view_helper.LocalMainFra
dcheng 2017/06/20 09:03:13 (Of course this only applies when there's an acces
Łukasz Anforowicz 2017/06/20 16:59:44 This cleanup opportunity impacts more lines than t
7730 7732
7731 std::string url1 = base_url_ + "history.html"; 7733 std::string url1 = base_url_ + "history.html";
7732 FrameTestHelpers::LoadFrame( 7734 FrameTestHelpers::LoadFrame(
7733 frame, 7735 frame,
7734 "javascript:var f = document.createElement('iframe'); " 7736 "javascript:var f = document.createElement('iframe'); "
7735 "f.src = '" + 7737 "f.src = '" +
7736 url1 + 7738 url1 +
7737 "';" 7739 "';"
7738 "document.body.appendChild(f)"); 7740 "document.body.appendChild(f)");
7739 7741
7740 WebFrame* iframe = frame->FirstChild(); 7742 WebLocalFrame* iframe = frame->FirstChild()->ToWebLocalFrame();
7741 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); 7743 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8());
7742 7744
7743 std::string url2 = base_url_ + "find.html"; 7745 std::string url2 = base_url_ + "find.html";
7744 FrameTestHelpers::LoadFrame(iframe, url2); 7746 FrameTestHelpers::LoadFrame(iframe, url2);
7745 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); 7747 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8());
7746 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); 7748 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem());
7747 } 7749 }
7748 7750
7749 // Test verifies that layout will change a layer's scrollable attibutes 7751 // Test verifies that layout will change a layer's scrollable attibutes
7750 TEST_F(WebFrameTest, overflowHiddenRewrite) { 7752 TEST_F(WebFrameTest, overflowHiddenRewrite) {
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
9590 remote_frame->Swap(local_frame); 9592 remote_frame->Swap(local_frame);
9591 9593
9592 // And the opener cycle should still be preserved. 9594 // And the opener cycle should still be preserved.
9593 EXPECT_EQ(local_frame, local_frame->Opener()); 9595 EXPECT_EQ(local_frame, local_frame->Opener());
9594 9596
9595 view->Close(); 9597 view->Close();
9596 } 9598 }
9597 9599
9598 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 9600 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
9599 public: 9601 public:
9600 explicit CommitTypeWebFrameClient() 9602 CommitTypeWebFrameClient() : history_commit_type_(kWebHistoryInertCommit) {}
9601 : history_commit_type_(kWebHistoryInertCommit) {}
9602 9603
9603 void DidCommitProvisionalLoad( 9604 void DidCommitProvisionalLoad(
9604 const WebHistoryItem&, 9605 const WebHistoryItem&,
9605 WebHistoryCommitType history_commit_type) override { 9606 WebHistoryCommitType history_commit_type) override {
9606 history_commit_type_ = history_commit_type; 9607 history_commit_type_ = history_commit_type;
9607 } 9608 }
9608 9609
9609 WebHistoryCommitType HistoryCommitType() const { 9610 WebHistoryCommitType HistoryCommitType() const {
9610 return history_commit_type_; 9611 return history_commit_type_;
9611 } 9612 }
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
10698 local_frame->CopyImageAt(WebPoint(50, 50)); 10699 local_frame->CopyImageAt(WebPoint(50, 50));
10699 10700
10700 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10701 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10701 WebClipboard::kBufferStandard)); 10702 WebClipboard::kBufferStandard));
10702 10703
10703 WebImage image = 10704 WebImage image =
10704 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10705 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10705 ->ReadRawImage(WebClipboard::Buffer()); 10706 ->ReadRawImage(WebClipboard::Buffer());
10706 10707
10707 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10708 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10708 }; 10709 }
10709 10710
10710 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { 10711 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) {
10711 std::string url = base_url_ + "canvas-copy-image.html"; 10712 std::string url = base_url_ + "canvas-copy-image.html";
10712 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html"); 10713 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html");
10713 10714
10714 FrameTestHelpers::WebViewHelper helper; 10715 FrameTestHelpers::WebViewHelper helper;
10715 WebViewBase* web_view = helper.InitializeAndLoad(url); 10716 WebViewBase* web_view = helper.InitializeAndLoad(url);
10716 web_view->Resize(WebSize(400, 400)); 10717 web_view->Resize(WebSize(400, 400));
10717 web_view->UpdateAllLifecyclePhases(); 10718 web_view->UpdateAllLifecyclePhases();
10718 web_view->SetPageScaleFactor(2); 10719 web_view->SetPageScaleFactor(2);
10719 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200)); 10720 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200));
10720 10721
10721 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber( 10722 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber(
10722 WebClipboard::kBufferStandard); 10723 WebClipboard::kBufferStandard);
10723 10724
10724 WebLocalFrame* local_frame = web_view->MainFrameImpl(); 10725 WebLocalFrame* local_frame = web_view->MainFrameImpl();
10725 local_frame->CopyImageAt(WebPoint(0, 0)); 10726 local_frame->CopyImageAt(WebPoint(0, 0));
10726 10727
10727 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10728 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10728 WebClipboard::kBufferStandard)); 10729 WebClipboard::kBufferStandard));
10729 10730
10730 WebImage image = 10731 WebImage image =
10731 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10732 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10732 ->ReadRawImage(WebClipboard::Buffer()); 10733 ->ReadRawImage(WebClipboard::Buffer());
10733 10734
10734 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10735 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10735 }; 10736 }
10736 10737
10737 TEST_F(WebFrameTest, CopyImageWithImageMap) { 10738 TEST_F(WebFrameTest, CopyImageWithImageMap) {
10738 SaveImageFromDataURLWebFrameClient client; 10739 SaveImageFromDataURLWebFrameClient client;
10739 10740
10740 std::string url = base_url_ + "image-map.html"; 10741 std::string url = base_url_ + "image-map.html";
10741 RegisterMockedURLLoadFromBase(base_url_, "image-map.html"); 10742 RegisterMockedURLLoadFromBase(base_url_, "image-map.html");
10742 10743
10743 FrameTestHelpers::WebViewHelper helper; 10744 FrameTestHelpers::WebViewHelper helper;
10744 WebViewBase* web_view = helper.InitializeAndLoad(url, &client); 10745 WebViewBase* web_view = helper.InitializeAndLoad(url, &client);
10745 web_view->Resize(WebSize(400, 400)); 10746 web_view->Resize(WebSize(400, 400));
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
12032 12033
12033 // Verify that the right WebWidgetClient has been notified. 12034 // Verify that the right WebWidgetClient has been notified.
12034 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard()); 12035 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard());
12035 12036
12036 remote_frame->Close(); 12037 remote_frame->Close();
12037 web_view_helper.Reset(); 12038 web_view_helper.Reset();
12038 } 12039 }
12039 12040
12040 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 12041 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
12041 public: 12042 public:
12042 ContextMenuWebFrameClient(){}; 12043 ContextMenuWebFrameClient() {}
12043 // WebFrameClient methods 12044 // WebFrameClient methods
12044 void ShowContextMenu(const WebContextMenuData& data) override { 12045 void ShowContextMenu(const WebContextMenuData& data) override {
12045 menu_data_ = data; 12046 menu_data_ = data;
12046 } 12047 }
12047 12048
12048 WebContextMenuData GetMenuData() { return menu_data_; } 12049 WebContextMenuData GetMenuData() { return menu_data_; }
12049 12050
12050 private: 12051 private:
12051 WebContextMenuData menu_data_; 12052 WebContextMenuData menu_data_;
12052 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient); 12053 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
12129 12130
12130 // Local frame with remote parent should have transparent baseBackgroundColor. 12131 // Local frame with remote parent should have transparent baseBackgroundColor.
12131 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); 12132 Color color = local_frame->GetFrameView()->BaseBackgroundColor();
12132 EXPECT_EQ(Color::kTransparent, color); 12133 EXPECT_EQ(Color::kTransparent, color);
12133 12134
12134 view->Close(); 12135 view->Close();
12135 } 12136 }
12136 12137
12137 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 12138 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
12138 public: 12139 public:
12139 explicit TestFallbackWebFrameClient() : child_client_(nullptr) {} 12140 TestFallbackWebFrameClient() : child_client_(nullptr) {}
12140 12141
12141 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) { 12142 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) {
12142 child_client_ = client; 12143 child_client_ = client;
12143 } 12144 }
12144 12145
12145 WebLocalFrame* CreateChildFrame( 12146 WebLocalFrame* CreateChildFrame(
12146 WebLocalFrame* parent, 12147 WebLocalFrame* parent,
12147 WebTreeScopeType scope, 12148 WebTreeScopeType scope,
12148 const WebString&, 12149 const WebString&,
12149 const WebString&, 12150 const WebString&,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
12218 if (obj->IsText()) { 12219 if (obj->IsText()) {
12219 LayoutText* layout_text = ToLayoutText(obj); 12220 LayoutText* layout_text = ToLayoutText(obj);
12220 text = layout_text->GetText(); 12221 text = layout_text->GetText();
12221 break; 12222 break;
12222 } 12223 }
12223 } 12224 }
12224 EXPECT_EQ("foo alt", text.Utf8()); 12225 EXPECT_EQ("foo alt", text.Utf8());
12225 } 12226 }
12226 12227
12227 } // namespace blink 12228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698