Title: [99661] trunk/Source/WebKit/chromium
Revision
99661
Author
[email protected]
Date
2011-11-09 00:06:11 -0800 (Wed, 09 Nov 2011)

Log Message

Fixes and reenables the WebPageSerializer tests.
https://bugs.webkit.org/show_bug.cgi?id=71874

Reviewed by Adam Barth.

* WebKit.gypi:
* tests/WebPageNewSerializerTest.cpp:
(WebKit::TestWebFrameClient::~TestWebFrameClient):
(WebKit::WebPageNewSerializeTest::SetUp):
(WebKit::WebPageNewSerializeTest::resourceVectorContains):
(WebKit::TEST_F):
* tests/WebPageSerializerTest.cpp:
(WebKit::WebPageSerializerTest::WebPageSerializerTest):
(WebKit::WebPageSerializerTest::webVectorContains):
(WebKit::TEST_F):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (99660 => 99661)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-09 08:00:41 UTC (rev 99660)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-09 08:06:11 UTC (rev 99661)
@@ -1,3 +1,21 @@
+2011-11-08  Jay Civelli  <[email protected]>
+
+        Fixes and reenables the WebPageSerializer tests.
+        https://bugs.webkit.org/show_bug.cgi?id=71874
+
+        Reviewed by Adam Barth.
+
+        * WebKit.gypi:
+        * tests/WebPageNewSerializerTest.cpp:
+        (WebKit::TestWebFrameClient::~TestWebFrameClient):
+        (WebKit::WebPageNewSerializeTest::SetUp):
+        (WebKit::WebPageNewSerializeTest::resourceVectorContains):
+        (WebKit::TEST_F):
+        * tests/WebPageSerializerTest.cpp:
+        (WebKit::WebPageSerializerTest::WebPageSerializerTest):
+        (WebKit::WebPageSerializerTest::webVectorContains):
+        (WebKit::TEST_F):
+
 2011-11-07  Adam Barth  <[email protected]>
 
         Move static "policy" state from SecurityOrigin.cpp to SecurityPolicy.cpp

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (99660 => 99661)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2011-11-09 08:00:41 UTC (rev 99660)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2011-11-09 08:06:11 UTC (rev 99661)
@@ -88,6 +88,8 @@
             'tests/WebCompositorImplTest.cpp',
             'tests/WebFrameTest.cpp',
             'tests/WebLayerTest.cpp',
+            'tests/WebPageNewSerializerTest.cpp',
+            'tests/WebPageSerializerTest.cpp',
             'tests/WebURLRequestTest.cpp',
             'tests/WebViewTest.cpp',
         ],

Modified: trunk/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp (99660 => 99661)


--- trunk/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp	2011-11-09 08:00:41 UTC (rev 99660)
+++ trunk/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp	2011-11-09 08:06:11 UTC (rev 99661)
@@ -51,9 +51,7 @@
 
 class TestWebFrameClient : public WebFrameClient {
 public:
-    TestWebFrameClient() : m_scriptEnabled(false) { }
-    virtual bool allowScript(WebFrame*, bool /* enabledPerSettings */) { return m_scriptEnabled; }
-    bool m_scriptEnabled;
+    virtual ~TestWebFrameClient() { }
 };
 
 class WebPageNewSerializeTest : public testing::Test {
@@ -72,10 +70,11 @@
         // Create and initialize the WebView.
         m_webView = WebView::create(0);
 
-        // We want the images to load.
+        // We want the images to load and _javascript_ to be on.
         WebSettings* settings = m_webView->settings();
         settings->setImagesEnabled(true);
         settings->setLoadsImagesAutomatically(true);
+        settings->setJavaScriptEnabled(true);
 
         m_webView->initializeMainFrame(&m_webFrameClient);
     }
@@ -112,22 +111,12 @@
         webkit_support::ServeAsynchronousMockedRequests();
     }
 
-    void enableJS()
-    {
-        m_webFrameClient.m_scriptEnabled = true;
-    }
-
-    void runOnLoad()
-    {
-        m_webView->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8("onLoad()")));
-    }
-
     const WebString& htmlMimeType() const { return m_htmlMimeType; }
     const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; }
     const WebString& cssMimeType() const { return m_cssMimeType; }
     const WebString& pngMimeType() const { return m_pngMimeType; }
-    
-    static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, char* url, char* mimeType)
+
+    static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, const char* url, const char* mimeType)
     {
         WebURL webURL = WebURL(GURL(url));
         for (size_t i = 0; i < resources.size(); ++i) {
@@ -137,7 +126,7 @@
         }
         return false;
     }
-    
+
     WebView* m_webView;
 
 private:
@@ -149,8 +138,7 @@
 };
 
 // Tests that a page with resources and sub-frame is reported with all its resources.
-// FIXME: reenable these tests once the Chromium part of the test_webkit_client have landed.
-TEST_F(WebPageNewSerializeTest, DISABLED_PageWithFrames)
+TEST_F(WebPageNewSerializeTest, PageWithFrames)
 {
     // Register the mocked frames.
     WebURL topFrameURL = GURL("http://www.test.com");
@@ -166,14 +154,14 @@
     WebVector<WebPageSerializer::Resource> resources;
     WebPageSerializer::serialize(m_webView, &resources);
     ASSERT_FALSE(resources.isEmpty());
-    
+
     // The first resource should be the main-frame.
     const WebPageSerializer::Resource& resource = resources[0];
     EXPECT_TRUE(resource.url == GURL("http://www.test.com"));
     EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html")));
     EXPECT_FALSE(resource.data.isEmpty());
 
-    EXPECT_EQ(6, resources.size()); // There should be no duplicates.
+    EXPECT_EQ(6U, resources.size()); // There should be no duplicates.
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/red_background.png", "image/png"));
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/green_background.png", "image/png"));
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/blue_background.png", "image/png"));
@@ -184,7 +172,7 @@
 // Test that when serializing a page, all CSS resources are reported, including url()'s
 // and imports and links. Note that we don't test the resources contents, we only make sure
 // they are all reported with the right mime type and that they contain some data.
-TEST_F(WebPageNewSerializeTest, DISABLED_CSSResources)
+TEST_F(WebPageNewSerializeTest, CSSResources)
 {
     // Register the mocked frame and load it.
     WebURL topFrameURL = GURL("http://www.test.com");
@@ -201,21 +189,19 @@
     registerMockedURLLoad(GURL("http://www.test.com/ul-dot.png"), WebString::fromUTF8("ul-dot.png"), pngMimeType());
     registerMockedURLLoad(GURL("http://www.test.com/ol-dot.png"), WebString::fromUTF8("ol-dot.png"), pngMimeType());
 
-    enableJS();
     loadURLInTopFrame(topFrameURL);
-    runOnLoad();
 
     WebVector<WebPageSerializer::Resource> resources;
     WebPageSerializer::serialize(m_webView, &resources);
     ASSERT_FALSE(resources.isEmpty());
-    
+
     // The first resource should be the main-frame.
     const WebPageSerializer::Resource& resource = resources[0];
     EXPECT_TRUE(resource.url == GURL("http://www.test.com"));
     EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html")));
     EXPECT_FALSE(resource.data.isEmpty());
 
-    EXPECT_EQ(12, resources.size()); // There should be no duplicates.
+    EXPECT_EQ(12U, resources.size()); // There should be no duplicates.
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/link_styles.css", "text/css"));
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/import_styles.css", "text/css"));
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/import_style_from_link.css", "text/css"));
@@ -230,7 +216,7 @@
 }
 
 // Tests that when serializing a page with blank frames these are reported with their resources.
-TEST_F(WebPageNewSerializeTest, DISABLED_BlankFrames)
+TEST_F(WebPageNewSerializeTest, BlankFrames)
 {
     // Register the mocked frame and load it.
     WebURL topFrameURL = GURL("http://www.test.com");
@@ -239,21 +225,19 @@
     registerMockedURLLoad(GURL("http://www.test.com/orange_background.png"), WebString::fromUTF8("orange_background.png"), pngMimeType());
     registerMockedURLLoad(GURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), pngMimeType());
 
-    enableJS();
     loadURLInTopFrame(topFrameURL);
-    runOnLoad();
 
     WebVector<WebPageSerializer::Resource> resources;
     WebPageSerializer::serialize(m_webView, &resources);
     ASSERT_FALSE(resources.isEmpty());
-    
+
     // The first resource should be the main-frame.
     const WebPageSerializer::Resource& resource = resources[0];
     EXPECT_TRUE(resource.url == GURL("http://www.test.com"));
     EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html")));
     EXPECT_FALSE(resource.data.isEmpty());
 
-    EXPECT_EQ(7, resources.size()); // There should be no duplicates.
+    EXPECT_EQ(7U, resources.size()); // There should be no duplicates.
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/red_background.png", "image/png"));
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/orange_background.png", "image/png"));
     EXPECT_TRUE(resourceVectorContains(resources, "http://www.test.com/blue_background.png", "image/png"));
@@ -263,7 +247,7 @@
     EXPECT_TRUE(resourceVectorContains(resources, "wyciwyg://frame/2", "text/html"));
 }
 
-TEST_F(WebPageNewSerializeTest, DISABLED_SerializeXMLHasRightDeclaration)
+TEST_F(WebPageNewSerializeTest, SerializeXMLHasRightDeclaration)
 {
     WebURL topFrameURL = GURL("http://www.test.com/simple.xhtml");
     registerMockedURLLoad(topFrameURL, WebString::fromUTF8("simple.xhtml"), xhtmlMimeType());
@@ -273,9 +257,9 @@
     WebVector<WebPageSerializer::Resource> resources;
     WebPageSerializer::serialize(m_webView, &resources);
     ASSERT_FALSE(resources.isEmpty());
-    
+
     // We expect only one resource, the XML.
-    ASSERT_EQ(1, resources.size());
+    ASSERT_EQ(1U, resources.size());
     std::string xml = resources[0].data;
 
     // We should have one and only one instance of the XML declaration.

Modified: trunk/Source/WebKit/chromium/tests/WebPageSerializerTest.cpp (99660 => 99661)


--- trunk/Source/WebKit/chromium/tests/WebPageSerializerTest.cpp	2011-11-09 08:00:41 UTC (rev 99660)
+++ trunk/Source/WebKit/chromium/tests/WebPageSerializerTest.cpp	2011-11-09 08:06:11 UTC (rev 99661)
@@ -52,7 +52,7 @@
 
 class WebPageSerializerTest : public testing::Test {
 public:
-    WebPageSerializerTest() : m_webView(0), m_supportedSchemes(3U)
+    WebPageSerializerTest() : m_webView(0), m_supportedSchemes(static_cast<size_t>(3))
     {
         m_supportedSchemes[0] = "http";
         m_supportedSchemes[1] = "https";
@@ -94,7 +94,7 @@
         webkit_support::ServeAsynchronousMockedRequests();
     }
 
-    static bool webVectorContains(const WebVector<WebURL>& vector, char* url)
+    static bool webVectorContains(const WebVector<WebURL>& vector, const char* url)
     {
         return vector.contains(WebURL(GURL(url)));
     }
@@ -124,13 +124,13 @@
     WebVector<WebURL> frames;
     WebVector<WebURL> resources;
     ASSERT_TRUE(WebPageSerializer::retrieveAllResources(
-        m_webView, m_supportedSchemes, &resources, &frames));    
+        m_webView, m_supportedSchemes, &resources, &frames));
 
     // Tests that all resources from the frame have been retrieved.
-    EXPECT_EQ(1, frames.size()); // There should be no duplicates.
+    EXPECT_EQ(1U, frames.size()); // There should be no duplicates.
     EXPECT_TRUE(webVectorContains(frames, "http://www.test.com"));
 
-    EXPECT_EQ(14, resources.size()); // There should be no duplicates.
+    EXPECT_EQ(14U, resources.size()); // There should be no duplicates.
     EXPECT_TRUE(webVectorContains(resources, "http://www.example.com/beautifull.css"));
     EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.js"));
     EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/bodyBackground.jpg"));
@@ -170,16 +170,16 @@
     WebVector<WebURL> frames;
     WebVector<WebURL> resources;
     ASSERT_TRUE(WebPageSerializer::retrieveAllResources(
-        m_webView, m_supportedSchemes, &resources, &frames));    
+        m_webView, m_supportedSchemes, &resources, &frames));
 
     // Tests that all resources from the frame have been retrieved.
-    EXPECT_EQ(4, frames.size()); // There should be no duplicates.
+    EXPECT_EQ(4U, frames.size()); // There should be no duplicates.
     EXPECT_TRUE(webVectorContains(frames, "http://www.test.com"));
     EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.html"));
     EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/object_iframe.html"));
     EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html"));
 
-    EXPECT_EQ(5, resources.size()); // There should be no duplicates.
+    EXPECT_EQ(5U, resources.size()); // There should be no duplicates.
     EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png"));
     EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png"));
     EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf"));

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/blue_background.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/blue_background.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/blue_background.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDRddJ,PLTE\xEE\xE0\xC8\xF2\xA5tIME\xDB	\xD2
+&tEXtSoftwareXPaint 2.8.13_]-\xB4IDAT8\x8Dc`\xA3`\x8C\x82Q@Ox\xF9\xA5^\xC7IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/green_background.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/green_background.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/green_background.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,4 @@
+\x89PNG
+
+
+IHDRddJ,PLTE\xFF4^\xC0\xA8tIME\xDB	\xC8\xD7\xDA[tEXtSoftwareXPaint 2.8.13_]-\xB4IDAT8\x8Dc`\xA3`\x8C\x82Q@Ox\xF9\xA5^\xC7IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/ol-dot.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/ol-dot.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/ol-dot.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,4 @@
+\x89PNG
+
+
+IHDR\xB7G\x8FNPLTE\xFF\xFF\xFF\xA5ٟ\xDDtIME\xDB	S\xD0\x87tEXtSoftwareXPaint 2.8.13_]-\xB4'IDAT\x99c\xF8\xFF\xFF\xFE\xC1\x81t=?`\xF8\xC0\xF0\xFD;\x83\xE4\xFF\xB0C\xE5zo\x975;${@\x9AIEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/orange_background.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/orange_background.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/orange_background.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,4 @@
+\x89PNG
+
+
+IHDRddJ,PLTE\xFF\xA5ʒA\x9BtIME\xDB	\xB2ʇ\xC3tEXtSoftwareXPaint 2.8.13_]-\xB4IDAT8\x8Dc`\xA3`\x8C\x82Q@Ox\xF9\xA5^\xC7IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/purple_background.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/purple_background.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/purple_background.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,4 @@
+\x89PNG
+
+
+IHDRddJ,PLTE}&\xCD\xDDX\xFB\xF0tIME\xDB	,l\x8DtEXtSoftwareXPaint 2.8.13_]-\xB4IDAT8\x8Dc`\xA3`\x8C\x82Q@Ox\xF9\xA5^\xC7IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/red_background.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/red_background.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/red_background.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDRddJ,PLTE\xEE\xC0ptIME\xDB	
+2\xC2N}-tEXtSoftwareXPaint 2.8.13_]-\xB4IDAT8\x8Dc`\xA3`\x8C\x82Q@Ox\xF9\xA5^\xC7IEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/ul-dot.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/ul-dot.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/ul-dot.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,4 @@
+\x89PNG
+
+
+IHDR\xB7G\x8FNPLTE\xFF\xFF\xFF\xA5ٟ\xDDtIME\xDB	"\xA3c\xD7tEXtSoftwareXPaint 2.8.13_]-\xB4-IDAT\x99c\xF8\xFF\xFF2\xFE'\xFF\x81\xE1\xFB\x86\xCC0~`8\xC0\x80\x83\xE4@j@jAz\xA0\xFA\xF9 +j\x97\x8CIEND\xAEB`\x82
\ No newline at end of file

Added: trunk/Source/WebKit/chromium/tests/data/pageserializer/yellow_background.png (0 => 99661)


--- trunk/Source/WebKit/chromium/tests/data/pageserializer/yellow_background.png	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/pageserializer/yellow_background.png	2011-11-09 08:06:11 UTC (rev 99661)
@@ -0,0 +1,4 @@
+\x89PNG
+
+
+IHDRddJ,PLTE\xEE\xEE\xC4\xFBtIME\xDB	!m\xDDo0tEXtSoftwareXPaint 2.8.13_]-\xB4IDAT8\x8Dc`\xA3`\x8C\x82Q@Ox\xF9\xA5^\xC7IEND\xAEB`\x82
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to