summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/errorpage_uitest.cc27
-rw-r--r--chrome/test/data/iframe404-inner.html1
-rw-r--r--chrome/test/data/iframe404-inner.html.mock-http-headers2
-rw-r--r--chrome/test/data/iframe404.html2
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc7
5 files changed, 36 insertions, 3 deletions
diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc
index 8da9f1d..ec63430 100644
--- a/chrome/browser/errorpage_uitest.cc
+++ b/chrome/browser/errorpage_uitest.cc
@@ -5,6 +5,7 @@
#include "base/string_util.h"
#include "chrome/test/ui/ui_test.h"
#include "chrome/browser/automation/url_request_failed_dns_job.h"
+#include "net/url_request/url_request_unittest.h"
class ErrorPageTest : public UITest {
};
@@ -32,3 +33,29 @@ TEST_F(ErrorPageTest, DNSError) {
}
};
+TEST_F(ErrorPageTest, IFrame404) {
+ // iframes that have 404 pages should not trigger an alternate error page.
+ // In this test, the iframe sets the title of the parent page to "SUCCESS"
+ // when the iframe loads. If the iframe fails to load (because an alternate
+ // error page loads instead), then the title will remain as "FAIL".
+ TestServer server(L"chrome/test/data");
+ GURL test_url = server.TestServerPage("files/iframe404.html");
+ NavigateToURL(test_url);
+
+ // Verify that the url is in the title. Since it's set via Javascript, we
+ // need to give it a chance to run.
+ int i;
+ std::wstring title;
+ for (i = 0; i < 10; ++i) {
+ Sleep(kWaitForActionMaxMsec / 10);
+ title = GetActiveTabTitle();
+ if (title == L"SUCCESS") {
+ // Success, bail out.
+ break;
+ }
+ }
+
+ if (i == 10) {
+ FAIL() << "iframe 404 didn't load properly";
+ }
+};
diff --git a/chrome/test/data/iframe404-inner.html b/chrome/test/data/iframe404-inner.html
new file mode 100644
index 0000000..c992efc0
--- /dev/null
+++ b/chrome/test/data/iframe404-inner.html
@@ -0,0 +1 @@
+<script>window.parent.document.title="SUCCESS"</script>
diff --git a/chrome/test/data/iframe404-inner.html.mock-http-headers b/chrome/test/data/iframe404-inner.html.mock-http-headers
new file mode 100644
index 0000000..0590363
--- /dev/null
+++ b/chrome/test/data/iframe404-inner.html.mock-http-headers
@@ -0,0 +1,2 @@
+HTTP/1.0 404 Not Found
+Content-type: text/html
diff --git a/chrome/test/data/iframe404.html b/chrome/test/data/iframe404.html
new file mode 100644
index 0000000..3089555
--- /dev/null
+++ b/chrome/test/data/iframe404.html
@@ -0,0 +1,2 @@
+<title>FAILURE</title>
+<iframe src="iframe404-inner.html"></iframe>
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 7d3011c..d8fed70 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -241,10 +241,10 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader,
unsigned long identifier,
const ResourceResponse& response) {
- // True if the request was for the page's main frame, or a subframe.
- bool is_frame = ResourceType::IsFrame(DetermineResourceTypeFromLoader(loader));
/* TODO(evanm): reenable this once we properly sniff XHTML from text/xml documents.
+ // True if the request was for the page's main frame, or a subframe.
+ bool is_frame = ResourceType::IsFrame(DetermineResourceTypeFromLoader(loader));
if (is_frame &&
response.httpStatusCode() == 200 &&
mime_util::IsViewSourceMimeType(
@@ -262,7 +262,8 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader,
// If it's a 404 page, we wait until we get 512 bytes of data before trying
// to load the document. This allows us to put up an alternate 404 page if
// there's short text.
- postpone_loading_data_ = is_frame &&
+ postpone_loading_data_ =
+ ResourceType::MAIN_FRAME == DetermineResourceTypeFromLoader(loader) &&
!is_substitute_data &&
response.httpStatusCode() == 404 &&
GetAlt404PageUrl(loader).is_valid();