summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authormihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-09 16:44:13 +0000
committermihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-09 16:44:13 +0000
commitdae5717306e82ff5ac20c11f7b31ac8cc8af9d6d (patch)
tree29709e815671d0ec4b8057fb482aa094d376a5ce /chrome/test
parentbe9a1b108ec864c9800e41841efe6a40d1fab3d0 (diff)
downloadchromium_src-dae5717306e82ff5ac20c11f7b31ac8cc8af9d6d.zip
chromium_src-dae5717306e82ff5ac20c11f7b31ac8cc8af9d6d.tar.gz
chromium_src-dae5717306e82ff5ac20c11f7b31ac8cc8af9d6d.tar.bz2
Don't recreate background windows when allow_js_access if false
Ignore calls to window.open(..., "background") with allow_js_access: false when there's already a BackgroundContents instance. BUG=122408 R=creis@chromium.org Review URL: http://codereview.chromium.org/10012053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html1
-rw-r--r--chrome/test/data/extensions/api_test/app_background_page/no_js/test.js35
2 files changed, 33 insertions, 3 deletions
diff --git a/chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html b/chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html
index 21e718f..cda0a6c 100644
--- a/chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html
+++ b/chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html
@@ -10,6 +10,7 @@
<script>
window.onload = function() {
+ console.log('background page loaded');
setupScriptTunnel();
notifyBackgroundPageLoaded();
}
diff --git a/chrome/test/data/extensions/api_test/app_background_page/no_js/test.js b/chrome/test/data/extensions/api_test/app_background_page/no_js/test.js
index fd42f07..ffb91be 100644
--- a/chrome/test/data/extensions/api_test/app_background_page/no_js/test.js
+++ b/chrome/test/data/extensions/api_test/app_background_page/no_js/test.js
@@ -7,9 +7,14 @@
// AppBackgroundPageApiTest.NoJsBackgroundPage code).
// - The return value of the window.open call is null (since the background
// page is not scriptable)
+// - Attempts to call window.open(...., "background") again will not result in
+// existing background page being closed and a new one being re-opened.
var pagePrefix =
'http://a.com:PORT/files/extensions/api_test/app_background_page/no_js';
+var launchUrl;
+var launchTabId;
+var backgroundPageLoaded = false;
// Dispatch "tunneled" functions from the live web pages to this testing page.
chrome.extension.onRequest.addListener(function(request) {
@@ -33,9 +38,13 @@ window.onload = function() {
// config is requested before onload, then sometimes onload has already
// fired by the time chrome.test.getConfig()'s callback runs.
chrome.test.getConfig(function(config) {
- var launchUrl =
+ launchUrl =
pagePrefix.replace(/PORT/, config.testServer.port) + '/launch.html';
- chrome.tabs.create({ 'url': launchUrl });
+ chrome.tabs.create(
+ {url: launchUrl},
+ function(tab) {
+ launchTabId = tab.id;
+ });
});
}
@@ -44,5 +53,25 @@ function onBackgroundWindowNotNull() {
}
function onBackgroundPageLoaded() {
- chrome.test.notifyPass();
+ if (backgroundPageLoaded) {
+ chrome.test.notifyFail('Background page loaded more than once.');
+ return;
+ }
+
+ backgroundPageLoaded = true;
+
+ // Close the existing page and re-open it, which will try to call
+ // window.open(..., "background") again.
+ chrome.tabs.remove(
+ launchTabId,
+ function() {
+ chrome.tabs.create(
+ {url: launchUrl },
+ function(tab) {
+ // We wait for a bit before declaring the test as passed, since
+ // it might take a while for the additional background contents
+ // to be recreated.
+ setTimeout(chrome.test.notifyPass, 2000);
+ });
+ });
}