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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function assertNoSensitiveFields(tab) { 5 function assertNoSensitiveFields(tab) {
6 ['url', 'title', 'faviconUrl'].forEach(function(field) { 6 ['url', 'title', 'faviconUrl'].forEach(function(field) {
7 chrome.test.assertEq(undefined, tab[field], 7 chrome.test.assertEq(undefined, tab[field],
8 'Sensitive property ' + field + ' is visible') 8 'Sensitive property ' + field + ' is visible')
9 }); 9 });
10 } 10 }
11 11
12 chrome.test.runTests([ 12 var port;
13 function testOnUpdated() {
14 var neededCallbacks = 3; // two onUpdateListener calls, one create callback
15 var countDown = function() {
16 neededCallbacks--;
17 if (neededCallbacks == 0) {
18 chrome.tabs.onUpdated.removeListener(onUpdateListener);
19 chrome.test.succeed();
20 }
21 };
22 13
23 var onUpdateListener = function(tabId, info, tab) { 14 function testUrl(domain) {
24 assertNoSensitiveFields(info); 15 return 'http://' + domain + ':' + port +
25 assertNoSensitiveFields(tab); 16 '/extensions/test_file.html';
26 countDown(); 17 }
27 }
28 18
29 chrome.tabs.onUpdated.addListener(onUpdateListener); 19 chrome.test.getConfig(function(config) {
30 chrome.tabs.create({url: 'chrome://newtab/'}, function(tab) { 20 port = config.testServer.port;
31 assertNoSensitiveFields(tab); 21 chrome.test.runTests([
32 chrome.tabs.update(tab.id, {url: 'about:blank'}, function(tab) { 22 function testOnUpdated() {
23 // two onUpdateListener calls, one create callback
24 var neededCallbacks = 3;
25 var countDown = function() {
26 neededCallbacks--;
27 if (neededCallbacks == 0) {
28 chrome.tabs.onUpdated.removeListener(onUpdateListener);
29 chrome.test.succeed();
30 }
31 };
32
33 var onUpdateListener = function(tabId, info, tab) {
34 assertNoSensitiveFields(info);
33 assertNoSensitiveFields(tab); 35 assertNoSensitiveFields(tab);
34 countDown(); 36 countDown();
37 }
38
39 chrome.tabs.onUpdated.addListener(onUpdateListener);
40 chrome.tabs.create({url: 'chrome://newtab/'}, function(tab) {
41 assertNoSensitiveFields(tab);
42 chrome.tabs.update(tab.id, {url: 'about:blank'}, function(tab) {
43 assertNoSensitiveFields(tab);
44 countDown();
45 });
35 }); 46 });
36 }); 47 },
37 },
38 48
39 function testQuery() { 49 function testQuery() {
40 chrome.tabs.create({url: 'chrome://newtab/'}); 50 chrome.tabs.create({url: 'chrome://newtab/'});
41 chrome.tabs.query({active: true}, chrome.test.callbackPass(function(tabs) { 51 chrome.tabs.query({active: true},
42 chrome.test.assertEq(1, tabs.length); 52 chrome.test.callbackPass(function(tabs) {
43 assertNoSensitiveFields(tabs[0]); 53 chrome.test.assertEq(1, tabs.length);
44 })); 54 assertNoSensitiveFields(tabs[0]);
45 }, 55 }));
56 },
46 57
47 ]); 58 function testErrorForCodeInjection() {
59 chrome.tabs.create({url: testUrl('a.com')}, function(tab) {
60 chrome.tabs.executeScript(tab.id, {code: ''},
61 // Error message should *not* contain a page URL here because the
62 // manifest file does not contain the tabs permission. Exposing
63 // the URL without tabs permission would be a privacy leak.
64 chrome.test.callbackFail('Cannot access contents of the page. ' +
65 'Extension manifest must request permission to access the ' +
66 'respective host.'));
67 });
68 },
69
70 ]);
71 });
OLDNEW
« 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