summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 04:15:00 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 04:15:00 +0000
commit32b7c4995d5f5ecc034999c02c28ded2190c6888 (patch)
tree8c497d9e6360444b65959e7b4f2911bea781b917 /chrome/test
parent771f68f817de7ce98949b29a68aa8778c7553640 (diff)
downloadchromium_src-32b7c4995d5f5ecc034999c02c28ded2190c6888.zip
chromium_src-32b7c4995d5f5ecc034999c02c28ded2190c6888.tar.gz
chromium_src-32b7c4995d5f5ecc034999c02c28ded2190c6888.tar.bz2
window.open() from an extension should always goes in normal browser. When the split incognito stuff lands, I will change this to allow window.open() to go to incognito if you're in split mode.
BUG=52298 TEST=browser_tests --gtest_filter=ExtensionApiTest.WindowOpen Review URL: http://codereview.chromium.org/3249012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rwxr-xr-xchrome/test/data/extensions/api_test/window_open/spanning/background.html52
-rwxr-xr-xchrome/test/data/extensions/api_test/window_open/spanning/foo.html1
-rwxr-xr-xchrome/test/data/extensions/api_test/window_open/spanning/infobar.html5
-rw-r--r--chrome/test/data/extensions/api_test/window_open/spanning/manifest.json6
4 files changed, 64 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/window_open/spanning/background.html b/chrome/test/data/extensions/api_test/window_open/spanning/background.html
new file mode 100755
index 0000000..17c3ecc
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/spanning/background.html
@@ -0,0 +1,52 @@
+<script>
+var nextTest = null;
+openFromNormalShouldOpenInNormal();
+
+function openFromNormalShouldOpenInNormal() {
+ nextTest = openFromExtensionHostInIncognitoBrowserShouldOpenInNormalBrowser;
+ chrome.windows.getAll({populate: true}, function(windows) {
+ chrome.test.assertEq(1, windows.length);
+ chrome.test.assertFalse(windows[0].incognito);
+ chrome.test.assertEq(1, windows[0].tabs.length);
+ chrome.test.assertFalse(windows[0].tabs[0].incognito);
+
+ // The rest of the test continues in infobar.html.
+ chrome.experimental.infobars.show({tabId: windows[0].tabs[0].id,
+ path: "infobar.html"});
+ });
+}
+
+function openFromExtensionHostInIncognitoBrowserShouldOpenInNormalBrowser() {
+ nextTest = null;
+ chrome.windows.getCurrent(function(normalWin) {
+ chrome.test.assertFalse(normalWin.incognito);
+ // Create an incognito window.
+ chrome.windows.create({ incognito: true }, function(incognitoWin) {
+ // Remove the normal window. We keep running because of the incognito
+ // window.
+ chrome.windows.remove(normalWin.id, function() {
+ chrome.tabs.getAllInWindow(incognitoWin.id, function(tabs) {
+ chrome.test.assertEq(1, tabs.length);
+ // The rest of the test continues in infobar.html.
+ chrome.experimental.infobars.show({tabId: tabs[0].id,
+ path: "infobar.html"});
+ });
+ });
+ });
+ });
+}
+
+function verifyCreatedTab(tab) {
+ // The new tab should be a normal tab, and it should be in a normal
+ // window.
+ chrome.test.assertFalse(tab.incognito);
+ chrome.windows.get(tab.windowId, function(win) {
+ chrome.test.assertFalse(win.incognito);
+ if (nextTest) {
+ nextTest();
+ } else {
+ chrome.test.notifyPass();
+ }
+ });
+}
+</script>
diff --git a/chrome/test/data/extensions/api_test/window_open/spanning/foo.html b/chrome/test/data/extensions/api_test/window_open/spanning/foo.html
new file mode 100755
index 0000000..a4d20dd
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/spanning/foo.html
@@ -0,0 +1 @@
+foo! \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/window_open/spanning/infobar.html b/chrome/test/data/extensions/api_test/window_open/spanning/infobar.html
new file mode 100755
index 0000000..f5d4a60
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/spanning/infobar.html
@@ -0,0 +1,5 @@
+<script>
+chrome.test.listenOnce(chrome.tabs.onCreated,
+ chrome.extension.getBackgroundPage().verifyCreatedTab);
+window.open('foo.html');
+</script>
diff --git a/chrome/test/data/extensions/api_test/window_open/spanning/manifest.json b/chrome/test/data/extensions/api_test/window_open/spanning/manifest.json
new file mode 100644
index 0000000..991756d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_open/spanning/manifest.json
@@ -0,0 +1,6 @@
+{
+ "name": "window.open test - spanning",
+ "version": "1",
+ "permissions": ["experimental", "tabs"],
+ "background_page": "background.html"
+}