summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-21 07:31:11 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-21 07:31:11 +0000
commitc70f9b84b30986220dc58993a9a41d6fdebefac2 (patch)
treebfd1dd487c509f9bfb65b065293d300c934b9282 /chrome/test
parent2f312ab5f419b77456eba5e0362af3adaf94f6ad (diff)
downloadchromium_src-c70f9b84b30986220dc58993a9a41d6fdebefac2.zip
chromium_src-c70f9b84b30986220dc58993a9a41d6fdebefac2.tar.gz
chromium_src-c70f9b84b30986220dc58993a9a41d6fdebefac2.tar.bz2
Close a newly opened (by cmd-clicking on a link) tab if it resulted in a download.
To test this, the CL adds an automation message AutomationMsg_NavigateAsyncWithDisposition, and a method NavigateToURLAsyncWithDisposition to TabProxy. The only functional change is in TabContents::OnStartDownload, the rest of the changes is for testing. BUG=10764 TEST=DownloadTest.CloseNewTab Manual test: go to http://build.chromium.org/buildbot/continuous/mac/LATEST/, open the link "chrome-mac.zip" in a new tab. The tab should close as soon as the download starts. Review URL: http://codereview.chromium.org/1151007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h8
-rw-r--r--chrome/test/automation/tab_proxy.cc20
-rw-r--r--chrome/test/automation/tab_proxy.h6
-rw-r--r--chrome/test/data/download_page1.html11
-rw-r--r--chrome/test/data/download_page2.html8
-rw-r--r--chrome/test/data/download_page3.html9
-rw-r--r--chrome/test/data/download_page4.html5
7 files changed, 66 insertions, 1 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 02ee3e4..9512969 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1381,4 +1381,12 @@ IPC_BEGIN_MESSAGES(Automation)
// Resets to the default theme.
IPC_SYNC_MESSAGE_ROUTED0_0(AutomationMsg_ResetToDefaultTheme)
+ // Navigates asynchronously to a URL with a certain disposition,
+ // like in a new tab.
+ IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_NavigationAsyncWithDisposition,
+ int /* tab handle */,
+ GURL,
+ WindowOpenDisposition,
+ bool /* result */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 495cf7a..a662f60 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -222,7 +222,25 @@ bool TabProxy::NavigateToURLAsync(const GURL& url) {
return false;
bool status = false;
- sender_->Send(new AutomationMsg_NavigationAsync(0, handle_, url, &status));
+ sender_->Send(new AutomationMsg_NavigationAsync(0,
+ handle_,
+ url,
+ &status));
+ return status;
+}
+
+bool TabProxy::NavigateToURLAsyncWithDisposition(
+ const GURL& url,
+ WindowOpenDisposition disposition) {
+ if (!is_valid())
+ return false;
+
+ bool status = false;
+ sender_->Send(new AutomationMsg_NavigationAsyncWithDisposition(0,
+ handle_,
+ url,
+ disposition,
+ &status));
return status;
}
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index ad28090..7fabc50 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -150,6 +150,12 @@ class TabProxy : public AutomationResourceProxy,
// TabProxy we attach won't know about it. See bug 666730.
bool NavigateToURLAsync(const GURL& url) WARN_UNUSED_RESULT;
+ // Asynchronously navigates to a url using a non-default disposition.
+ // This can be used for example to open a URL in a new tab.
+ bool NavigateToURLAsyncWithDisposition(
+ const GURL& url,
+ WindowOpenDisposition disposition) WARN_UNUSED_RESULT;
+
// Replaces a vector contents with the redirect chain out of the given URL.
// Returns true on success. Failure may be due to being unable to send the
// message, parse the response, or a failure of the history system in the
diff --git a/chrome/test/data/download_page1.html b/chrome/test/data/download_page1.html
new file mode 100644
index 0000000..25854f8
--- /dev/null
+++ b/chrome/test/data/download_page1.html
@@ -0,0 +1,11 @@
+<script>
+function openNew() {
+ var w = window.open();
+ var download = "http://"+window.location.host+"/download-test1.lib";
+ w.document.write('<bo' + 'dy onload="location.replace(\''+download+'\')">Important information about the download...</bo' + 'dy>');
+ w.document.close();
+}
+</script>
+<body>
+ <button onclick="openNew()">click me</button>
+</body> \ No newline at end of file
diff --git a/chrome/test/data/download_page2.html b/chrome/test/data/download_page2.html
new file mode 100644
index 0000000..9c6d0dd
--- /dev/null
+++ b/chrome/test/data/download_page2.html
@@ -0,0 +1,8 @@
+<script>
+function openNew() {
+ var w = window.open();
+}
+</script>
+<body>
+ <button onclick="openNew()">click me</button>
+</body> \ No newline at end of file
diff --git a/chrome/test/data/download_page3.html b/chrome/test/data/download_page3.html
new file mode 100644
index 0000000..2037253
--- /dev/null
+++ b/chrome/test/data/download_page3.html
@@ -0,0 +1,9 @@
+<script>
+function openNew() {
+ var download = "http://"+window.location.host+"/download-test1.lib";
+ var w = window.open(download);
+}
+</script>
+<body>
+ <button onclick="openNew()">click me</button>
+</body> \ No newline at end of file
diff --git a/chrome/test/data/download_page4.html b/chrome/test/data/download_page4.html
new file mode 100644
index 0000000..a8ea0c6
--- /dev/null
+++ b/chrome/test/data/download_page4.html
@@ -0,0 +1,5 @@
+<body>
+ <form id="form" action="download-test1.lib" target="_blank">
+ <input type="submit" />
+ </form>
+</body> \ No newline at end of file