[chromium] Port IFrameRedirectTest.Test from test_shell_tests to webkit_unit_tests
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jun 2012 02:46:41 +0000 (02:46 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jun 2012 02:46:41 +0000 (02:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89132

Reviewed by Adam Barth.

This test is currently in src/webkit/glue/iframe_redirect_unittest.cc
and uses test_shell's layoutTestController. Moving this will make
it easier to get rid of layoutTestController in test_shell.

* tests/WebFrameTest.cpp:
(WebKit::TEST_F):
(WebKit):
* tests/data/iframe_redirect.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120391 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/WebFrameTest.cpp
Source/WebKit/chromium/tests/data/iframe_redirect.html [new file with mode: 0644]

index c350b7c..7a4f0bc 100644 (file)
@@ -1,3 +1,19 @@
+2012-06-14  Tony Chang  <tony@chromium.org>
+
+        [chromium] Port IFrameRedirectTest.Test from test_shell_tests to webkit_unit_tests
+        https://bugs.webkit.org/show_bug.cgi?id=89132
+
+        Reviewed by Adam Barth.
+
+        This test is currently in src/webkit/glue/iframe_redirect_unittest.cc
+        and uses test_shell's layoutTestController. Moving this will make
+        it easier to get rid of layoutTestController in test_shell.
+
+        * tests/WebFrameTest.cpp:
+        (WebKit::TEST_F):
+        (WebKit):
+        * tests/data/iframe_redirect.html: Added.
+
 2012-06-14  David Reveman  <reveman@chromium.org>
 
         [Chromium] Sub-pixel text rendering is incorrectly used for WebView with transparent background.
index 113b6ca..4070580 100644 (file)
@@ -36,6 +36,7 @@
 #include "FrameTestHelpers.h"
 #include "FrameView.h"
 #include "ResourceError.h"
+#include "WebDataSource.h"
 #include "WebDocument.h"
 #include "WebFindOptions.h"
 #include "WebFormElement.h"
@@ -396,6 +397,28 @@ TEST_F(WebFrameTest, ReloadDoesntSetRedirect)
     webkit_support::ServeAsynchronousMockedRequests();
 }
 
+TEST_F(WebFrameTest, IframeRedirect)
+{
+    registerMockedHttpURLLoad("iframe_redirect.html");
+    registerMockedHttpURLLoad("visible_iframe.html");
+
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_redirect.html", true);
+    webkit_support::RunAllPendingMessages(); // Queue the iframe.
+    webkit_support::ServeAsynchronousMockedRequests(); // Load the iframe.
+
+    WebFrame* iframe = webView->findFrameByName(WebString::fromUTF8("ifr"));
+    ASSERT_TRUE(iframe);
+    WebDataSource* iframeDataSource = iframe->dataSource();
+    ASSERT_TRUE(iframeDataSource);
+    WebVector<WebURL> redirects;
+    iframeDataSource->redirectChain(redirects);
+    ASSERT_EQ(2U, redirects.size());
+    EXPECT_EQ(GURL("about:blank"), GURL(redirects[0]));
+    EXPECT_EQ(GURL("http://www.test.com/visible_iframe.html"), GURL(redirects[1]));
+
+    webView->close();
+}
+
 TEST_F(WebFrameTest, ClearFocusedNodeTest)
 {
     registerMockedHttpURLLoad("iframe_clear_focused_node_test.html");
diff --git a/Source/WebKit/chromium/tests/data/iframe_redirect.html b/Source/WebKit/chromium/tests/data/iframe_redirect.html
new file mode 100644 (file)
index 0000000..8176253
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+  <body>
+    <iframe id='ifr'>
+    </iframe>
+    <script>
+      var ifr = document.getElementById('ifr');
+      ifr.contentWindow.document.location = "visible_iframe.html";
+    </script>
+  </body>
+</html>