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

Side by Side Diff: chrome/test/data/extensions/api_test/executescript/test.html

Issue 401007: Make executeScript and insertCSS inject code into all frames. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 <script> 1 <script>
2 2
3 var pass = chrome.test.callbackPass; 3 var pass = chrome.test.callbackPass;
4 var fail = chrome.test.callbackFail; 4 var fail = chrome.test.callbackFail;
5 var assertEq = chrome.test.assertEq; 5 var assertEq = chrome.test.assertEq;
6 var assertTrue = chrome.test.assertTrue; 6 var assertTrue = chrome.test.assertTrue;
7 var relativePath = 7 var relativePath =
8 '/files/extensions/api_test/executescript/test_executescript.html'; 8 '/files/extensions/api_test/executescript/test_executescript.html';
9 var testUrl = 'http://a.com:1337' + relativePath; 9 var testUrl = 'http://a.com:1337' + relativePath;
10 var testFailureUrl = 'http://b.com:1337' + relativePath; 10 var testFailureUrl = 'http://b.com:1337' + relativePath;
11 var testingFailure = false; 11 var firstEnter = true;
12 12
13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { 13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
14 if (changeInfo.status == 'complete') 14 if (changeInfo.status != 'complete')
15 return; 15 return;
16 if (testingFailure) { 16 if (!firstEnter) {
17 return; 17 return;
18 } 18 }
19 firstEnter = false;
19 20
20 chrome.test.runTests([ 21 chrome.test.runTests([
21 22
22 function executeJavaScriptCodeShouldSucceed() { 23 function executeJavaScriptCodeShouldSucceed() {
23 var script_file = {}; 24 var script_file = {};
24 script_file.code = "document.title = 'executeScript';"; 25 script_file.code = "document.title = 'executeScript';";
25 chrome.tabs.executeScript(tabId, script_file, function() { 26 chrome.tabs.executeScript(tabId, script_file, function() {
26 chrome.tabs.get(tabId, pass(function(tab) { 27 chrome.tabs.get(tabId, pass(function(tab) {
27 assertEq(tab.title, 'executeScript'); 28 assertEq(tab.title, 'executeScript');
28 })); 29 }));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 script_file.file = 'script2.js'; 62 script_file.file = 'script2.js';
62 chrome.tabs.executeScript(tabId, script_file, function() { 63 chrome.tabs.executeScript(tabId, script_file, function() {
63 chrome.tabs.get(tabId, pass(function(tab) { 64 chrome.tabs.get(tabId, pass(function(tab) {
64 assertEq(tab.title, 'block'); 65 assertEq(tab.title, 'block');
65 })); 66 }));
66 }); 67 });
67 }); 68 });
68 }, 69 },
69 70
70 function executeJavaScriptCodeShouldFail() { 71 function executeJavaScriptCodeShouldFail() {
71 testingFailure = true;
72 chrome.tabs.update(tabId, { url: testFailureUrl }, function() { 72 chrome.tabs.update(tabId, { url: testFailureUrl }, function() {
73 var script_file = {}; 73 var script_file = {};
74 script_file.code = "document.title = 'executeScript';"; 74 script_file.code = "document.title = 'executeScript';";
75 chrome.tabs.executeScript(tabId, script_file, fail( 75 chrome.tabs.executeScript(tabId, script_file, fail(
76 'Cannot access contents of url "' + testFailureUrl + 76 'Cannot access contents of url "' + testFailureUrl +
77 '". Extension manifest must request permission to access this ' + 77 '". Extension manifest must request permission to access this ' +
78 'host.')); 78 'host.'));
79 }); 79 });
80 },
81
82 function executeJavaScriptWithNoneValueShouldFail() {
83 var script_file = {};
84 chrome.tabs.executeScript(tabId, script_file, fail(
85 'No source code or file specified.'));
86 },
87
88 function executeJavaScriptWithTwoValuesShouldFail() {
89 var script_file = {};
90 script_file.file = 'script1.js';
91 script_file.code = 'var test = 1;';
92 chrome.tabs.executeScript(tabId, script_file, fail(
93 'Code and file should not be specified ' +
94 'at the same time in the second argument'));
80 } 95 }
81 ]); 96 ]);
82 }); 97 });
83 98
84 chrome.tabs.create({ url: testUrl }); 99 chrome.tabs.create({ url: testUrl });
85 100
86 </script> 101 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698