aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-21 13:27:06 -0500
committerGitHub <noreply@github.com>2016-07-21 13:27:06 -0500
commit1e835e330df49da068928231a5b55b165c360a42 (patch)
tree4e805cc1ac5a0af13b83d76ecb30856c9bd2d2c7
parentde4eaa4f21c53a1d1da7d58ef2cda8ef28989fb6 (diff)
parent8e3593aa670c1bd5d775870c3b75852859bbd572 (diff)
downloadservo-1e835e330df49da068928231a5b55b165c360a42.tar.gz
servo-1e835e330df49da068928231a5b55b165c360a42.zip
Auto merge of #12539 - johannhof:error-page, r=jdm
Improve page load error information Fixes #8640. This commit adds a neterror page that displays really really basic information about what went wrong with your request, which is an improvement over the current state of blank page. It also fixes the problem of certificate validation errors not triggering the cert error page, since for some reason the function string seems to have turned lowercase. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #8640. - [x] These changes do not require tests because I'm not sure how to test this, suggestions welcome! r?@jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12539) <!-- Reviewable:end -->
-rw-r--r--components/net/http_loader.rs2
-rw-r--r--components/script/dom/servohtmlparser.rs17
-rw-r--r--resources/neterror.html8
3 files changed, 23 insertions, 4 deletions
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs
index 80a7b91e335..a39d284a486 100644
--- a/components/net/http_loader.rs
+++ b/components/net/http_loader.rs
@@ -1143,7 +1143,7 @@ fn is_cert_verify_error(error: &OpensslError) -> bool {
match error {
&OpensslError::UnknownError { ref library, ref function, ref reason } => {
library == "SSL routines" &&
- function == "SSL3_GET_SERVER_CERTIFICATE" &&
+ function.to_uppercase() == "SSL3_GET_SERVER_CERTIFICATE" &&
reason == "certificate verify failed"
}
}
diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs
index 884ac6c8653..a28612416fc 100644
--- a/components/script/dom/servohtmlparser.rs
+++ b/components/script/dom/servohtmlparser.rs
@@ -171,13 +171,24 @@ impl AsyncResponseListener for ParserContext {
Some(parser) => parser.root(),
None => return,
};
- parser.r().document().finish_load(LoadType::PageSource(self.url.clone()));
- if let Err(err) = status {
- debug!("Failed to load page URL {}, error: {:?}", self.url, err);
+ if let Err(NetworkError::Internal(ref reason)) = status {
+ // Show an error page for network errors,
+ // certificate errors are handled earlier.
+ self.is_synthesized_document = true;
+ let parser = parser.r();
+ let page_bytes = read_resource_file("neterror.html").unwrap();
+ let page = String::from_utf8(page_bytes).unwrap();
+ let page = page.replace("${reason}", reason);
+ parser.pending_input().borrow_mut().push(page);
+ parser.parse_sync();
+ } else if let Err(err) = status {
// TODO(Savago): we should send a notification to callers #5463.
+ debug!("Failed to load page URL {}, error: {:?}", self.url, err);
}
+ parser.r().document().finish_load(LoadType::PageSource(self.url.clone()));
+
parser.r().last_chunk_received().set(true);
if !parser.r().is_suspended() {
parser.r().parse_sync();
diff --git a/resources/neterror.html b/resources/neterror.html
new file mode 100644
index 00000000000..8af6cbb2d08
--- /dev/null
+++ b/resources/neterror.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+ <title>Error loading page</title>
+</head>
+<body>
+ <p>Could not load the requested page: ${reason}</p>
+</body>
+</html>