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

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

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Addressed CR feedback from alexmos@. 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 EXPECT_EQ(String(), callback_helper.StringValue()); 617 EXPECT_EQ(String(), callback_helper.StringValue());
616 } 618 }
617 619
618 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) { 620 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) {
619 RegisterMockedHttpURLLoad("form.html"); 621 RegisterMockedHttpURLLoad("form.html");
620 622
621 FrameTestHelpers::WebViewHelper web_view_helper; 623 FrameTestHelpers::WebViewHelper web_view_helper;
622 web_view_helper.InitializeAndLoad(base_url_ + "form.html"); 624 web_view_helper.InitializeAndLoad(base_url_ + "form.html");
623 625
624 WebVector<WebFormElement> forms; 626 WebVector<WebFormElement> forms;
625 web_view_helper.WebView()->MainFrame()->GetDocument().Forms(forms); 627 web_view_helper.WebView()->MainFrameImpl()->GetDocument().Forms(forms);
626 web_view_helper.Reset(); 628 web_view_helper.Reset();
627 629
628 EXPECT_EQ(forms.size(), 1U); 630 EXPECT_EQ(forms.size(), 1U);
629 631
630 // This test passes if this doesn't crash. 632 // This test passes if this doesn't crash.
631 WebSearchableFormData searchable_data_form(forms[0]); 633 WebSearchableFormData searchable_data_form(forms[0]);
632 } 634 }
633 635
634 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) { 636 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) {
635 RegisterMockedChromeURLLoad("history.html"); 637 RegisterMockedChromeURLLoad("history.html");
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1005
1004 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) { 1006 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) {
1005 RegisterMockedHttpURLLoad("postmessage_test.html"); 1007 RegisterMockedHttpURLLoad("postmessage_test.html");
1006 1008
1007 FrameTestHelpers::WebViewHelper web_view_helper; 1009 FrameTestHelpers::WebViewHelper web_view_helper;
1008 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html"); 1010 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html");
1009 1011
1010 // Send a message with the correct origin. 1012 // Send a message with the correct origin.
1011 WebSecurityOrigin correct_origin( 1013 WebSecurityOrigin correct_origin(
1012 WebSecurityOrigin::Create(ToKURL(base_url_))); 1014 WebSecurityOrigin::Create(ToKURL(base_url_)));
1013 WebDocument document = web_view_helper.WebView()->MainFrame()->GetDocument(); 1015 WebDocument document =
1016 web_view_helper.WebView()->MainFrameImpl()->GetDocument();
1014 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid()); 1017 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid());
1015 WebDOMMessageEvent message(data, "http://origin.com"); 1018 WebDOMMessageEvent message(data, "http://origin.com");
1016 web_view_helper.WebView() 1019 web_view_helper.WebView()
1017 ->MainFrameImpl() 1020 ->MainFrameImpl()
1018 ->DispatchMessageEventWithOriginCheck(correct_origin, message); 1021 ->DispatchMessageEventWithOriginCheck(correct_origin, message);
1019 1022
1020 // Send another message with incorrect origin. 1023 // Send another message with incorrect origin.
1021 WebSecurityOrigin incorrect_origin( 1024 WebSecurityOrigin incorrect_origin(
1022 WebSecurityOrigin::Create(ToKURL(chrome_url_))); 1025 WebSecurityOrigin::Create(ToKURL(chrome_url_)));
1023 web_view_helper.WebView() 1026 web_view_helper.WebView()
(...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 3910 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
3908 3911
3909 WebRect edit_box_with_text(200, 200, 250, 20); 3912 WebRect edit_box_with_text(200, 200, 250, 20);
3910 WebRect edit_box_with_no_text(200, 250, 250, 20); 3913 WebRect edit_box_with_no_text(200, 250, 250, 20);
3911 3914
3912 // Test scrolling the focused node 3915 // Test scrolling the focused node
3913 // The edit box is shorter and narrower than the viewport when legible. 3916 // The edit box is shorter and narrower than the viewport when legible.
3914 web_view_helper.WebView()->AdvanceFocus(false); 3917 web_view_helper.WebView()->AdvanceFocus(false);
3915 // Set the caret to the end of the input box. 3918 // Set the caret to the end of the input box.
3916 web_view_helper.WebView() 3919 web_view_helper.WebView()
3917 ->MainFrame() 3920 ->MainFrameImpl()
3918 ->GetDocument() 3921 ->GetDocument()
3919 .GetElementById("EditBoxWithText") 3922 .GetElementById("EditBoxWithText")
3920 .To<WebInputElement>() 3923 .To<WebInputElement>()
3921 .SetSelectionRange(1000, 1000); 3924 .SetSelectionRange(1000, 1000);
3922 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 3925 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
3923 WebRect rect, caret; 3926 WebRect rect, caret;
3924 web_view_helper.WebView()->SelectionBounds(caret, rect); 3927 web_view_helper.WebView()->SelectionBounds(caret, rect);
3925 3928
3926 // Set the page scale to be smaller than the minimal readable scale. 3929 // Set the page scale to be smaller than the minimal readable scale.
3927 float initial_scale = min_readable_caret_height / caret.height * 0.5f; 3930 float initial_scale = min_readable_caret_height / caret.height * 0.5f;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4004 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled( 4007 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled(
4005 false); 4008 false);
4006 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight)); 4009 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight));
4007 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 4010 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
4008 4011
4009 const WebRect edit_box_with_text(200, 200, 250, 20); 4012 const WebRect edit_box_with_text(200, 200, 250, 20);
4010 4013
4011 web_view_helper.WebView()->AdvanceFocus(false); 4014 web_view_helper.WebView()->AdvanceFocus(false);
4012 // Set the caret to the begining of the input box. 4015 // Set the caret to the begining of the input box.
4013 web_view_helper.WebView() 4016 web_view_helper.WebView()
4014 ->MainFrame() 4017 ->MainFrameImpl()
4015 ->GetDocument() 4018 ->GetDocument()
4016 .GetElementById("EditBoxWithText") 4019 .GetElementById("EditBoxWithText")
4017 .To<WebInputElement>() 4020 .To<WebInputElement>()
4018 .SetSelectionRange(0, 0); 4021 .SetSelectionRange(0, 0);
4019 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 4022 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
4020 WebRect rect, caret; 4023 WebRect rect, caret;
4021 web_view_helper.WebView()->SelectionBounds(caret, rect); 4024 web_view_helper.WebView()->SelectionBounds(caret, rect);
4022 4025
4023 // Set the page scale to be twice as large as the minimal readable scale. 4026 // Set the page scale to be twice as large as the minimal readable scale.
4024 float new_scale = kMinReadableCaretHeight / caret.height * 2.0; 4027 float new_scale = kMinReadableCaretHeight / caret.height * 2.0;
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5307 } 5310 }
5308 5311
5309 static WebPoint BottomRightMinusOne(const WebRect& rect) { 5312 static WebPoint BottomRightMinusOne(const WebRect& rect) {
5310 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the 5313 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the
5311 // selection bounds, selectRange() will select the *next* element. That's 5314 // selection bounds, selectRange() will select the *next* element. That's
5312 // strictly correct, as hit-testing checks the pixel to the lower-right of 5315 // strictly correct, as hit-testing checks the pixel to the lower-right of
5313 // the input coordinate, but it's a wart on the API. 5316 // the input coordinate, but it's a wart on the API.
5314 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 5317 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
5315 } 5318 }
5316 5319
5317 static WebRect ElementBounds(WebFrame* frame, const WebString& id) { 5320 static WebRect ElementBounds(WebLocalFrame* frame, const WebString& id) {
5318 return frame->GetDocument().GetElementById(id).BoundsInViewport(); 5321 return frame->GetDocument().GetElementById(id).BoundsInViewport();
5319 } 5322 }
5320 5323
5321 static std::string SelectionAsString(WebFrame* frame) { 5324 static std::string SelectionAsString(WebFrame* frame) {
5322 return frame->ToWebLocalFrame()->SelectionAsText().Utf8(); 5325 return frame->ToWebLocalFrame()->SelectionAsText().Utf8();
5323 } 5326 }
5324 5327
5325 TEST_P(ParameterizedWebFrameTest, SelectRange) { 5328 TEST_P(ParameterizedWebFrameTest, SelectRange) {
5326 WebLocalFrame* frame; 5329 WebLocalFrame* frame;
5327 WebRect start_web_rect; 5330 WebRect start_web_rect;
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
6684 WebVector<unsigned> offsets2; 6687 WebVector<unsigned> offsets2;
6685 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument()); 6688 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument());
6686 EXPECT_EQ(0U, offsets2.size()); 6689 EXPECT_EQ(0U, offsets2.size());
6687 } 6690 }
6688 6691
6689 class StubbornTextCheckClient : public WebTextCheckClient { 6692 class StubbornTextCheckClient : public WebTextCheckClient {
6690 public: 6693 public:
6691 StubbornTextCheckClient() : completion_(0) {} 6694 StubbornTextCheckClient() : completion_(0) {}
6692 virtual ~StubbornTextCheckClient() {} 6695 virtual ~StubbornTextCheckClient() {}
6693 6696
6694 virtual void RequestCheckingOfText( 6697 void RequestCheckingOfText(const WebString&,
6695 const WebString&, 6698 WebTextCheckingCompletion* completion) override {
6696 WebTextCheckingCompletion* completion) override {
6697 completion_ = completion; 6699 completion_ = completion;
6698 } 6700 }
6699 6701
6700 void CancelAllPendingRequests() override { 6702 void CancelAllPendingRequests() override {
6701 if (!completion_) 6703 if (!completion_)
6702 return; 6704 return;
6703 completion_->DidCancelCheckingText(); 6705 completion_->DidCancelCheckingText();
6704 completion_ = nullptr; 6706 completion_ = nullptr;
6705 } 6707 }
6706 6708
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
7155 test_url, redirect_response, file_path); 7157 test_url, redirect_response, file_path);
7156 7158
7157 WebURLResponse final_response; 7159 WebURLResponse final_response;
7158 final_response.SetMIMEType("text/html"); 7160 final_response.SetMIMEType("text/html");
7159 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL( 7161 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL(
7160 redirect_url, final_response, file_path); 7162 redirect_url, final_response, file_path);
7161 7163
7162 FrameTestHelpers::WebViewHelper web_view_helper; 7164 FrameTestHelpers::WebViewHelper web_view_helper;
7163 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html"); 7165 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html");
7164 EXPECT_TRUE(web_view_helper.WebView() 7166 EXPECT_TRUE(web_view_helper.WebView()
7165 ->MainFrame() 7167 ->MainFrameImpl()
7166 ->GetDocument() 7168 ->GetDocument()
7167 .FirstPartyForCookies() == redirect_url); 7169 .FirstPartyForCookies() == redirect_url);
7168 } 7170 }
7169 7171
7170 class TestNavigationPolicyWebFrameClient 7172 class TestNavigationPolicyWebFrameClient
7171 : public FrameTestHelpers::TestWebFrameClient { 7173 : public FrameTestHelpers::TestWebFrameClient {
7172 public: 7174 public:
7173 void DidNavigateWithinPage(const WebHistoryItem&, 7175 void DidNavigateWithinPage(const WebHistoryItem&,
7174 WebHistoryCommitType, 7176 WebHistoryCommitType,
7175 bool) override { 7177 bool) override {
(...skipping 22 matching lines...) Expand all
7198 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer); 7200 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer);
7199 FrameLoadRequest frame_request(document, ResourceRequest(destination)); 7201 FrameLoadRequest frame_request(document, ResourceRequest(destination));
7200 frame_request.SetTriggeringEvent(event); 7202 frame_request.SetTriggeringEvent(event);
7201 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame()) 7203 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame())
7202 ->Loader() 7204 ->Loader()
7203 .Load(frame_request); 7205 .Load(frame_request);
7204 } 7206 }
7205 7207
7206 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { 7208 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient {
7207 public: 7209 public:
7208 virtual WebView* CreateView(WebLocalFrame*, 7210 WebView* CreateView(WebLocalFrame*,
7209 const WebURLRequest&, 7211 const WebURLRequest&,
7210 const WebWindowFeatures&, 7212 const WebWindowFeatures&,
7211 const WebString&, 7213 const WebString&,
7212 WebNavigationPolicy, 7214 WebNavigationPolicy,
7213 bool) override { 7215 bool) override {
7214 EXPECT_TRUE(false); 7216 EXPECT_TRUE(false);
7215 return 0; 7217 return 0;
7216 } 7218 }
7217 }; 7219 };
7218 7220
7219 class TestNewWindowWebFrameClient 7221 class TestNewWindowWebFrameClient
7220 : public FrameTestHelpers::TestWebFrameClient { 7222 : public FrameTestHelpers::TestWebFrameClient {
7221 public: 7223 public:
7222 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {} 7224 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {}
7223 7225
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
7682 7684
7683 TestHistoryWebFrameClient client; 7685 TestHistoryWebFrameClient client;
7684 FrameTestHelpers::WebViewHelper web_view_helper; 7686 FrameTestHelpers::WebViewHelper web_view_helper;
7685 web_view_helper.InitializeAndLoad("about:blank", &client); 7687 web_view_helper.InitializeAndLoad("about:blank", &client);
7686 7688
7687 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); 7689 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl();
7688 7690
7689 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( 7691 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8(
7690 "document.body.appendChild(document.createElement('iframe'))"))); 7692 "document.body.appendChild(document.createElement('iframe'))")));
7691 7693
7692 WebLocalFrame* iframe = frame->FirstChild()->ToWebLocalFrame(); 7694 WebLocalFrameBase* iframe = ToWebLocalFrameBase(frame->FirstChild());
7693 ASSERT_EQ(&client.ChildClient(), ToWebLocalFrameBase(iframe)->Client()); 7695 ASSERT_EQ(&client.ChildClient(), iframe->Client());
7694 7696
7695 std::string url1 = base_url_ + "history.html"; 7697 std::string url1 = base_url_ + "history.html";
7696 FrameTestHelpers::LoadFrame(iframe, url1); 7698 FrameTestHelpers::LoadFrame(iframe, url1);
7697 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); 7699 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8());
7698 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem()); 7700 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem());
7699 7701
7700 std::string url2 = base_url_ + "find.html"; 7702 std::string url2 = base_url_ + "find.html";
7701 FrameTestHelpers::LoadFrame(iframe, url2); 7703 FrameTestHelpers::LoadFrame(iframe, url2);
7702 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); 7704 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8());
7703 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); 7705 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem());
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
9436 WebLocalFrame* local_frame = 9438 WebLocalFrame* local_frame =
9437 FrameTestHelpers::CreateProvisional(*remote_frame); 9439 FrameTestHelpers::CreateProvisional(*remote_frame);
9438 remote_frame->Swap(local_frame); 9440 remote_frame->Swap(local_frame);
9439 9441
9440 // And the opener cycle should still be preserved. 9442 // And the opener cycle should still be preserved.
9441 EXPECT_EQ(local_frame, local_frame->Opener()); 9443 EXPECT_EQ(local_frame, local_frame->Opener());
9442 } 9444 }
9443 9445
9444 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 9446 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
9445 public: 9447 public:
9446 explicit CommitTypeWebFrameClient() 9448 CommitTypeWebFrameClient() : history_commit_type_(kWebHistoryInertCommit) {}
9447 : history_commit_type_(kWebHistoryInertCommit) {}
9448 9449
9449 void DidCommitProvisionalLoad( 9450 void DidCommitProvisionalLoad(
9450 const WebHistoryItem&, 9451 const WebHistoryItem&,
9451 WebHistoryCommitType history_commit_type) override { 9452 WebHistoryCommitType history_commit_type) override {
9452 history_commit_type_ = history_commit_type; 9453 history_commit_type_ = history_commit_type;
9453 } 9454 }
9454 9455
9455 WebHistoryCommitType HistoryCommitType() const { 9456 WebHistoryCommitType HistoryCommitType() const {
9456 return history_commit_type_; 9457 return history_commit_type_;
9457 } 9458 }
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
10505 local_frame->CopyImageAt(WebPoint(50, 50)); 10506 local_frame->CopyImageAt(WebPoint(50, 50));
10506 10507
10507 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10508 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10508 WebClipboard::kBufferStandard)); 10509 WebClipboard::kBufferStandard));
10509 10510
10510 WebImage image = 10511 WebImage image =
10511 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10512 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10512 ->ReadRawImage(WebClipboard::Buffer()); 10513 ->ReadRawImage(WebClipboard::Buffer());
10513 10514
10514 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10515 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10515 }; 10516 }
10516 10517
10517 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { 10518 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) {
10518 std::string url = base_url_ + "canvas-copy-image.html"; 10519 std::string url = base_url_ + "canvas-copy-image.html";
10519 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html"); 10520 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html");
10520 10521
10521 FrameTestHelpers::WebViewHelper helper; 10522 FrameTestHelpers::WebViewHelper helper;
10522 WebViewBase* web_view = helper.InitializeAndLoad(url); 10523 WebViewBase* web_view = helper.InitializeAndLoad(url);
10523 web_view->Resize(WebSize(400, 400)); 10524 web_view->Resize(WebSize(400, 400));
10524 web_view->UpdateAllLifecyclePhases(); 10525 web_view->UpdateAllLifecyclePhases();
10525 web_view->SetPageScaleFactor(2); 10526 web_view->SetPageScaleFactor(2);
10526 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200)); 10527 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200));
10527 10528
10528 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber( 10529 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber(
10529 WebClipboard::kBufferStandard); 10530 WebClipboard::kBufferStandard);
10530 10531
10531 WebLocalFrame* local_frame = web_view->MainFrameImpl(); 10532 WebLocalFrame* local_frame = web_view->MainFrameImpl();
10532 local_frame->CopyImageAt(WebPoint(0, 0)); 10533 local_frame->CopyImageAt(WebPoint(0, 0));
10533 10534
10534 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10535 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10535 WebClipboard::kBufferStandard)); 10536 WebClipboard::kBufferStandard));
10536 10537
10537 WebImage image = 10538 WebImage image =
10538 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10539 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10539 ->ReadRawImage(WebClipboard::Buffer()); 10540 ->ReadRawImage(WebClipboard::Buffer());
10540 10541
10541 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10542 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10542 }; 10543 }
10543 10544
10544 TEST_F(WebFrameTest, CopyImageWithImageMap) { 10545 TEST_F(WebFrameTest, CopyImageWithImageMap) {
10545 SaveImageFromDataURLWebFrameClient client; 10546 SaveImageFromDataURLWebFrameClient client;
10546 10547
10547 std::string url = base_url_ + "image-map.html"; 10548 std::string url = base_url_ + "image-map.html";
10548 RegisterMockedURLLoadFromBase(base_url_, "image-map.html"); 10549 RegisterMockedURLLoadFromBase(base_url_, "image-map.html");
10549 10550
10550 FrameTestHelpers::WebViewHelper helper; 10551 FrameTestHelpers::WebViewHelper helper;
10551 WebViewBase* web_view = helper.InitializeAndLoad(url, &client); 10552 WebViewBase* web_view = helper.InitializeAndLoad(url, &client);
10552 web_view->Resize(WebSize(400, 400)); 10553 web_view->Resize(WebSize(400, 400));
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
11833 "document.querySelector('input').focus();")); 11834 "document.querySelector('input').focus();"));
11834 11835
11835 // Verify that the right WebWidgetClient has been notified. 11836 // Verify that the right WebWidgetClient has been notified.
11836 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard()); 11837 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard());
11837 11838
11838 web_view_helper.Reset(); 11839 web_view_helper.Reset();
11839 } 11840 }
11840 11841
11841 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 11842 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
11842 public: 11843 public:
11843 ContextMenuWebFrameClient(){}; 11844 ContextMenuWebFrameClient() {}
11844 // WebFrameClient methods 11845 // WebFrameClient methods
11845 void ShowContextMenu(const WebContextMenuData& data) override { 11846 void ShowContextMenu(const WebContextMenuData& data) override {
11846 menu_data_ = data; 11847 menu_data_ = data;
11847 } 11848 }
11848 11849
11849 WebContextMenuData GetMenuData() { return menu_data_; } 11850 WebContextMenuData GetMenuData() { return menu_data_; }
11850 11851
11851 private: 11852 private:
11852 WebContextMenuData menu_data_; 11853 WebContextMenuData menu_data_;
11853 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient); 11854 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
11924 FrameTestHelpers::CreateLocalChild(*helper.RemoteMainFrame()); 11925 FrameTestHelpers::CreateLocalChild(*helper.RemoteMainFrame());
11925 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page"); 11926 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page");
11926 11927
11927 // Local frame with remote parent should have transparent baseBackgroundColor. 11928 // Local frame with remote parent should have transparent baseBackgroundColor.
11928 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); 11929 Color color = local_frame->GetFrameView()->BaseBackgroundColor();
11929 EXPECT_EQ(Color::kTransparent, color); 11930 EXPECT_EQ(Color::kTransparent, color);
11930 } 11931 }
11931 11932
11932 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 11933 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
11933 public: 11934 public:
11934 explicit TestFallbackWebFrameClient() : child_client_(nullptr) {} 11935 TestFallbackWebFrameClient() : child_client_(nullptr) {}
11935 11936
11936 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) { 11937 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) {
11937 child_client_ = client; 11938 child_client_ = client;
11938 } 11939 }
11939 11940
11940 WebLocalFrame* CreateChildFrame( 11941 WebLocalFrame* CreateChildFrame(
11941 WebLocalFrame* parent, 11942 WebLocalFrame* parent,
11942 WebTreeScopeType scope, 11943 WebTreeScopeType scope,
11943 const WebString&, 11944 const WebString&,
11944 const WebString&, 11945 const WebString&,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
12013 if (obj->IsText()) { 12014 if (obj->IsText()) {
12014 LayoutText* layout_text = ToLayoutText(obj); 12015 LayoutText* layout_text = ToLayoutText(obj);
12015 text = layout_text->GetText(); 12016 text = layout_text->GetText();
12016 break; 12017 break;
12017 } 12018 }
12018 } 12019 }
12019 EXPECT_EQ("foo alt", text.Utf8()); 12020 EXPECT_EQ("foo alt", text.Utf8());
12020 } 12021 }
12021 12022
12022 } // namespace blink 12023 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698