| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 ViewCreatingWebViewClient client; | 2050 ViewCreatingWebViewClient client; |
| 2051 FrameTestHelpers::WebViewHelper m_webViewHelper; | 2051 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 2052 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); | 2052 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); |
| 2053 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); | 2053 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); |
| 2054 | 2054 |
| 2055 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); | 2055 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
| 2056 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), "<html><body><ifr
ame src=\"about:blank\"></iframe></body></html>", baseURL); | 2056 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), "<html><body><ifr
ame src=\"about:blank\"></iframe></body></html>", baseURL); |
| 2057 | 2057 |
| 2058 // Make a request from a local frame. | 2058 // Make a request from a local frame. |
| 2059 WebURLRequest webURLRequestWithTargetStart; | 2059 WebURLRequest webURLRequestWithTargetStart; |
| 2060 webURLRequestWithTargetStart.initialize(); | |
| 2061 LocalFrame* localFrame = toWebLocalFrameImpl(webViewImpl->mainFrame()->first
Child())->frame(); | 2060 LocalFrame* localFrame = toWebLocalFrameImpl(webViewImpl->mainFrame()->first
Child())->frame(); |
| 2062 FrameLoadRequest requestWithTargetStart(localFrame->document(), webURLReques
tWithTargetStart.toResourceRequest(), "_top"); | 2061 FrameLoadRequest requestWithTargetStart(localFrame->document(), webURLReques
tWithTargetStart.toResourceRequest(), "_top"); |
| 2063 localFrame->loader().load(requestWithTargetStart); | 2062 localFrame->loader().load(requestWithTargetStart); |
| 2064 EXPECT_FALSE(client.didFocusCalled()); | 2063 EXPECT_FALSE(client.didFocusCalled()); |
| 2065 | 2064 |
| 2066 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2065 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 2067 } | 2066 } |
| 2068 | 2067 |
| 2069 TEST_F(WebViewTest, FocusExistingFrameOnNavigate) | 2068 TEST_F(WebViewTest, FocusExistingFrameOnNavigate) |
| 2070 { | 2069 { |
| 2071 ViewCreatingWebViewClient client; | 2070 ViewCreatingWebViewClient client; |
| 2072 FrameTestHelpers::WebViewHelper m_webViewHelper; | 2071 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 2073 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); | 2072 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client); |
| 2074 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); | 2073 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); |
| 2075 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | 2074 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); |
| 2076 frame->setName("_start"); | 2075 frame->setName("_start"); |
| 2077 | 2076 |
| 2078 // Make a request that will open a new window | 2077 // Make a request that will open a new window |
| 2079 WebURLRequest webURLRequest; | 2078 WebURLRequest webURLRequest; |
| 2080 webURLRequest.initialize(); | |
| 2081 FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blank"); | 2079 FrameLoadRequest request(0, webURLRequest.toResourceRequest(), "_blank"); |
| 2082 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); | 2080 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(request); |
| 2083 ASSERT_TRUE(client.createdWebView()); | 2081 ASSERT_TRUE(client.createdWebView()); |
| 2084 EXPECT_FALSE(client.didFocusCalled()); | 2082 EXPECT_FALSE(client.didFocusCalled()); |
| 2085 | 2083 |
| 2086 // Make a request from the new window that will navigate the original window
. The original window should be focused. | 2084 // Make a request from the new window that will navigate the original window
. The original window should be focused. |
| 2087 WebURLRequest webURLRequestWithTargetStart; | 2085 WebURLRequest webURLRequestWithTargetStart; |
| 2088 webURLRequestWithTargetStart.initialize(); | |
| 2089 FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetStart.toRe
sourceRequest(), "_start"); | 2086 FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetStart.toRe
sourceRequest(), "_start"); |
| 2090 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame())->l
oader().load(requestWithTargetStart); | 2087 toLocalFrame(toWebViewImpl(client.createdWebView())->page()->mainFrame())->l
oader().load(requestWithTargetStart); |
| 2091 EXPECT_TRUE(client.didFocusCalled()); | 2088 EXPECT_TRUE(client.didFocusCalled()); |
| 2092 | 2089 |
| 2093 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2090 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 2094 } | 2091 } |
| 2095 | 2092 |
| 2096 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) | 2093 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) |
| 2097 { | 2094 { |
| 2098 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "focusout_focusin_events.html"); | 2095 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "focusout_focusin_events.html"); |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 frame->setAutofillClient(&client); | 3126 frame->setAutofillClient(&client); |
| 3130 webView->setInitialFocus(false); | 3127 webView->setInitialFocus(false); |
| 3131 | 3128 |
| 3132 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3129 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); |
| 3133 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3130 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3134 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3131 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3135 frame->setAutofillClient(0); | 3132 frame->setAutofillClient(0); |
| 3136 } | 3133 } |
| 3137 | 3134 |
| 3138 } // namespace blink | 3135 } // namespace blink |
| OLD | NEW |