summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-20 19:07:22 +0000
committerbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-20 19:07:22 +0000
commit801edb5e32b17541bec8c927a48b1ebd96b67ed1 (patch)
treefb2e36735837c9d7a48edc31b715597726ad62ff
parenta09ea7e7c27aa551a3f0929b4a78f585c1605821 (diff)
downloadchromium_src-801edb5e32b17541bec8c927a48b1ebd96b67ed1.zip
chromium_src-801edb5e32b17541bec8c927a48b1ebd96b67ed1.tar.gz
chromium_src-801edb5e32b17541bec8c927a48b1ebd96b67ed1.tar.bz2
[AndroidWebView] Properly escape the "Web Page Unavailable" document.
BUG=344887 Review URL: https://codereview.chromium.org/172573002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252344 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java22
-rw-r--r--android_webview/renderer/aw_content_renderer_client.cc3
-rw-r--r--android_webview/test/shell/res/raw/error.html6
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellResourceProvider.java2
4 files changed, 31 insertions, 2 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
index 70ab742..ad524c0 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -446,4 +446,26 @@ public class AwContentsTest extends AwTestBase {
});
callback.waitForCallback(0, 1, WAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
}
+
+ @Feature({"AndroidWebView"})
+ @SmallTest
+ public void testEscapingOfErrorPage() throws Throwable {
+ AwTestContainerView testView = createAwTestContainerViewOnMainSync(mContentsClient);
+ AwContents awContents = testView.getAwContents();
+ String SCRIPT = "window.failed == true";
+
+ enableJavaScriptOnUiThread(awContents);
+ CallbackHelper onPageFinishedHelper = mContentsClient.getOnPageFinishedHelper();
+ int currentCallCount = onPageFinishedHelper.getCallCount();
+ loadUrlAsync(awContents,
+ "file:///file-that-does-not-exist#<script>window.failed = true;</script>");
+ // We must wait for two onPageFinished callbacks. One for the original failing URL, and
+ // one for the error page that we then display to the user.
+ onPageFinishedHelper.waitForCallback(currentCallCount, 2, WAIT_TIMEOUT_MS,
+ TimeUnit.MILLISECONDS);
+
+ assertEquals("false", executeJavaScriptAndWaitForResult(awContents, mContentsClient,
+ SCRIPT));
+ }
+
}
diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc
index 628d284..7001aff 100644
--- a/android_webview/renderer/aw_content_renderer_client.cc
+++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -22,6 +22,7 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
+#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
@@ -170,7 +171,7 @@ void AwContentRendererClient::GetNavigationErrorStrings(
}
ReplaceSubstringsAfterOffset(&contents, 0, "%s",
- error_url.possibly_invalid_spec());
+ net::EscapeForHTML(error_url.possibly_invalid_spec()));
*error_html = contents;
}
if (error_description) {
diff --git a/android_webview/test/shell/res/raw/error.html b/android_webview/test/shell/res/raw/error.html
new file mode 100644
index 0000000..ec1ee5c
--- /dev/null
+++ b/android_webview/test/shell/res/raw/error.html
@@ -0,0 +1,6 @@
+<html>
+ <head>
+ <title>Error</title>
+ <p>An error occured loading %s</p>
+ </head>
+</html>
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellResourceProvider.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellResourceProvider.java
index dd54ad3..bfc8125 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellResourceProvider.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellResourceProvider.java
@@ -21,7 +21,7 @@ public class AwShellResourceProvider {
AwResource.setResources(context.getResources());
- AwResource.setErrorPageResources(R.raw.blank_html, R.raw.blank_html);
+ AwResource.setErrorPageResources(R.raw.error, R.raw.blank_html);
AwResource.setDefaultTextEncoding(R.string.default_encoding);