[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jcivelli at chromium.org jcivelli at chromium.org
Wed Dec 22 12:27:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 60c6bbde00a64b118f7d76b75a918f0644c3524d
Author: jcivelli at chromium.org <jcivelli at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 24 03:43:08 2010 +0000

    2010-08-23  Jay Civelli  <jcivelli at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Made WebFrame not report the text from hidden frames.
            (some pages contain hidden frames with garbage text that
            should not be indexed or used to detect the page's language).
            https://bugs.webkit.org/show_bug.cgi?id=39456
    
            * WebKit.gyp:
            * public/WebCString.h:
            (WebKit::operator<):
            * public/WebURL.h:
            (WebKit::operator<):
            * src/WebCString.cpp:
            (WebKit::WebCString::compare):
            * src/WebFrameImpl.cpp:
            (WebKit::frameContentAsPlainText):
            * tests/RunAllTests.cpp:
            (main):
            * tests/WebFrameTest.cpp: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65860 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index df00a00..67b6a9d 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,25 @@
+2010-08-23  Jay Civelli  <jcivelli at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Made WebFrame not report the text from hidden frames.
+        (some pages contain hidden frames with garbage text that
+        should not be indexed or used to detect the page's language).
+        https://bugs.webkit.org/show_bug.cgi?id=39456
+
+        * WebKit.gyp:
+        * public/WebCString.h:
+        (WebKit::operator<):
+        * public/WebURL.h:
+        (WebKit::operator<):
+        * src/WebCString.cpp:
+        (WebKit::WebCString::compare):
+        * src/WebFrameImpl.cpp:
+        (WebKit::frameContentAsPlainText):
+        * tests/RunAllTests.cpp:
+        (main):
+        * tests/WebFrameTest.cpp: Added.
+
 2010-08-23  Kent Tamura  <tkent at chromium.org>
 
         Unreviewed, build fix for r65852.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index d060d87..564b9f9 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -734,6 +734,7 @@
                         '<(chromium_src_dir)/base/base.gyp:base_i18n',
                         '<(chromium_src_dir)/base/base.gyp:test_support_base',
                         '<(chromium_src_dir)/gpu/gpu.gyp:gles2_c_lib',
+                        '<(chromium_src_dir)/webkit/support/webkit_support.gyp:webkit_support',
                     ],
                     'include_dirs': [
                         'public',
@@ -751,10 +752,11 @@
                     'conditions': [
                         ['OS=="win"', {
                             'sources': [
-                                # FIXME: Port PopupMenuTest to Linux and Mac.
+                                # FIXME: Port PopupMenuTest and WebFrameTest to Linux and Mac.
                                 'tests/PopupMenuTest.cpp',
                                 'tests/TransparencyWinTest.cpp',
                                 'tests/UniscribeHelperTest.cpp',
+                                'tests/WebFrameTest.cpp',
                             ],
                         }],
                         ['OS=="mac"', {
diff --git a/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp
index 671190b..4375e73 100644
--- a/WebKit/chromium/src/WebFrameImpl.cpp
+++ b/WebKit/chromium/src/WebFrameImpl.cpp
@@ -234,6 +234,15 @@ static void frameContentAsPlainText(size_t maxChars, Frame* frame,
     // Recursively walk the children.
     FrameTree* frameTree = frame->tree();
     for (Frame* curChild = frameTree->firstChild(); curChild; curChild = curChild->tree()->nextSibling()) {
+        // Ignore the text of non-visible frames.
+        RenderView* contentRenderer = curChild->contentRenderer();
+        RenderPart* ownerRenderer = curChild->ownerRenderer();        
+        if (!contentRenderer || !contentRenderer->width() || !contentRenderer->height()
+            || (contentRenderer->x() + contentRenderer->width() <= 0) || (contentRenderer->y() + contentRenderer->height() <= 0)
+            || (ownerRenderer && ownerRenderer->style() && ownerRenderer->style()->visibility() != VISIBLE)) {
+            continue;
+        }
+
         // Make sure the frame separator won't fill up the buffer, and give up if
         // it will. The danger is if the separator will make the buffer longer than
         // maxChars. This will cause the computation above:
diff --git a/WebKit/chromium/tests/RunAllTests.cpp b/WebKit/chromium/tests/RunAllTests.cpp
index 0f3f82f..cfcfbee 100644
--- a/WebKit/chromium/tests/RunAllTests.cpp
+++ b/WebKit/chromium/tests/RunAllTests.cpp
@@ -33,18 +33,15 @@
 
 #include "WebKit.h"
 #include "WebKitClient.h"
-
-// WebKitClient has a protected destructor, so we need to subclass.
-class DummyWebKitClient : public WebKit::WebKitClient {
-};
+#include <webkit/support/webkit_support.h>
 
 int main(int argc, char** argv)
 {
-    DummyWebKitClient dummyClient;
-    WebKit::initialize(&dummyClient);
-
-    int result = TestSuite(argc, argv).Run();
-
-    WebKit::shutdown();
+    TestSuite testSuite(argc, argv);
+    // TestSuite must be created before SetUpTestEnvironment so it performs
+    // initializations needed by WebKit support.
+    webkit_support::SetUpTestEnvironmentForUnitTests();
+    int result = testSuite.Run();
+    webkit_support::TearDownTestEnvironment();
     return result;
 }
diff --git a/WebKit/chromium/tests/WebFrameTest.cpp b/WebKit/chromium/tests/WebFrameTest.cpp
new file mode 100644
index 0000000..cf91cb4
--- /dev/null
+++ b/WebKit/chromium/tests/WebFrameTest.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2010 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 <googleurl/src/gurl.h>
+#include <gtest/gtest.h>
+#include <webkit/support/webkit_support.h>
+#include "WebFrame.h"
+#include "WebFrameClient.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+#include "WebView.h"
+
+using namespace WebKit;
+
+namespace {
+
+class WebFrameTest : public testing::Test {
+public:
+    WebFrameTest() {}
+
+    virtual void TearDown()
+    {
+        webkit_support::UnregisterAllMockedURLs();
+    }
+
+    void registerMockedURLLoad(const WebURL& url, const WebURLResponse& response, const WebString& fileName)
+    {
+        std::string filePath = webkit_support::GetWebKitRootDir().utf8();
+        filePath.append("/WebKit/chromium/tests/data/");
+        filePath.append(fileName.utf8());
+        webkit_support::RegisterMockedURL(url, response, WebString::fromUTF8(filePath));
+    }
+
+    void serveRequests()
+    {
+        webkit_support::ServeAsynchronousMockedRequests();
+    }
+};
+
+class TestWebFrameClient : public WebFrameClient {
+};
+
+TEST_F(WebFrameTest, ContentText)
+{
+    // Register our resources.
+    WebURLResponse response;
+    response.initialize();
+    response.setMIMEType("text/html");
+    std::string rootURL = "http://www.test.com/";
+    const char* files[] = { "iframes_test.html", "visible_iframe.html",
+                            "invisible_iframe.html", "zero_sized_iframe.html" };
+    for (int i = 0; i < (sizeof(files) / sizeof(char*)); ++i) {
+        WebURL webURL = GURL(rootURL + files[i]);
+        registerMockedURLLoad(webURL, response, WebString::fromUTF8(files[i]));
+    }
+
+    // Create and initialize the WebView.    
+    TestWebFrameClient webFrameClient;
+    WebView* webView = WebView::create(0, 0);
+    webView->initializeMainFrame(&webFrameClient);
+
+    // Load the main frame URL.
+    WebURL testURL(GURL(rootURL + files[0]));
+    WebURLRequest urlRequest;
+    urlRequest.initialize();
+    urlRequest.setURL(testURL);
+    webView->mainFrame()->loadRequest(urlRequest);
+
+    // Load all pending asynchronous requests.
+    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"));
+    EXPECT_NE(std::string::npos, content.find(" visible iframe"));
+    EXPECT_EQ(std::string::npos, content.find(" invisible pararaph"));
+    EXPECT_EQ(std::string::npos, content.find(" invisible iframe"));
+    EXPECT_EQ(std::string::npos, content.find("iframe with zero size"));
+
+    webView->close();
+}
+
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list