summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 00:47:15 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 00:47:15 +0000
commit50d5e839049830d699da85675a3a065173726d48 (patch)
treeebbafabf0153859fb4025ea584482613709ed4de /chrome/test
parentfdc3c22cbbf495f5819eb9cbd867915bb9d33702 (diff)
downloadchromium_src-50d5e839049830d699da85675a3a065173726d48.zip
chromium_src-50d5e839049830d699da85675a3a065173726d48.tar.gz
chromium_src-50d5e839049830d699da85675a3a065173726d48.tar.bz2
Fix bug where window.open() with no feature string from
extension background pages created a new browser instead of a tab. BUG=54768 TEST= Review URL: http://codereview.chromium.org/3352009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58902 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/background.html73
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/content_script.js1
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/foo.html1
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/manifest.json13
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/pop.js8
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/tab.html4
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/manifest.json13
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_popup.html3
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_tab.html3
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/popup.html1
-rw-r--r--chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/tab.html1
11 files changed, 121 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/background.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/background.html
new file mode 100644
index 0000000..ef48990
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/background.html
@@ -0,0 +1,73 @@
+<!--
+Copyright (c) 2010 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<script src="pop.js"></script>
+<script>
+var webPageURL =
+ "http://b.com:1337/files/extensions/api_test/window_open/popup_blocking/" +
+ "extension/foo.html";
+
+chrome.tabs.onUpdated.addListener(function(tabId, changed, tab) {
+ if (tab.status == "complete")
+ checkTest();
+});
+
+function checkTest() {
+ chrome.windows.getAll({populate: true}, function(windows) {
+ // If we don't have enough windows and tabs yet, the test isn't done.
+ if (windows.length < 4 || windows[0].tabs.length < 6)
+ return;
+
+ // The first window should have 6 tabs, all of which have a URL.
+ chrome.test.assertEq("normal", windows[0].type);
+ for (var i = 0; i < windows[0].tabs.length; i++) {
+ // If a tab doesn't have a URL yet, the test isn't done.
+ if (!windows[0].tabs[i].url)
+ return;
+ }
+
+ // The remaining 3 windows should each be popup with one tab.
+ for (var i = 1; i < 4; i++) {
+ // If the popup doesn't have a URL yet, the test isn't done.
+ if (windows[i].tabs.length < 1 || !windows[i].tabs[0].url)
+ return;
+ }
+
+ // OK, we appear to be done with the test. Now check that each of the tabs
+ // has the expected URL.
+
+ // The first window has: the new tab page, a tab from our extension, a web
+ // page we used to trigger a content script, and three popup tabs.
+ chrome.test.assertEq("normal", windows[0].type);
+ chrome.test.assertEq(chrome.extension.getURL("tab.html"),
+ windows[0].tabs[1].url);
+ chrome.test.assertEq(webPageURL, windows[0].tabs[2].url);
+ for (var i = 3; i < 6; i++) {
+ chrome.test.assertEq(popupURL, windows[0].tabs[i].url);
+ }
+
+ // The remaining windows should each have one popup tab.
+ for (var i = 1; i < 4; i++) {
+ chrome.test.assertEq("popup", windows[i].type);
+ chrome.test.assertEq(1, windows[i].tabs.length);
+ chrome.test.assertEq(popupURL, windows[i].tabs[0].url);
+ }
+
+ chrome.test.notifyPass();
+ });
+}
+
+// Open a popup and a tab from the background page.
+pop();
+
+// Open a popup and a tab from a tab (tabs don't use ExtensionHost, so it's
+// interesting to test them separately).
+chrome.tabs.create({url: "tab.html", index: 1});
+
+// Open a tab to a URL that will cause our content script to run. The content
+// script will open a popup and a tab.
+chrome.tabs.create({url: webPageURL, index: 2});
+</script>
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/content_script.js b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/content_script.js
new file mode 100644
index 0000000..5732c77
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/content_script.js
@@ -0,0 +1 @@
+pop();
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/foo.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/foo.html
new file mode 100644
index 0000000..a84ad03e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/foo.html
@@ -0,0 +1 @@
+I am foo.
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/manifest.json b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/manifest.json
new file mode 100644
index 0000000..ea931b5
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/manifest.json
@@ -0,0 +1,13 @@
+{
+ "name": "Popup blocking test",
+ "version": "1",
+ "description": "Popup windows should never be blocked from within an extension.",
+ "permissions": ["tabs"],
+ "background_page": "background.html",
+ "content_scripts": [
+ {
+ "matches": ["http://b.com/*"],
+ "js": ["pop.js", "content_script.js"]
+ }
+ ]
+}
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/pop.js b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/pop.js
new file mode 100644
index 0000000..9244005
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/pop.js
@@ -0,0 +1,8 @@
+var popupURL =
+ "http://a.com:1337/files/extensions/api_test/window_open/popup_blocking/" +
+ "extension/foo.html";
+
+function pop() {
+ window.open(popupURL);
+ window.open(popupURL, "", "width=300,height=300");
+}
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/tab.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/tab.html
new file mode 100644
index 0000000..0fcc765
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/extension/tab.html
@@ -0,0 +1,4 @@
+<script src="pop.js"></script>
+<script>
+pop();
+</script>
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/manifest.json b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/manifest.json
new file mode 100644
index 0000000..342a331
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/manifest.json
@@ -0,0 +1,13 @@
+{
+ "name": "Popup blocking test",
+ "version": "1",
+ "description": "Popup windows should never be blocked from within a hosted app.",
+ "app": {
+ "urls": [
+ "http://a.com/"
+ ],
+ "launch": {
+ "web_url": "http://a.com/app.html"
+ }
+ }
+}
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_popup.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_popup.html
new file mode 100644
index 0000000..1f9ab25
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_popup.html
@@ -0,0 +1,3 @@
+<script>
+window.open("popup.html", "", "width=300,height=300");
+</script>
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_tab.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_tab.html
new file mode 100644
index 0000000..6d82efc
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/open_tab.html
@@ -0,0 +1,3 @@
+<script>
+window.open("tab.html");
+</script>
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/popup.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/popup.html
new file mode 100644
index 0000000..6f7c48f
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/popup.html
@@ -0,0 +1 @@
+I am popup!
diff --git a/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/tab.html b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/tab.html
new file mode 100644
index 0000000..fa5d220
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/popup_blocking/hosted_app/tab.html
@@ -0,0 +1 @@
+I am tab!