Chromium Code Reviews| 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)); | |
|
dcheng
2017/03/09 02:00:25
Nit: WebRemoteFrameImpl::create will avoid the nee
EhsanK
2017/03/09 17:19:49
Acknowledged.
| |
| 11438 webView->setMainFrame(remoteFrame); | |
| 11439 RefPtr<SecurityOrigin> origin = | |
|
EhsanK
2017/03/08 23:38:28
If I don't set this, it will be null for the frame
dcheng
2017/03/09 02:00:25
Nit: we usually we just create a unique origin her
EhsanK
2017/03/09 17:19:49
Acknowledged.
| |
| 11440 SecurityOrigin::createFromString("http://remote.com"); | |
| 11441 remoteFrame->frame()->securityContext()->setSecurityOrigin(origin); | |
| 11442 | |
| 11443 ShowVirtualKeyboardObserverWidgetClient webWidgetClient; | |
| 11444 WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild( | |
| 11445 remoteFrame, "child", nullptr, &webWidgetClient); | |
| 11446 | |
| 11447 registerMockedHttpURLLoad("input_field_default.html"); | |
| 11448 FrameTestHelpers::loadFrame(localFrame, | |
| 11449 m_baseURL + "input_field_default.html"); | |
| 11450 | |
| 11451 // Simulate an input element focus leading to Element::focus() call with a | |
| 11452 // user gesture. | |
| 11453 localFrame->setHasReceivedUserGesture(); | |
| 11454 localFrame->executeScript( | |
| 11455 WebScriptSource("window.focus();" | |
| 11456 "document.querySelector('input').focus();")); | |
| 11457 | |
| 11458 // Verify that the right WebWidgetClient has been notified. | |
| 11459 EXPECT_TRUE(webWidgetClient.didShowVirtualKeyboard()); | |
| 11460 | |
| 11461 remoteFrame->close(); | |
| 11462 webViewHelper.reset(); | |
| 11463 } | |
| 11464 | |
| 11418 } // namespace blink | 11465 } // namespace blink |
| OLD | NEW |