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

Side by Side Diff: chrome/test/data/extensions/api_test/active_tab/background.js

Issue 2871533002: [Test] Added a test for activeTab URL filtering (Closed)
Patch Set: Added a public session test (tests URL scrubbing) Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/active_tab_apitest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 var assertEq = chrome.test.assertEq; 5 var assertEq = chrome.test.assertEq;
6 var assertFalse = chrome.test.assertFalse; 6 var assertFalse = chrome.test.assertFalse;
7 var assertTrue = chrome.test.assertTrue; 7 var assertTrue = chrome.test.assertTrue;
8 var callbackFail = chrome.test.callbackFail; 8 var callbackFail = chrome.test.callbackFail;
9 var callbackPass = chrome.test.callbackPass; 9 var callbackPass = chrome.test.callbackPass;
10 10
(...skipping 24 matching lines...) Expand all
35 iframeDone(); 35 iframeDone();
36 } 36 }
37 }); 37 });
38 38
39 var iframeUrl = chrome.extension.getURL('iframe.html'); 39 var iframeUrl = chrome.extension.getURL('iframe.html');
40 var injectIframe = 40 var injectIframe =
41 'var iframe = document.createElement("iframe");\n' + 41 'var iframe = document.createElement("iframe");\n' +
42 'iframe.src = "' + iframeUrl + '";\n' + 42 'iframe.src = "' + iframeUrl + '";\n' +
43 'document.body.appendChild(iframe);\n'; 43 'document.body.appendChild(iframe);\n';
44 44
45 var runCount = 0;
46
45 chrome.browserAction.onClicked.addListener(function(tab) { 47 chrome.browserAction.onClicked.addListener(function(tab) {
48 runCount++;
49 if (runCount == 1) {
Devlin 2017/05/23 20:49:21 add some comments explaining the ordering here.
Ivan Šandrk 2017/05/24 16:36:51 Done.
50 assertTrue(tab.url == undefined);
Devlin 2017/05/23 20:49:21 maybe just: assertFalse(!!tab.url);
Ivan Šandrk 2017/05/24 16:36:51 Done.
51 return chrome.test.succeed();
Devlin 2017/05/23 20:49:21 chrome.test.succeed() doesn't return anything, so
Ivan Šandrk 2017/05/24 16:36:51 Done.
52 } else if (runCount == 3) {
53 chrome.test.sendMessage(tab.url);
54 return chrome.test.succeed();
55 }
56
46 iframeDone = chrome.test.callbackAdded(); 57 iframeDone = chrome.test.callbackAdded();
47 cachedUrl = tab.url; 58 cachedUrl = tab.url;
48 chrome.tabs.executeScript({ code: injectIframe }, callbackPass()); 59 chrome.tabs.executeScript({ code: injectIframe }, callbackPass());
49 assertTrue(canXhr(tab.url)); 60 assertTrue(canXhr(tab.url));
50 61
51 chrome.automation.getTree(callbackPass(function(rootNode) { 62 chrome.automation.getTree(callbackPass(function(rootNode) {
52 assertFalse(rootNode == undefined); 63 assertFalse(rootNode == undefined);
53 assertEq(RoleType.ROOT_WEB_AREA, rootNode.role); 64 assertEq(RoleType.ROOT_WEB_AREA, rootNode.role);
54 })); 65 }));
55 }); 66 });
56 67
57 chrome.webNavigation.onCompleted.addListener(function(details) { 68 chrome.webNavigation.onCompleted.addListener(function(details) {
58 chrome.tabs.executeScript({ code: 'true' }, callbackFail( 69 chrome.tabs.executeScript({ code: 'true' }, callbackFail(
59 'Cannot access contents of the page. ' + 70 'Cannot access contents of the page. ' +
60 'Extension manifest must request permission to access the ' + 71 'Extension manifest must request permission to access the ' +
61 'respective host.')); 72 'respective host.'));
62 73
63 chrome.automation.getTree(callbackFail( 74 chrome.automation.getTree(callbackFail(
64 'Cannot request automation tree on url "' + details.url + 75 'Cannot request automation tree on url "' + details.url +
65 '". Extension manifest must request permission to access this host.')); 76 '". Extension manifest must request permission to access this host.'));
66 77
67 assertFalse(canXhr(details.url)); 78 assertFalse(canXhr(details.url));
68 }); 79 });
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_tab_apitest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698