| OLD | NEW |
| 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 11397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11408 FrameTestHelpers::TestWebViewClient openerWebViewClient; | 11408 FrameTestHelpers::TestWebViewClient openerWebViewClient; |
| 11409 FrameTestHelpers::WebViewHelper openerHelper; | 11409 FrameTestHelpers::WebViewHelper openerHelper; |
| 11410 openerHelper.initialize(false, nullptr, &openerWebViewClient); | 11410 openerHelper.initialize(false, nullptr, &openerWebViewClient); |
| 11411 FrameTestHelpers::WebViewHelper helper; | 11411 FrameTestHelpers::WebViewHelper helper; |
| 11412 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); | 11412 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); |
| 11413 | 11413 |
| 11414 openerHelper.reset(); | 11414 openerHelper.reset(); |
| 11415 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); | 11415 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); |
| 11416 } | 11416 } |
| 11417 | 11417 |
| 11418 class ShowVirtualKeyboardObserverWidgetClient |
| 11419 : public FrameTestHelpers::TestWebWidgetClient { |
| 11420 public: |
| 11421 ShowVirtualKeyboardObserverWidgetClient() : m_didShowVirtualKeyboard(false) {} |
| 11422 |
| 11423 void showVirtualKeyboardOnElementFocus() override { |
| 11424 m_didShowVirtualKeyboard = true; |
| 11425 } |
| 11426 |
| 11427 bool didShowVirtualKeyboard() const { return m_didShowVirtualKeyboard; } |
| 11428 |
| 11429 private: |
| 11430 bool m_didShowVirtualKeyboard; |
| 11431 }; |
| 11432 |
| 11433 TEST_F(WebFrameTest, ShowVirtualKeyboardOnElementFocus) { |
| 11434 FrameTestHelpers::WebViewHelper webViewHelper; |
| 11435 WebViewImpl* webView = webViewHelper.initialize(true); |
| 11436 WebRemoteFrameImpl* remoteFrame = static_cast<WebRemoteFrameImpl*>( |
| 11437 WebRemoteFrame::create(WebTreeScopeType::Document, nullptr)); |
| 11438 webView->setMainFrame(remoteFrame); |
| 11439 RefPtr<SecurityOrigin> uniqueOrigin = SecurityOrigin::createUnique(); |
| 11440 remoteFrame->frame()->securityContext()->setSecurityOrigin(uniqueOrigin); |
| 11441 |
| 11442 ShowVirtualKeyboardObserverWidgetClient webWidgetClient; |
| 11443 WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild( |
| 11444 remoteFrame, "child", nullptr, &webWidgetClient); |
| 11445 |
| 11446 registerMockedHttpURLLoad("input_field_default.html"); |
| 11447 FrameTestHelpers::loadFrame(localFrame, |
| 11448 m_baseURL + "input_field_default.html"); |
| 11449 |
| 11450 // Simulate an input element focus leading to Element::focus() call with a |
| 11451 // user gesture. |
| 11452 localFrame->setHasReceivedUserGesture(); |
| 11453 localFrame->executeScript( |
| 11454 WebScriptSource("window.focus();" |
| 11455 "document.querySelector('input').focus();")); |
| 11456 |
| 11457 // Verify that the right WebWidgetClient has been notified. |
| 11458 EXPECT_TRUE(webWidgetClient.didShowVirtualKeyboard()); |
| 11459 |
| 11460 remoteFrame->close(); |
| 11461 webViewHelper.reset(); |
| 11462 } |
| 11463 |
| 11418 } // namespace blink | 11464 } // namespace blink |
| OLD | NEW |