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

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

Issue 2905873003: VR: Disable select element in VR mode via WebPreferences (Closed)
Patch Set: Address the comment 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
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/html/HTMLSelectElement.h"
32 #include "core/html/forms/ColorChooserClient.h" 33 #include "core/html/forms/ColorChooserClient.h"
33 #include "core/html/forms/DateTimeChooser.h" 34 #include "core/html/forms/DateTimeChooser.h"
34 #include "core/html/forms/DateTimeChooserClient.h" 35 #include "core/html/forms/DateTimeChooserClient.h"
35 #include "core/loader/FrameLoadRequest.h" 36 #include "core/loader/FrameLoadRequest.h"
36 #include "core/page/Page.h" 37 #include "core/page/Page.h"
37 #include "core/page/ScopedPageSuspender.h" 38 #include "core/page/ScopedPageSuspender.h"
38 #include "platform/Language.h" 39 #include "platform/Language.h"
39 #include "public/platform/WebInputEvent.h" 40 #include "public/platform/WebInputEvent.h"
40 #include "public/web/WebFrameClient.h" 41 #include "public/web/WebFrameClient.h"
41 #include "public/web/WebLocalFrame.h" 42 #include "public/web/WebLocalFrame.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 color); 347 color);
347 } 348 }
348 349
349 bool CanOpenDateTimeChooser() { 350 bool CanOpenDateTimeChooser() {
350 DateTimeChooserParameters params; 351 DateTimeChooserParameters params;
351 params.locale = DefaultLanguage(); 352 params.locale = DefaultLanguage();
352 return !!chrome_client_impl_->OpenDateTimeChooser(date_time_chooser_client_, 353 return !!chrome_client_impl_->OpenDateTimeChooser(date_time_chooser_client_,
353 params); 354 params);
354 } 355 }
355 356
357 bool CanOpenPopupMenu() {
358 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame();
359 return !!chrome_client_impl_->OpenPopupMenu(*frame, *select_);
360 }
361
356 Settings* GetSettings() { 362 Settings* GetSettings() {
357 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); 363 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame();
358 return frame->GetDocument()->GetSettings(); 364 return frame->GetDocument()->GetSettings();
359 } 365 }
360 366
361 protected: 367 protected:
362 void SetUp() override { 368 void SetUp() override {
363 web_view_ = static_cast<WebViewBase*>( 369 web_view_ = static_cast<WebViewBase*>(
364 WebViewBase::Create(&web_view_client_, kWebPageVisibilityStateVisible)); 370 WebViewBase::Create(&web_view_client_, kWebPageVisibilityStateVisible));
365 main_frame_ = WebLocalFrame::Create(WebTreeScopeType::kDocument, 371 main_frame_ = WebLocalFrame::Create(WebTreeScopeType::kDocument,
366 &web_frame_client_, nullptr, nullptr); 372 &web_frame_client_, nullptr, nullptr);
367 web_view_->SetMainFrame(main_frame_); 373 web_view_->SetMainFrame(main_frame_);
368 chrome_client_impl_ = 374 chrome_client_impl_ =
369 ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient()); 375 ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient());
370 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame(); 376 LocalFrame* frame = ToWebLocalFrameImpl(main_frame_)->GetFrame();
371 color_chooser_client_ = 377 color_chooser_client_ =
372 new FakeColorChooserClient(frame->GetDocument()->documentElement()); 378 new FakeColorChooserClient(frame->GetDocument()->documentElement());
373 date_time_chooser_client_ = 379 date_time_chooser_client_ =
374 new FakeDateTimeChooserClient(frame->GetDocument()->documentElement()); 380 new FakeDateTimeChooserClient(frame->GetDocument()->documentElement());
381 select_ = HTMLSelectElement::Create(*(frame->GetDocument()));
375 } 382 }
376 383
377 void TearDown() override { web_view_->Close(); } 384 void TearDown() override { web_view_->Close(); }
378 385
379 protected: 386 protected:
380 FrameTestHelpers::TestWebViewClient web_view_client_; 387 FrameTestHelpers::TestWebViewClient web_view_client_;
381 WebViewBase* web_view_ = nullptr; 388 WebViewBase* web_view_ = nullptr;
382 WebLocalFrame* main_frame_ = nullptr; 389 WebLocalFrame* main_frame_ = nullptr;
383 FrameTestHelpers::TestWebFrameClient web_frame_client_; 390 FrameTestHelpers::TestWebFrameClient web_frame_client_;
384 Persistent<ChromeClientImpl> chrome_client_impl_; 391 Persistent<ChromeClientImpl> chrome_client_impl_;
385 Persistent<FakeColorChooserClient> color_chooser_client_; 392 Persistent<FakeColorChooserClient> color_chooser_client_;
386 Persistent<FakeDateTimeChooserClient> date_time_chooser_client_; 393 Persistent<FakeDateTimeChooserClient> date_time_chooser_client_;
394 Persistent<HTMLSelectElement> select_;
387 }; 395 };
388 396
389 TEST_F(PagePopupSuppressionTest, SuppressColorChooser) { 397 TEST_F(PagePopupSuppressionTest, SuppressColorChooser) {
390 // By default, the popup should be shown. 398 // By default, the popup should be shown.
391 EXPECT_TRUE(CanOpenColorChooser()); 399 EXPECT_TRUE(CanOpenColorChooser());
392 400
393 Settings* settings = GetSettings(); 401 Settings* settings = GetSettings();
394 settings->SetPagePopupsSuppressed(true); 402 settings->SetPagePopupsSuppressed(true);
395 403
396 EXPECT_FALSE(CanOpenColorChooser()); 404 EXPECT_FALSE(CanOpenColorChooser());
397 405
398 settings->SetPagePopupsSuppressed(false); 406 settings->SetPagePopupsSuppressed(false);
399 EXPECT_TRUE(CanOpenColorChooser()); 407 EXPECT_TRUE(CanOpenColorChooser());
400 } 408 }
401 409
402 TEST_F(PagePopupSuppressionTest, SuppressDateTimeChooser) { 410 TEST_F(PagePopupSuppressionTest, SuppressDateTimeChooser) {
403 // By default, the popup should be shown. 411 // By default, the popup should be shown.
404 EXPECT_TRUE(CanOpenDateTimeChooser()); 412 EXPECT_TRUE(CanOpenDateTimeChooser());
405 413
406 Settings* settings = GetSettings(); 414 Settings* settings = GetSettings();
407 settings->SetPagePopupsSuppressed(true); 415 settings->SetPagePopupsSuppressed(true);
408 416
409 EXPECT_FALSE(CanOpenDateTimeChooser()); 417 EXPECT_FALSE(CanOpenDateTimeChooser());
410 418
411 settings->SetPagePopupsSuppressed(false); 419 settings->SetPagePopupsSuppressed(false);
412 EXPECT_TRUE(CanOpenDateTimeChooser()); 420 EXPECT_TRUE(CanOpenDateTimeChooser());
413 } 421 }
414 422
423 TEST_F(PagePopupSuppressionTest, SuppressPopupMenu) {
424 // By default, the popup should be shown.
425 EXPECT_TRUE(CanOpenPopupMenu());
426
427 Settings* settings = GetSettings();
428 settings->SetPagePopupsSuppressed(true);
429
430 EXPECT_FALSE(CanOpenPopupMenu());
431
432 settings->SetPagePopupsSuppressed(false);
433 EXPECT_TRUE(CanOpenPopupMenu());
434 }
435
415 } // namespace blink 436 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698