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

Unified Diff: chrome/test/data/extensions/api_test/tabs/no_permissions/test.js

Issue 1414223005: Remove URLs from chrome.tabs.executeScript permission warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test case Created 5 years, 1 month 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
Index: chrome/test/data/extensions/api_test/tabs/no_permissions/test.js
diff --git a/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js b/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js
index 9718173f73b693dfb3a90cbcafd0313c3167cbbe..a727fb15dc57b3588bf1895a4400156ea1307123 100644
--- a/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js
+++ b/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js
@@ -9,39 +9,63 @@ function assertNoSensitiveFields(tab) {
});
}
-chrome.test.runTests([
- function testOnUpdated() {
- var neededCallbacks = 3; // two onUpdateListener calls, one create callback
- var countDown = function() {
- neededCallbacks--;
- if (neededCallbacks == 0) {
- chrome.tabs.onUpdated.removeListener(onUpdateListener);
- chrome.test.succeed();
- }
- };
-
- var onUpdateListener = function(tabId, info, tab) {
- assertNoSensitiveFields(info);
- assertNoSensitiveFields(tab);
- countDown();
- }
-
- chrome.tabs.onUpdated.addListener(onUpdateListener);
- chrome.tabs.create({url: 'chrome://newtab/'}, function(tab) {
- assertNoSensitiveFields(tab);
- chrome.tabs.update(tab.id, {url: 'about:blank'}, function(tab) {
+var port;
+
+function testUrl(domain) {
+ return 'http://' + domain + ':' + port +
+ '/extensions/test_file.html';
+}
+
+chrome.test.getConfig(function(config) {
+ port = config.testServer.port;
+ chrome.test.runTests([
+ function testOnUpdated() {
+ // two onUpdateListener calls, one create callback
+ var neededCallbacks = 3;
+ var countDown = function() {
+ neededCallbacks--;
+ if (neededCallbacks == 0) {
+ chrome.tabs.onUpdated.removeListener(onUpdateListener);
+ chrome.test.succeed();
+ }
+ };
+
+ var onUpdateListener = function(tabId, info, tab) {
+ assertNoSensitiveFields(info);
assertNoSensitiveFields(tab);
countDown();
+ }
+
+ chrome.tabs.onUpdated.addListener(onUpdateListener);
+ chrome.tabs.create({url: 'chrome://newtab/'}, function(tab) {
+ assertNoSensitiveFields(tab);
+ chrome.tabs.update(tab.id, {url: 'about:blank'}, function(tab) {
+ assertNoSensitiveFields(tab);
+ countDown();
+ });
+ });
+ },
+
+ function testQuery() {
+ chrome.tabs.create({url: 'chrome://newtab/'});
+ chrome.tabs.query({active: true},
+ chrome.test.callbackPass(function(tabs) {
+ chrome.test.assertEq(1, tabs.length);
+ assertNoSensitiveFields(tabs[0]);
+ }));
+ },
+
+ function testErrorForCodeInjection() {
+ chrome.tabs.create({url: testUrl('a.com')}, function(tab) {
+ chrome.tabs.executeScript(tab.id, {code: ''},
+ // Error message should *not* contain a page URL here because the
+ // manifest file does not contain the tabs permission. Exposing
+ // the URL without tabs permission would be a privacy leak.
+ chrome.test.callbackFail('Cannot access contents of the page. ' +
+ 'Extension manifest must request permission to access the ' +
+ 'respective host.'));
});
- });
- },
-
- function testQuery() {
- chrome.tabs.create({url: 'chrome://newtab/'});
- chrome.tabs.query({active: true}, chrome.test.callbackPass(function(tabs) {
- chrome.test.assertEq(1, tabs.length);
- assertNoSensitiveFields(tabs[0]);
- }));
- },
-
-]);
+ },
+
+ ]);
+});
« no previous file with comments | « chrome/test/data/extensions/api_test/executescript/navigation_race/test.js ('k') | extensions/common/manifest_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698