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

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

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Split a DCHECK in two as suggested by boliu@. 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 2882 matching lines...) Expand 10 before | Expand all | Expand 10 after
3906 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 3909 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
3907 3910
3908 WebRect edit_box_with_text(200, 200, 250, 20); 3911 WebRect edit_box_with_text(200, 200, 250, 20);
3909 WebRect edit_box_with_no_text(200, 250, 250, 20); 3912 WebRect edit_box_with_no_text(200, 250, 250, 20);
3910 3913
3911 // Test scrolling the focused node 3914 // Test scrolling the focused node
3912 // The edit box is shorter and narrower than the viewport when legible. 3915 // The edit box is shorter and narrower than the viewport when legible.
3913 web_view_helper.WebView()->AdvanceFocus(false); 3916 web_view_helper.WebView()->AdvanceFocus(false);
3914 // Set the caret to the end of the input box. 3917 // Set the caret to the end of the input box.
3915 web_view_helper.WebView() 3918 web_view_helper.WebView()
3916 ->MainFrame() 3919 ->MainFrameImpl()
3917 ->GetDocument() 3920 ->GetDocument()
3918 .GetElementById("EditBoxWithText") 3921 .GetElementById("EditBoxWithText")
3919 .To<WebInputElement>() 3922 .To<WebInputElement>()
3920 .SetSelectionRange(1000, 1000); 3923 .SetSelectionRange(1000, 1000);
3921 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 3924 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
3922 WebRect rect, caret; 3925 WebRect rect, caret;
3923 web_view_helper.WebView()->SelectionBounds(caret, rect); 3926 web_view_helper.WebView()->SelectionBounds(caret, rect);
3924 3927
3925 // Set the page scale to be smaller than the minimal readable scale. 3928 // Set the page scale to be smaller than the minimal readable scale.
3926 float initial_scale = min_readable_caret_height / caret.height * 0.5f; 3929 float initial_scale = min_readable_caret_height / caret.height * 0.5f;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled( 4006 web_view_helper.WebView()->GetPage()->GetSettings().SetTextAutosizingEnabled(
4004 false); 4007 false);
4005 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight)); 4008 web_view_helper.Resize(WebSize(kViewportWidth, kViewportHeight));
4006 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true); 4009 web_view_helper.WebView()->EnableFakePageScaleAnimationForTesting(true);
4007 4010
4008 const WebRect edit_box_with_text(200, 200, 250, 20); 4011 const WebRect edit_box_with_text(200, 200, 250, 20);
4009 4012
4010 web_view_helper.WebView()->AdvanceFocus(false); 4013 web_view_helper.WebView()->AdvanceFocus(false);
4011 // Set the caret to the begining of the input box. 4014 // Set the caret to the begining of the input box.
4012 web_view_helper.WebView() 4015 web_view_helper.WebView()
4013 ->MainFrame() 4016 ->MainFrameImpl()
4014 ->GetDocument() 4017 ->GetDocument()
4015 .GetElementById("EditBoxWithText") 4018 .GetElementById("EditBoxWithText")
4016 .To<WebInputElement>() 4019 .To<WebInputElement>()
4017 .SetSelectionRange(0, 0); 4020 .SetSelectionRange(0, 0);
4018 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1); 4021 SetScaleAndScrollAndLayout(web_view_helper.WebView(), WebPoint(0, 0), 1);
4019 WebRect rect, caret; 4022 WebRect rect, caret;
4020 web_view_helper.WebView()->SelectionBounds(caret, rect); 4023 web_view_helper.WebView()->SelectionBounds(caret, rect);
4021 4024
4022 // Set the page scale to be twice as large as the minimal readable scale. 4025 // Set the page scale to be twice as large as the minimal readable scale.
4023 float new_scale = kMinReadableCaretHeight / caret.height * 2.0; 4026 float new_scale = kMinReadableCaretHeight / caret.height * 2.0;
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after
5303 } 5306 }
5304 5307
5305 static WebPoint BottomRightMinusOne(const WebRect& rect) { 5308 static WebPoint BottomRightMinusOne(const WebRect& rect) {
5306 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the 5309 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the
5307 // selection bounds, selectRange() will select the *next* element. That's 5310 // selection bounds, selectRange() will select the *next* element. That's
5308 // strictly correct, as hit-testing checks the pixel to the lower-right of 5311 // strictly correct, as hit-testing checks the pixel to the lower-right of
5309 // the input coordinate, but it's a wart on the API. 5312 // the input coordinate, but it's a wart on the API.
5310 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1); 5313 return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
5311 } 5314 }
5312 5315
5313 static WebRect ElementBounds(WebFrame* frame, const WebString& id) { 5316 static WebRect ElementBounds(WebLocalFrame* frame, const WebString& id) {
5314 return frame->GetDocument().GetElementById(id).BoundsInViewport(); 5317 return frame->GetDocument().GetElementById(id).BoundsInViewport();
5315 } 5318 }
5316 5319
5317 static std::string SelectionAsString(WebFrame* frame) { 5320 static std::string SelectionAsString(WebFrame* frame) {
5318 return frame->ToWebLocalFrame()->SelectionAsText().Utf8(); 5321 return frame->ToWebLocalFrame()->SelectionAsText().Utf8();
5319 } 5322 }
5320 5323
5321 TEST_P(ParameterizedWebFrameTest, SelectRange) { 5324 TEST_P(ParameterizedWebFrameTest, SelectRange) {
5322 WebLocalFrame* frame; 5325 WebLocalFrame* frame;
5323 WebRect start_web_rect; 5326 WebRect start_web_rect;
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
6695 WebVector<unsigned> offsets2; 6698 WebVector<unsigned> offsets2;
6696 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument()); 6699 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument());
6697 EXPECT_EQ(0U, offsets2.size()); 6700 EXPECT_EQ(0U, offsets2.size());
6698 } 6701 }
6699 6702
6700 class StubbornTextCheckClient : public WebTextCheckClient { 6703 class StubbornTextCheckClient : public WebTextCheckClient {
6701 public: 6704 public:
6702 StubbornTextCheckClient() : completion_(0) {} 6705 StubbornTextCheckClient() : completion_(0) {}
6703 virtual ~StubbornTextCheckClient() {} 6706 virtual ~StubbornTextCheckClient() {}
6704 6707
6705 virtual void RequestCheckingOfText( 6708 void RequestCheckingOfText(const WebString&,
6706 const WebString&, 6709 WebTextCheckingCompletion* completion) override {
6707 WebTextCheckingCompletion* completion) override {
6708 completion_ = completion; 6710 completion_ = completion;
6709 } 6711 }
6710 6712
6711 void CancelAllPendingRequests() override { 6713 void CancelAllPendingRequests() override {
6712 if (!completion_) 6714 if (!completion_)
6713 return; 6715 return;
6714 completion_->DidCancelCheckingText(); 6716 completion_->DidCancelCheckingText();
6715 completion_ = nullptr; 6717 completion_ = nullptr;
6716 } 6718 }
6717 6719
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
7166 test_url, redirect_response, file_path); 7168 test_url, redirect_response, file_path);
7167 7169
7168 WebURLResponse final_response; 7170 WebURLResponse final_response;
7169 final_response.SetMIMEType("text/html"); 7171 final_response.SetMIMEType("text/html");
7170 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL( 7172 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL(
7171 redirect_url, final_response, file_path); 7173 redirect_url, final_response, file_path);
7172 7174
7173 FrameTestHelpers::WebViewHelper web_view_helper; 7175 FrameTestHelpers::WebViewHelper web_view_helper;
7174 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html"); 7176 web_view_helper.InitializeAndLoad(base_url_ + "first_party_redirect.html");
7175 EXPECT_TRUE(web_view_helper.WebView() 7177 EXPECT_TRUE(web_view_helper.WebView()
7176 ->MainFrame() 7178 ->MainFrameImpl()
7177 ->GetDocument() 7179 ->GetDocument()
7178 .FirstPartyForCookies() == redirect_url); 7180 .FirstPartyForCookies() == redirect_url);
7179 } 7181 }
7180 7182
7181 class TestNavigationPolicyWebFrameClient 7183 class TestNavigationPolicyWebFrameClient
7182 : public FrameTestHelpers::TestWebFrameClient { 7184 : public FrameTestHelpers::TestWebFrameClient {
7183 public: 7185 public:
7184 void DidNavigateWithinPage(const WebHistoryItem&, 7186 void DidNavigateWithinPage(const WebHistoryItem&,
7185 WebHistoryCommitType, 7187 WebHistoryCommitType,
7186 bool) override { 7188 bool) override {
(...skipping 22 matching lines...) Expand all
7209 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer); 7211 MouseEvent::Create(nullptr, EventTypeNames::click, mouse_initializer);
7210 FrameLoadRequest frame_request(document, ResourceRequest(destination)); 7212 FrameLoadRequest frame_request(document, ResourceRequest(destination));
7211 frame_request.SetTriggeringEvent(event); 7213 frame_request.SetTriggeringEvent(event);
7212 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame()) 7214 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame())
7213 ->Loader() 7215 ->Loader()
7214 .Load(frame_request); 7216 .Load(frame_request);
7215 } 7217 }
7216 7218
7217 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { 7219 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient {
7218 public: 7220 public:
7219 virtual WebView* CreateView(WebLocalFrame*, 7221 WebView* CreateView(WebLocalFrame*,
7220 const WebURLRequest&, 7222 const WebURLRequest&,
7221 const WebWindowFeatures&, 7223 const WebWindowFeatures&,
7222 const WebString&, 7224 const WebString&,
7223 WebNavigationPolicy, 7225 WebNavigationPolicy,
7224 bool) override { 7226 bool) override {
7225 EXPECT_TRUE(false); 7227 EXPECT_TRUE(false);
7226 return 0; 7228 return 0;
7227 } 7229 }
7228 }; 7230 };
7229 7231
7230 class TestNewWindowWebFrameClient 7232 class TestNewWindowWebFrameClient
7231 : public FrameTestHelpers::TestWebFrameClient { 7233 : public FrameTestHelpers::TestWebFrameClient {
7232 public: 7234 public:
7233 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {} 7235 TestNewWindowWebFrameClient() : decide_policy_call_count_(0) {}
7234 7236
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
7693 7695
7694 TestHistoryWebFrameClient client; 7696 TestHistoryWebFrameClient client;
7695 FrameTestHelpers::WebViewHelper web_view_helper; 7697 FrameTestHelpers::WebViewHelper web_view_helper;
7696 web_view_helper.InitializeAndLoad("about:blank", &client); 7698 web_view_helper.InitializeAndLoad("about:blank", &client);
7697 7699
7698 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); 7700 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl();
7699 7701
7700 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( 7702 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8(
7701 "document.body.appendChild(document.createElement('iframe'))"))); 7703 "document.body.appendChild(document.createElement('iframe'))")));
7702 7704
7703 WebLocalFrame* iframe = frame->FirstChild()->ToWebLocalFrame(); 7705 WebLocalFrameBase* iframe = ToWebLocalFrameBase(frame->FirstChild());
7704 ASSERT_EQ(&client.ChildClient(), ToWebLocalFrameBase(iframe)->Client()); 7706 ASSERT_EQ(&client.ChildClient(), iframe->Client());
7705 7707
7706 std::string url1 = base_url_ + "history.html"; 7708 std::string url1 = base_url_ + "history.html";
7707 FrameTestHelpers::LoadFrame(iframe, url1); 7709 FrameTestHelpers::LoadFrame(iframe, url1);
7708 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); 7710 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8());
7709 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem()); 7711 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem());
7710 7712
7711 std::string url2 = base_url_ + "find.html"; 7713 std::string url2 = base_url_ + "find.html";
7712 FrameTestHelpers::LoadFrame(iframe, url2); 7714 FrameTestHelpers::LoadFrame(iframe, url2);
7713 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); 7715 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8());
7714 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); 7716 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem());
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
9447 WebLocalFrame* local_frame = 9449 WebLocalFrame* local_frame =
9448 FrameTestHelpers::CreateProvisional(*remote_frame); 9450 FrameTestHelpers::CreateProvisional(*remote_frame);
9449 remote_frame->Swap(local_frame); 9451 remote_frame->Swap(local_frame);
9450 9452
9451 // And the opener cycle should still be preserved. 9453 // And the opener cycle should still be preserved.
9452 EXPECT_EQ(local_frame, local_frame->Opener()); 9454 EXPECT_EQ(local_frame, local_frame->Opener());
9453 } 9455 }
9454 9456
9455 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 9457 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
9456 public: 9458 public:
9457 explicit CommitTypeWebFrameClient() 9459 CommitTypeWebFrameClient() : history_commit_type_(kWebHistoryInertCommit) {}
9458 : history_commit_type_(kWebHistoryInertCommit) {}
9459 9460
9460 void DidCommitProvisionalLoad( 9461 void DidCommitProvisionalLoad(
9461 const WebHistoryItem&, 9462 const WebHistoryItem&,
9462 WebHistoryCommitType history_commit_type) override { 9463 WebHistoryCommitType history_commit_type) override {
9463 history_commit_type_ = history_commit_type; 9464 history_commit_type_ = history_commit_type;
9464 } 9465 }
9465 9466
9466 WebHistoryCommitType HistoryCommitType() const { 9467 WebHistoryCommitType HistoryCommitType() const {
9467 return history_commit_type_; 9468 return history_commit_type_;
9468 } 9469 }
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
10521 local_frame->CopyImageAt(WebPoint(50, 50)); 10522 local_frame->CopyImageAt(WebPoint(50, 50));
10522 10523
10523 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10524 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10524 WebClipboard::kBufferStandard)); 10525 WebClipboard::kBufferStandard));
10525 10526
10526 WebImage image = 10527 WebImage image =
10527 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10528 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10528 ->ReadRawImage(WebClipboard::Buffer()); 10529 ->ReadRawImage(WebClipboard::Buffer());
10529 10530
10530 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10531 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10531 }; 10532 }
10532 10533
10533 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { 10534 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) {
10534 std::string url = base_url_ + "canvas-copy-image.html"; 10535 std::string url = base_url_ + "canvas-copy-image.html";
10535 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html"); 10536 RegisterMockedURLLoadFromBase(base_url_, "canvas-copy-image.html");
10536 10537
10537 FrameTestHelpers::WebViewHelper helper; 10538 FrameTestHelpers::WebViewHelper helper;
10538 WebViewBase* web_view = helper.InitializeAndLoad(url); 10539 WebViewBase* web_view = helper.InitializeAndLoad(url);
10539 web_view->Resize(WebSize(400, 400)); 10540 web_view->Resize(WebSize(400, 400));
10540 web_view->UpdateAllLifecyclePhases(); 10541 web_view->UpdateAllLifecyclePhases();
10541 web_view->SetPageScaleFactor(2); 10542 web_view->SetPageScaleFactor(2);
10542 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200)); 10543 web_view->SetVisualViewportOffset(WebFloatPoint(200, 200));
10543 10544
10544 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber( 10545 uint64_t sequence = Platform::Current()->Clipboard()->SequenceNumber(
10545 WebClipboard::kBufferStandard); 10546 WebClipboard::kBufferStandard);
10546 10547
10547 WebLocalFrame* local_frame = web_view->MainFrameImpl(); 10548 WebLocalFrame* local_frame = web_view->MainFrameImpl();
10548 local_frame->CopyImageAt(WebPoint(0, 0)); 10549 local_frame->CopyImageAt(WebPoint(0, 0));
10549 10550
10550 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber( 10551 EXPECT_NE(sequence, Platform::Current()->Clipboard()->SequenceNumber(
10551 WebClipboard::kBufferStandard)); 10552 WebClipboard::kBufferStandard));
10552 10553
10553 WebImage image = 10554 WebImage image =
10554 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard()) 10555 static_cast<WebMockClipboard*>(Platform::Current()->Clipboard())
10555 ->ReadRawImage(WebClipboard::Buffer()); 10556 ->ReadRawImage(WebClipboard::Buffer());
10556 10557
10557 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0)); 10558 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.GetSkBitmap().getColor(0, 0));
10558 }; 10559 }
10559 10560
10560 TEST_F(WebFrameTest, CopyImageWithImageMap) { 10561 TEST_F(WebFrameTest, CopyImageWithImageMap) {
10561 SaveImageFromDataURLWebFrameClient client; 10562 SaveImageFromDataURLWebFrameClient client;
10562 10563
10563 std::string url = base_url_ + "image-map.html"; 10564 std::string url = base_url_ + "image-map.html";
10564 RegisterMockedURLLoadFromBase(base_url_, "image-map.html"); 10565 RegisterMockedURLLoadFromBase(base_url_, "image-map.html");
10565 10566
10566 FrameTestHelpers::WebViewHelper helper; 10567 FrameTestHelpers::WebViewHelper helper;
10567 WebViewBase* web_view = helper.InitializeAndLoad(url, &client); 10568 WebViewBase* web_view = helper.InitializeAndLoad(url, &client);
10568 web_view->Resize(WebSize(400, 400)); 10569 web_view->Resize(WebSize(400, 400));
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
11849 "document.querySelector('input').focus();")); 11850 "document.querySelector('input').focus();"));
11850 11851
11851 // Verify that the right WebWidgetClient has been notified. 11852 // Verify that the right WebWidgetClient has been notified.
11852 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard()); 11853 EXPECT_TRUE(web_widget_client.DidShowVirtualKeyboard());
11853 11854
11854 web_view_helper.Reset(); 11855 web_view_helper.Reset();
11855 } 11856 }
11856 11857
11857 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 11858 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
11858 public: 11859 public:
11859 ContextMenuWebFrameClient(){}; 11860 ContextMenuWebFrameClient() {}
11860 // WebFrameClient methods 11861 // WebFrameClient methods
11861 void ShowContextMenu(const WebContextMenuData& data) override { 11862 void ShowContextMenu(const WebContextMenuData& data) override {
11862 menu_data_ = data; 11863 menu_data_ = data;
11863 } 11864 }
11864 11865
11865 WebContextMenuData GetMenuData() { return menu_data_; } 11866 WebContextMenuData GetMenuData() { return menu_data_; }
11866 11867
11867 private: 11868 private:
11868 WebContextMenuData menu_data_; 11869 WebContextMenuData menu_data_;
11869 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient); 11870 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
11940 FrameTestHelpers::CreateLocalChild(*helper.RemoteMainFrame()); 11941 FrameTestHelpers::CreateLocalChild(*helper.RemoteMainFrame());
11941 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page"); 11942 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page");
11942 11943
11943 // Local frame with remote parent should have transparent baseBackgroundColor. 11944 // Local frame with remote parent should have transparent baseBackgroundColor.
11944 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); 11945 Color color = local_frame->GetFrameView()->BaseBackgroundColor();
11945 EXPECT_EQ(Color::kTransparent, color); 11946 EXPECT_EQ(Color::kTransparent, color);
11946 } 11947 }
11947 11948
11948 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 11949 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
11949 public: 11950 public:
11950 explicit TestFallbackWebFrameClient() : child_client_(nullptr) {} 11951 TestFallbackWebFrameClient() : child_client_(nullptr) {}
11951 11952
11952 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) { 11953 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) {
11953 child_client_ = client; 11954 child_client_ = client;
11954 } 11955 }
11955 11956
11956 WebLocalFrame* CreateChildFrame( 11957 WebLocalFrame* CreateChildFrame(
11957 WebLocalFrame* parent, 11958 WebLocalFrame* parent,
11958 WebTreeScopeType scope, 11959 WebTreeScopeType scope,
11959 const WebString&, 11960 const WebString&,
11960 const WebString&, 11961 const WebString&,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
12029 if (obj->IsText()) { 12030 if (obj->IsText()) {
12030 LayoutText* layout_text = ToLayoutText(obj); 12031 LayoutText* layout_text = ToLayoutText(obj);
12031 text = layout_text->GetText(); 12032 text = layout_text->GetText();
12032 break; 12033 break;
12033 } 12034 }
12034 } 12035 }
12035 EXPECT_EQ("foo alt", text.Utf8()); 12036 EXPECT_EQ("foo alt", text.Utf8());
12036 } 12037 }
12037 12038
12038 } // namespace blink 12039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698