Index: chrome/test/data/extensions/api_test/active_tab/background.js |
diff --git a/chrome/test/data/extensions/api_test/active_tab/background.js b/chrome/test/data/extensions/api_test/active_tab/background.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3f2fd586246c7a56b05735a9985e8801bc64ecc1 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/active_tab/background.js |
@@ -0,0 +1,33 @@ |
+// Copyright (c) 2011 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. |
+ |
+var theOnlyTestDone = null; |
+ |
+function inject(callback) { |
+ chrome.tabs.executeScript({ code: "true" }, callback); |
+} |
+ |
+chrome.browserAction.onClicked.addListener(function() { |
+ inject(function() { |
+ chrome.test.assertNoLastError(); |
+ chrome.test.notifyPass(); |
+ }); |
+}); |
+ |
+chrome.webNavigation.onCompleted.addListener(function(details) { |
+ inject(function() { |
+ chrome.test.assertLastError("Access to extension API denied."); |
+ if (details.url.indexOf("final_page") >= 0) |
+ theOnlyTestDone(); |
+ else |
+ chrome.test.notifyPass(); |
+ }); |
+}); |
+ |
+chrome.test.runTests([ |
+ function theOnlyTest() { |
+ // This will keep the test alive until the final callback is run. |
+ theOnlyTestDone = chrome.test.callbackAdded(); |
+ } |
+]); |