summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 23:48:34 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 23:48:34 +0000
commit03a2e4b067ca859a567c31137bf2845a8c2d6e61 (patch)
tree61160d9db030fbc3c10ff4180985f090d9fb05e9 /content
parenta73024640ac0db3e7f330d5d7b1d527e74646b6a (diff)
downloadchromium_src-03a2e4b067ca859a567c31137bf2845a8c2d6e61.zip
chromium_src-03a2e4b067ca859a567c31137bf2845a8c2d6e61.tar.gz
chromium_src-03a2e4b067ca859a567c31137bf2845a8c2d6e61.tar.bz2
Add regression test for 301510
BUG=301510 R=ananta@chromium.org Review URL: https://codereview.chromium.org/62203013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/plugin_browsertest.cc2
-rw-r--r--content/test/plugin/plugin_geturl_test.cc58
-rw-r--r--content/test/plugin/plugin_geturl_test.h3
3 files changed, 49 insertions, 14 deletions
diff --git a/content/browser/plugin_browsertest.cc b/content/browser/plugin_browsertest.cc
index 52d0e13..3c4d169 100644
--- a/content/browser/plugin_browsertest.cc
+++ b/content/browser/plugin_browsertest.cc
@@ -241,7 +241,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetJavaScriptURL2)) {
}
// Test is flaky on linux/cros/win builders. http://crbug.com/71904
-IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_GetURLRedirectNotification) {
+IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRedirectNotification) {
LoadAndWait(GetURL("geturl_redirect_notify.html"));
}
diff --git a/content/test/plugin/plugin_geturl_test.cc b/content/test/plugin/plugin_geturl_test.cc
index 1696871..8bc62e0 100644
--- a/content/test/plugin/plugin_geturl_test.cc
+++ b/content/test/plugin/plugin_geturl_test.cc
@@ -29,8 +29,11 @@
#define REDIRECT_SRC_URL \
"http://mock.http/npapi/plugin_read_page_redirect_src.html"
-// The notification id for the redirect notification url.
-#define REDIRECT_SRC_URL_NOTIFICATION_ID 4
+// The notification id for the redirect notification url that we will cancel.
+#define REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID 4
+
+// The notification id for the redirect notification url that we will accept.
+#define REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID 5
// The identifier for the bogus url stream.
#define BOGUS_URL_STREAM_ID 3
@@ -48,7 +51,8 @@ PluginGetURLTest::PluginGetURLTest(NPP id, NPNetscapeFuncs *host_functions)
expect_404_response_(false),
npn_evaluate_context_(false),
handle_url_redirects_(false),
- received_url_redirect_notification_(false),
+ received_url_redirect_cancel_notification_(false),
+ received_url_redirect_allow_notification_(false),
check_cookies_(false) {
}
@@ -114,7 +118,7 @@ NPError PluginGetURLTest::SetWindow(NPWindow* pNPWindow) {
} else if (handle_url_redirects_) {
HostFunctions()->geturlnotify(
id(), REDIRECT_SRC_URL, NULL,
- reinterpret_cast<void*>(REDIRECT_SRC_URL_NOTIFICATION_ID));
+ reinterpret_cast<void*>(REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID));
return NPERR_NO_ERROR;
} else if (check_cookies_) {
HostFunctions()->geturlnotify(
@@ -217,9 +221,11 @@ NPError PluginGetURLTest::NewStream(NPMIMEType type, NPStream* stream,
case BOGUS_URL_STREAM_ID:
SetError("Unexpected NewStream for BOGUS_URL");
break;
- case REDIRECT_SRC_URL_NOTIFICATION_ID:
+ case REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID:
SetError("Should not redirect to URL when plugin denied it.");
break;
+ case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID:
+ break;
default:
SetError("Unexpected NewStream callback");
break;
@@ -294,6 +300,8 @@ int32 PluginGetURLTest::Write(NPStream *stream, int32 offset, int32 len,
case BOGUS_URL_STREAM_ID:
SetError("Unexpected write callback for BOGUS_URL");
break;
+ case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID:
+ break;
default:
SetError("Unexpected write callback");
break;
@@ -340,6 +348,8 @@ NPError PluginGetURLTest::DestroyStream(NPStream *stream, NPError reason) {
case SELF_URL_STREAM_ID:
// don't care
break;
+ case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID:
+ break;
case FETCHED_URL_STREAM_ID:
{
char read_buffer[STREAM_CHUNK];
@@ -414,9 +424,21 @@ void PluginGetURLTest::URLNotify(const char* url, NPReason reason, void* data) {
}
tests_in_progress_--;
break;
- case REDIRECT_SRC_URL_NOTIFICATION_ID: {
- if (!received_url_redirect_notification_) {
- SetError("Failed to receive URLRedirect notification");
+ case REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID: {
+ if (!received_url_redirect_cancel_notification_) {
+ SetError("Failed to receive URLRedirect notification for cancel");
+ }
+ if (reason != NPRES_NETWORK_ERR) {
+ SetError("Redirected URL didn't get canceled");
+ }
+ break;
+ }
+ case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: {
+ if (!received_url_redirect_allow_notification_) {
+ SetError("Failed to receive URLRedirect notification for allow");
+ }
+ if (reason != NPRES_DONE) {
+ SetError("Redirected URL didn't complete successfully");
}
tests_in_progress_--;
break;
@@ -433,10 +455,22 @@ void PluginGetURLTest::URLNotify(const char* url, NPReason reason, void* data) {
void PluginGetURLTest::URLRedirectNotify(const char* url,
int32_t status,
void* notify_data) {
- if (!base::strcasecmp(url, "http://mock.http/npapi/plugin_read_page.html")) {
- received_url_redirect_notification_ = true;
- // Disallow redirect notification.
- HostFunctions()->urlredirectresponse(id(), notify_data, false);
+ unsigned long stream_id = reinterpret_cast<unsigned long>(notify_data);
+ if (stream_id == REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID) {
+ if (!base::strcasecmp(url,
+ "http://mock.http/npapi/plugin_read_page.html")) {
+ received_url_redirect_cancel_notification_ = true;
+ // Disallow redirect notification.
+ HostFunctions()->urlredirectresponse(id(), notify_data, false);
+
+ // Now start a request that we will allow to redirect.
+ HostFunctions()->geturlnotify(
+ id(), REDIRECT_SRC_URL, NULL,
+ reinterpret_cast<void*>(REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID));
+ }
+ } else if (stream_id == REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID) {
+ received_url_redirect_allow_notification_ = true;
+ HostFunctions()->urlredirectresponse(id(), notify_data, true);
}
}
diff --git a/content/test/plugin/plugin_geturl_test.h b/content/test/plugin/plugin_geturl_test.h
index 3035d03..6d85540 100644
--- a/content/test/plugin/plugin_geturl_test.h
+++ b/content/test/plugin/plugin_geturl_test.h
@@ -53,7 +53,8 @@ class PluginGetURLTest : public PluginTest {
// The following two flags handle URL redirect notifications received by
// plugins.
bool handle_url_redirects_;
- bool received_url_redirect_notification_;
+ bool received_url_redirect_cancel_notification_;
+ bool received_url_redirect_allow_notification_;
std::string page_not_found_url_;
std::string fail_write_url_;
std::string referrer_target_url_;