Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Unified Diff: chrome/test/data/extensions/api_test/app_background_page/no_js/test.js

Issue 10012053: Don't recreate background windows when allow_js_access if false (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/app_background_page/no_js/test.js
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 fd42f0740db00e00c66dc64e8316f48848e61a64..ffb91be6648f6a8168283f57afb885f4d60d425a 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 },
Andrew T Wilson (Slow) 2012/04/07 02:45:25 no space after 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);
+ });
+ });
}
« no previous file with comments | « chrome/test/data/extensions/api_test/app_background_page/no_js/bg.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698