| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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 "core/exported/WebViewBase.h" | 31 #include "core/exported/WebViewBase.h" |
| 32 #include "core/frame/WebLocalFrameBase.h" |
| 32 #include "core/html/HTMLSelectElement.h" | 33 #include "core/html/HTMLSelectElement.h" |
| 33 #include "core/html/forms/ColorChooserClient.h" | 34 #include "core/html/forms/ColorChooserClient.h" |
| 34 #include "core/html/forms/DateTimeChooser.h" | 35 #include "core/html/forms/DateTimeChooser.h" |
| 35 #include "core/html/forms/DateTimeChooserClient.h" | 36 #include "core/html/forms/DateTimeChooserClient.h" |
| 36 #include "core/loader/FrameLoadRequest.h" | 37 #include "core/loader/FrameLoadRequest.h" |
| 37 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
| 38 #include "core/page/ScopedPageSuspender.h" | 39 #include "core/page/ScopedPageSuspender.h" |
| 39 #include "platform/Language.h" | 40 #include "platform/Language.h" |
| 40 #include "public/platform/WebInputEvent.h" | 41 #include "public/platform/WebInputEvent.h" |
| 41 #include "public/web/WebFrameClient.h" | 42 #include "public/web/WebFrameClient.h" |
| 42 #include "public/web/WebLocalFrame.h" | 43 #include "public/web/WebLocalFrame.h" |
| 43 #include "public/web/WebView.h" | 44 #include "public/web/WebView.h" |
| 44 #include "public/web/WebViewClient.h" | 45 #include "public/web/WebViewClient.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 46 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "web/ChromeClientImpl.h" | 47 #include "web/ChromeClientImpl.h" |
| 47 #include "web/WebLocalFrameImpl.h" | |
| 48 #include "web/tests/FrameTestHelpers.h" | 48 #include "web/tests/FrameTestHelpers.h" |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 class TestWebViewClient : public FrameTestHelpers::TestWebViewClient { | 54 class TestWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 55 public: | 55 public: |
| 56 explicit TestWebViewClient(WebNavigationPolicy* target) : target_(target) {} | 56 explicit TestWebViewClient(WebNavigationPolicy* target) : target_(target) {} |
| 57 ~TestWebViewClient() override {} | 57 ~TestWebViewClient() override {} |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 ViewCreatingClient web_view_client_; | 267 ViewCreatingClient web_view_client_; |
| 268 WebViewBase* web_view_; | 268 WebViewBase* web_view_; |
| 269 WebLocalFrame* main_frame_; | 269 WebLocalFrame* main_frame_; |
| 270 FrameTestHelpers::TestWebFrameClient web_frame_client_; | 270 FrameTestHelpers::TestWebFrameClient web_frame_client_; |
| 271 Persistent<ChromeClientImpl> chrome_client_impl_; | 271 Persistent<ChromeClientImpl> chrome_client_impl_; |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 TEST_F(CreateWindowTest, CreateWindowFromSuspendedPage) { | 274 TEST_F(CreateWindowTest, CreateWindowFromSuspendedPage) { |
| 275 ScopedPageSuspender suspender; | 275 ScopedPageSuspender suspender; |
| 276 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); | 276 LocalFrame* frame = ToWebLocalFrameBase(main_frame_)->GetFrame(); |
| 277 FrameLoadRequest request(frame->GetDocument()); | 277 FrameLoadRequest request(frame->GetDocument()); |
| 278 WindowFeatures features; | 278 WindowFeatures features; |
| 279 EXPECT_EQ(nullptr, | 279 EXPECT_EQ(nullptr, |
| 280 chrome_client_impl_->CreateWindow( | 280 chrome_client_impl_->CreateWindow( |
| 281 frame, request, features, kNavigationPolicyNewForegroundTab)); | 281 frame, request, features, kNavigationPolicyNewForegroundTab)); |
| 282 } | 282 } |
| 283 | 283 |
| 284 class FakeColorChooserClient | 284 class FakeColorChooserClient |
| 285 : public GarbageCollectedFinalized<FakeColorChooserClient>, | 285 : public GarbageCollectedFinalized<FakeColorChooserClient>, |
| 286 public ColorChooserClient { | 286 public ColorChooserClient { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 private: | 335 private: |
| 336 Member<Element> owner_element_; | 336 Member<Element> owner_element_; |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 class PagePopupSuppressionTest : public testing::Test { | 339 class PagePopupSuppressionTest : public testing::Test { |
| 340 public: | 340 public: |
| 341 PagePopupSuppressionTest() {} | 341 PagePopupSuppressionTest() {} |
| 342 | 342 |
| 343 bool CanOpenColorChooser() { | 343 bool CanOpenColorChooser() { |
| 344 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); | 344 LocalFrame* frame = ToWebLocalFrameBase(main_frame_)->GetFrame(); |
| 345 Color color; | 345 Color color; |
| 346 return !!chrome_client_impl_->OpenColorChooser(frame, color_chooser_client_, | 346 return !!chrome_client_impl_->OpenColorChooser(frame, color_chooser_client_, |
| 347 color); | 347 color); |
| 348 } | 348 } |
| 349 | 349 |
| 350 bool CanOpenDateTimeChooser() { | 350 bool CanOpenDateTimeChooser() { |
| 351 DateTimeChooserParameters params; | 351 DateTimeChooserParameters params; |
| 352 params.locale = DefaultLanguage(); | 352 params.locale = DefaultLanguage(); |
| 353 return !!chrome_client_impl_->OpenDateTimeChooser(date_time_chooser_client_, | 353 return !!chrome_client_impl_->OpenDateTimeChooser(date_time_chooser_client_, |
| 354 params); | 354 params); |
| 355 } | 355 } |
| 356 | 356 |
| 357 bool CanOpenPopupMenu() { | 357 bool CanOpenPopupMenu() { |
| 358 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); | 358 LocalFrame* frame = ToWebLocalFrameBase(main_frame_)->GetFrame(); |
| 359 return !!chrome_client_impl_->OpenPopupMenu(*frame, *select_); | 359 return !!chrome_client_impl_->OpenPopupMenu(*frame, *select_); |
| 360 } | 360 } |
| 361 | 361 |
| 362 Settings* GetSettings() { | 362 Settings* GetSettings() { |
| 363 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); | 363 LocalFrame* frame = ToWebLocalFrameBase(main_frame_)->GetFrame(); |
| 364 return frame->GetDocument()->GetSettings(); | 364 return frame->GetDocument()->GetSettings(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 protected: | 367 protected: |
| 368 void SetUp() override { | 368 void SetUp() override { |
| 369 web_view_ = static_cast<WebViewBase*>( | 369 web_view_ = static_cast<WebViewBase*>( |
| 370 WebViewBase::Create(&web_view_client_, kWebPageVisibilityStateVisible)); | 370 WebViewBase::Create(&web_view_client_, kWebPageVisibilityStateVisible)); |
| 371 main_frame_ = WebLocalFrame::Create(WebTreeScopeType::kDocument, | 371 main_frame_ = WebLocalFrame::Create(WebTreeScopeType::kDocument, |
| 372 &web_frame_client_, nullptr, nullptr); | 372 &web_frame_client_, nullptr, nullptr); |
| 373 web_view_->SetMainFrame(main_frame_); | 373 web_view_->SetMainFrame(main_frame_); |
| 374 chrome_client_impl_ = | 374 chrome_client_impl_ = |
| 375 ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient()); | 375 ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient()); |
| 376 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); | 376 LocalFrame* frame = ToWebLocalFrameBase(main_frame_)->GetFrame(); |
| 377 color_chooser_client_ = | 377 color_chooser_client_ = |
| 378 new FakeColorChooserClient(frame->GetDocument()->documentElement()); | 378 new FakeColorChooserClient(frame->GetDocument()->documentElement()); |
| 379 date_time_chooser_client_ = | 379 date_time_chooser_client_ = |
| 380 new FakeDateTimeChooserClient(frame->GetDocument()->documentElement()); | 380 new FakeDateTimeChooserClient(frame->GetDocument()->documentElement()); |
| 381 select_ = HTMLSelectElement::Create(*(frame->GetDocument())); | 381 select_ = HTMLSelectElement::Create(*(frame->GetDocument())); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void TearDown() override { web_view_->Close(); } | 384 void TearDown() override { web_view_->Close(); } |
| 385 | 385 |
| 386 protected: | 386 protected: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 Settings* settings = GetSettings(); | 427 Settings* settings = GetSettings(); |
| 428 settings->SetPagePopupsSuppressed(true); | 428 settings->SetPagePopupsSuppressed(true); |
| 429 | 429 |
| 430 EXPECT_FALSE(CanOpenPopupMenu()); | 430 EXPECT_FALSE(CanOpenPopupMenu()); |
| 431 | 431 |
| 432 settings->SetPagePopupsSuppressed(false); | 432 settings->SetPagePopupsSuppressed(false); |
| 433 EXPECT_TRUE(CanOpenPopupMenu()); | 433 EXPECT_TRUE(CanOpenPopupMenu()); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } // namespace blink | 436 } // namespace blink |
| OLD | NEW |