Title: [96912] trunk/Source/WebKit/chromium
Revision
96912
Author
[email protected]
Date
2011-10-07 00:43:10 -0700 (Fri, 07 Oct 2011)

Log Message

Always call setActive() in WebViewImpl::setFocus(),
not just when enabling focus.
https://bugs.webkit.org/show_bug.cgi?id=65220

Reviewed by Darin Fisher.

* WebKit.gyp:
* WebKit.gypi:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setFocus):
* tests/FrameTestHelpers.cpp: Added, refactored out of WebFrameTest.cpp.
(WebKit::FrameTestHelpers::registerMockedURLLoad):
(WebKit::FrameTestHelpers::loadFrame):
(WebKit::FrameTestHelpers::defaultWebFrameClient):
(WebKit::FrameTestHelpers::defaultWebViewClient):
(WebKit::FrameTestHelpers::createWebViewAndLoad):
* tests/FrameTestHelpers.h: Added, refactored out of WebFrameTest.cpp.
* tests/WebFrameTest.cpp:
* tests/WebViewTest.cpp: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (96911 => 96912)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-10-07 07:06:09 UTC (rev 96911)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-10-07 07:43:10 UTC (rev 96912)
@@ -1,3 +1,25 @@
+2011-10-07  Nate Chapin  <[email protected]>
+
+        Always call setActive() in WebViewImpl::setFocus(),
+        not just when enabling focus.
+        https://bugs.webkit.org/show_bug.cgi?id=65220
+
+        Reviewed by Darin Fisher.
+
+        * WebKit.gyp:
+        * WebKit.gypi:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setFocus):
+        * tests/FrameTestHelpers.cpp: Added, refactored out of WebFrameTest.cpp.
+        (WebKit::FrameTestHelpers::registerMockedURLLoad):
+        (WebKit::FrameTestHelpers::loadFrame):
+        (WebKit::FrameTestHelpers::defaultWebFrameClient):
+        (WebKit::FrameTestHelpers::defaultWebViewClient):
+        (WebKit::FrameTestHelpers::createWebViewAndLoad):
+        * tests/FrameTestHelpers.h: Added, refactored out of WebFrameTest.cpp.
+        * tests/WebFrameTest.cpp:
+        * tests/WebViewTest.cpp: Added.
+
 2011-10-06  Bill Budge  <[email protected]>
 
         Adds a field, "saveAs", to WebFileChooserParams to present the file chooser

Modified: trunk/Source/WebKit/chromium/WebKit.gyp (96911 => 96912)


--- trunk/Source/WebKit/chromium/WebKit.gyp	2011-10-07 07:06:09 UTC (rev 96911)
+++ trunk/Source/WebKit/chromium/WebKit.gyp	2011-10-07 07:43:10 UTC (rev 96912)
@@ -691,6 +691,7 @@
                                 'tests/WebFrameTest.cpp',
                                 'tests/WebPageNewSerializerTest.cpp',
                                 'tests/WebPageSerializerTest.cpp',
+                                'tests/WebViewTest.cpp',
                                 'tests/PopupMenuTest.cpp',
                             ],
                             'conditions': [

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (96911 => 96912)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2011-10-07 07:06:09 UTC (rev 96911)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2011-10-07 07:43:10 UTC (rev 96912)
@@ -60,6 +60,8 @@
             'tests/CCSchedulerTest.cpp',
             'tests/CCThreadTaskTest.cpp',
             'tests/CCThreadTest.cpp',
+            'tests/FrameTestHelpers.cpp',
+            'tests/FrameTestHelpers.h',
             'tests/IDBBindingUtilitiesTest.cpp',
             'tests/IDBKeyPathTest.cpp',
             'tests/IDBLevelDBCodingTest.cpp',
@@ -80,6 +82,7 @@
             'tests/WebCompositorImplTest.cpp',
             'tests/WebFrameTest.cpp',
             'tests/WebURLRequestTest.cpp',
+            'tests/WebViewTest.cpp',
         ],
 
         'conditions': [

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (96911 => 96912)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-10-07 07:06:09 UTC (rev 96911)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-10-07 07:43:10 UTC (rev 96912)
@@ -1300,10 +1300,8 @@
 void WebViewImpl::setFocus(bool enable)
 {
     m_page->focusController()->setFocused(enable);
+    m_page->focusController()->setActive(enable);
     if (enable) {
-        // Note that we don't call setActive() when disabled as this cause extra
-        // focus/blur events to be dispatched.
-        m_page->focusController()->setActive(true);
         RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame();
         if (focusedFrame) {
             Node* focusedNode = focusedFrame->document()->focusedNode();

Added: trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp (0 => 96912)


--- trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp	2011-10-07 07:43:10 UTC (rev 96912)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FrameTestHelpers.h"
+
+#include "WebFrame.h"
+#include "WebFrameClient.h"
+#include "WebSettings.h"
+#include "WebString.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+#include "WebView.h"
+#include "WebViewClient.h"
+#include <googleurl/src/gurl.h>
+#include <webkit/support/webkit_support.h>
+
+namespace WebKit {
+namespace FrameTestHelpers {
+
+void registerMockedURLLoad(const std::string& base, const std::string& fileName)
+{
+    WebURLResponse response;
+    response.initialize();
+    response.setMIMEType("text/html");
+
+    std::string filePath = webkit_support::GetWebKitRootDir().utf8();
+    filePath += "/Source/WebKit/chromium/tests/data/";
+    filePath += fileName;
+
+    webkit_support::RegisterMockedURL(GURL(base + fileName), response, WebString::fromUTF8(filePath));
+}
+
+void loadFrame(WebFrame* frame, const std::string& url)
+{
+    WebURLRequest urlRequest;
+    urlRequest.initialize();
+    urlRequest.setURL(GURL(url));
+    frame->loadRequest(urlRequest);
+}
+
+class TestWebFrameClient : public WebFrameClient {
+};
+
+static WebFrameClient* defaultWebFrameClient()
+{
+    static TestWebFrameClient client;
+    return &client;
+}
+
+class TestWebViewClient : public WebViewClient {
+};
+
+static WebViewClient* defaultWebViewClient()
+{
+    static TestWebViewClient client;
+    return &client;
+}
+
+WebView* createWebViewAndLoad(const std::string& url, bool enableJavascript, WebFrameClient* webFrameClient)
+{
+    if (!webFrameClient)
+        webFrameClient = defaultWebFrameClient();
+    WebView* webView = WebView::create(defaultWebViewClient());
+    webView->settings()->setJavaScriptEnabled(enableJavascript);
+    webView->initializeMainFrame(webFrameClient);
+
+    loadFrame(webView->mainFrame(), url);
+    webkit_support::ServeAsynchronousMockedRequests();
+
+    return webView;
+}
+
+} // namespace FrameTestHelpers
+} // namespace WebKit

Added: trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h (0 => 96912)


--- trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h	2011-10-07 07:43:10 UTC (rev 96912)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FrameTestHelpers_h
+#define FrameTestHelpers_h
+
+#include <string>
+
+namespace WebKit {
+
+class WebFrame;
+class WebFrameClient;
+class WebView;
+
+namespace FrameTestHelpers {
+
+void registerMockedURLLoad(const std::string& base, const std::string& fileName);
+
+void loadFrame(WebFrame*, const std::string& url);
+
+WebView* createWebViewAndLoad(const std::string& url, bool enableJavascript = false, WebFrameClient* = 0);
+
+} // namespace FrameTestHelpers
+} // namespace WebKit
+
+#endif // FrameTestHelpers_h

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (96911 => 96912)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2011-10-07 07:06:09 UTC (rev 96911)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2011-10-07 07:43:10 UTC (rev 96912)
@@ -30,6 +30,7 @@
 
 #include "config.h"
 
+#include "FrameTestHelpers.h"
 #include "ResourceError.h"
 #include "WebDocument.h"
 #include "WebFormElement.h"
@@ -39,14 +40,8 @@
 #include "WebSearchableFormData.h"
 #include "WebSecurityPolicy.h"
 #include "WebSettings.h"
-#include "WebString.h"
-#include "WebURL.h"
-#include "WebURLRequest.h"
-#include "WebURLResponse.h"
-#include "WebViewClient.h"
 #include "WebViewImpl.h"
 #include "v8.h"
-#include <googleurl/src/gurl.h>
 #include <gtest/gtest.h>
 #include <webkit/support/webkit_support.h>
 
@@ -57,8 +52,8 @@
 class WebFrameTest : public testing::Test {
 public:
     WebFrameTest()
-        : baseURL("http://www.test.com/"),
-          chromeURL("chrome://")
+        : m_baseURL("http://www.test.com/"),
+          m_chromeURL("chrome://")
     {
     }
 
@@ -69,61 +64,19 @@
 
     void registerMockedHttpURLLoad(const std::string& fileName)
     {
-        registerMockedURLLoad(baseURL, fileName);
+        FrameTestHelpers::registerMockedURLLoad(m_baseURL, fileName);
     }
 
     void registerMockedChromeURLLoad(const std::string& fileName)
     {
-        registerMockedURLLoad(chromeURL, fileName);
+        FrameTestHelpers::registerMockedURLLoad(m_chromeURL, fileName);
     }
 
-    void serveRequests()
-    {
-        webkit_support::ServeAsynchronousMockedRequests();
-    }
-
-    void loadHttpFrame(WebFrame* frame, const std::string& fileName)
-    {
-        loadFrame(frame, baseURL, fileName);
-    }
-
-    void loadChromeFrame(WebFrame* frame, const std::string& fileName)
-    {
-        loadFrame(frame, chromeURL, fileName);
-    }
-
-    void registerMockedURLLoad(const std::string& base, const std::string& fileName)
-    {
-        WebURLResponse response;
-        response.initialize();
-        response.setMIMEType("text/html");
-
-        std::string filePath = webkit_support::GetWebKitRootDir().utf8();
-        filePath += "/Source/WebKit/chromium/tests/data/";
-        filePath += fileName;
-
-        webkit_support::RegisterMockedURL(WebURL(GURL(base + fileName)), response, WebString::fromUTF8(filePath));
-    }
-
-    void loadFrame(WebFrame* frame, const std::string& base, const std::string& fileName)
-    {
-        WebURLRequest urlRequest;
-        urlRequest.initialize();
-        urlRequest.setURL(WebURL(GURL(base + fileName)));
-        frame->loadRequest(urlRequest);
-    }
-
 protected:
-    std::string baseURL;
-    std::string chromeURL;
+    std::string m_baseURL;
+    std::string m_chromeURL;
 };
 
-class TestWebFrameClient : public WebFrameClient {
-};
-
-class TestWebViewClient : public WebViewClient {
-};
-
 TEST_F(WebFrameTest, ContentText)
 {
     registerMockedHttpURLLoad("iframes_test.html");
@@ -131,14 +84,8 @@
     registerMockedHttpURLLoad("invisible_iframe.html");
     registerMockedHttpURLLoad("zero_sized_iframe.html");
 
-    // Create and initialize the WebView.
-    TestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->initializeMainFrame(&webFrameClient);
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html");
 
-    loadHttpFrame(webView->mainFrame(), "iframes_test.html");
-    serveRequests();
-
     // Now retrieve the frames text and test it only includes visible elements.
     std::string content = webView->mainFrame()->contentAsText(1024).utf8();
     EXPECT_NE(std::string::npos, content.find(" visible paragraph"));
@@ -157,15 +104,8 @@
     registerMockedHttpURLLoad("invisible_iframe.html");
     registerMockedHttpURLLoad("zero_sized_iframe.html");
 
-    // Create and initialize the WebView.
-    TestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->settings()->setJavaScriptEnabled(true);
-    webView->initializeMainFrame(&webFrameClient);
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html", true);
 
-    loadHttpFrame(webView->mainFrame(), "iframes_test.html");
-    serveRequests();
-
     v8::HandleScope scope;
     EXPECT_EQ(webView->mainFrame(),
               WebFrame::frameForContext(
@@ -181,13 +121,8 @@
 {
     registerMockedHttpURLLoad("form.html");
 
-    TestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->initializeMainFrame(&webFrameClient);
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.html");
 
-    loadHttpFrame(webView->mainFrame(), "form.html");
-    serveRequests();
-
     WebVector<WebFormElement> forms;
     webView->mainFrame()->document().forms(forms);
     webView->close();
@@ -202,18 +137,11 @@
 {
     registerMockedChromeURLLoad("history.html");
 
-    // Create and initialize the WebView.
-    TestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->settings()->setJavaScriptEnabled(true);
-    webView->initializeMainFrame(&webFrameClient);
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.html", true);
 
-    loadChromeFrame(webView->mainFrame(), "history.html");
-    serveRequests();
-
     // Try to run JS against the chrome-style URL.
     WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome");
-    loadFrame(webView->mainFrame(), "_javascript_:", "document.body.appendChild(document.createTextNode('Clobbered'))");
+    FrameTestHelpers::loadFrame(webView->mainFrame(), "_javascript_:document.body.appendChild(document.createTextNode('Clobbered'))");
 
     // Now retrieve the frames text and see if it was clobbered.
     std::string content = webView->mainFrame()->contentAsText(1024).utf8();
@@ -247,17 +175,12 @@
     registerMockedHttpURLLoad("form.html");
 
     TestReloadDoesntRedirectWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->initializeMainFrame(&webFrameClient);
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.html", false, &webFrameClient);
 
-    loadHttpFrame(webView->mainFrame(), "form.html");
-    serveRequests();
-    // Frame is loaded.
-
     webView->mainFrame()->reload(true);
     // start reload before request is delivered.
     webView->mainFrame()->reload(true);
-    serveRequests();
+    webkit_support::ServeAsynchronousMockedRequests();
 }
 
 TEST_F(WebFrameTest, ClearFocusedNodeTest)
@@ -265,16 +188,8 @@
     registerMockedHttpURLLoad("iframe_clear_focused_node_test.html");
     registerMockedHttpURLLoad("autofocus_input_field_iframe.html");
 
-    // Create and initialize the WebView.
-    TestWebFrameClient webFrameClient;
-    TestWebViewClient webviewClient;
-    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(WebView::create(&webviewClient));
-    webViewImpl->settings()->setJavaScriptEnabled(true);
-    webViewImpl->initializeMainFrame(&webFrameClient);
+    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_clear_focused_node_test.html", true));
 
-    loadHttpFrame(webViewImpl->mainFrame(), "iframe_clear_focused_node_test.html");
-    serveRequests();
-
     // Clear the focused node.
     webViewImpl->clearFocusedNode();
 
@@ -353,11 +268,7 @@
 
     // Load a frame with an iframe, make sure we get the right create notifications.
     ContextLifetimeTestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->settings()->setJavaScriptEnabled(true);
-    webView->initializeMainFrame(&webFrameClient);
-    loadHttpFrame(webView->mainFrame(), "context_notifications_test.html");
-    serveRequests();
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient);
 
     WebFrame* mainFrame = webView->mainFrame();
     WebFrame* childFrame = mainFrame->firstChild();
@@ -395,15 +306,11 @@
     registerMockedHttpURLLoad("context_notifications_test_frame.html");
 
     ContextLifetimeTestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->settings()->setJavaScriptEnabled(true);
-    webView->initializeMainFrame(&webFrameClient);
-    loadHttpFrame(webView->mainFrame(), "context_notifications_test.html");
-    serveRequests();
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient);
 
     // Refresh, we should get two release notifications and two more create notifications.
     webView->mainFrame()->reload(false);
-    serveRequests();
+    webkit_support::ServeAsynchronousMockedRequests();
     ASSERT_EQ(4u, webFrameClient.createNotifications.size());
     ASSERT_EQ(2u, webFrameClient.releaseNotifications.size());
 
@@ -438,11 +345,7 @@
     registerMockedHttpURLLoad("context_notifications_test_frame.html");
 
     ContextLifetimeTestWebFrameClient webFrameClient;
-    WebView* webView = WebView::create(0);
-    webView->settings()->setJavaScriptEnabled(true);
-    webView->initializeMainFrame(&webFrameClient);
-    loadHttpFrame(webView->mainFrame(), "context_notifications_test.html");
-    serveRequests();
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient);
 
     // Add an isolated world.
     webFrameClient.reset();

Added: trunk/Source/WebKit/chromium/tests/WebViewTest.cpp (0 => 96912)


--- trunk/Source/WebKit/chromium/tests/WebViewTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/WebViewTest.cpp	2011-10-07 07:43:10 UTC (rev 96912)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebView.h"
+
+#include "Document.h"
+#include "FrameTestHelpers.h"
+#include "HTMLDocument.h"
+#include "WebDocument.h"
+#include "WebFrame.h"
+#include "WebFrameImpl.h"
+#include <gtest/gtest.h>
+#include <webkit/support/webkit_support.h>
+
+using namespace WebKit;
+
+namespace {
+
+class WebViewTest : public testing::Test {
+public:
+    WebViewTest()
+        : m_baseURL("http://www.test.com/")
+    {
+    }
+
+    virtual void TearDown()
+    {
+        webkit_support::UnregisterAllMockedURLs();
+    }
+
+protected:
+    std::string m_baseURL;
+};
+
+TEST_F(WebViewTest, FocusIsInactive)
+{
+    FrameTestHelpers::registerMockedURLLoad(m_baseURL, "visible_iframe.html");
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visible_iframe.html");
+
+    webView->setFocus(true);
+    WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame());
+    EXPECT_TRUE(frame->frame()->document()->isHTMLDocument());
+
+    WebCore::HTMLDocument* document = static_cast<WebCore::HTMLDocument*>(frame->frame()->document());
+    EXPECT_TRUE(document->hasFocus());
+    webView->setFocus(false);
+    EXPECT_FALSE(document->hasFocus());
+    webView->setFocus(true);
+    EXPECT_TRUE(document->hasFocus());
+
+    webView->close();
+}
+
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to