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

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

Issue 173556: Implement script API:executeScript (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <script>
2
3 var pass = chrome.test.callbackPass;
4 var fail = chrome.test.callbackFail;
5 var assertEq = chrome.test.assertEq;
6 var assertTrue = chrome.test.assertTrue;
7 var relativePath =
8 '/files/extensions/api_test/executescript/test_executescript.html';
9 var testUrl = 'http://a.com:1337' + relativePath;
10 var testFailureUrl = 'http://b.com:1337' + relativePath;
11 var testingFailure = false;
12
13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
14 if (changeInfo.status == 'complete')
15 return;
16 if (testingFailure) {
17 return;
18 }
19
20 chrome.test.runTests([
21
22 function executeJavaScriptCodeShouldSucceed() {
23 var script_file = {};
24 script_file.code = "document.title = 'executeScript';";
25 chrome.tabs.executeScript(tabId, script_file, pass(function() {
26 chrome.tabs.get(tabId, function(tab) {
27 assertEq(tab.title, 'executeScript');
28 });
29 }));
30 },
31
32 function executeJavaScriptFileShouldSucceed() {
33 var script_file = {};
34 script_file.file = 'script1.js';
35 chrome.tabs.executeScript(tabId, script_file, pass(function() {
36 chrome.tabs.get(tabId, function(tab) {
37 assertEq(tab.title, 'executeScript1');
38 });
39 }));
40 },
41
42 function insertCSSTextShouldSucceed() {
43 var css_file = {};
44 css_file.code = "p {display:none;}";
45 chrome.tabs.insertCSS(tabId, css_file, function() {
46 var script_file = {};
47 script_file.file = 'script3.js';
48 chrome.tabs.executeScript(tabId, script_file, pass(function() {
49 chrome.tabs.get(tabId, function(tab) {
50 assertEq(tab.title, 'none');
51 });
52 }));
53 });
54 },
55
56 function insertCSSFileShouldSucceed() {
57 var css_file = {};
58 css_file.file = '1.css';
59 chrome.tabs.insertCSS(tabId, css_file, function() {
60 var script_file = {};
61 script_file.file = 'script2.js';
62 chrome.tabs.executeScript(tabId, script_file, pass(function() {
63 chrome.tabs.get(tabId, function(tab) {
64 assertEq(tab.title, 'block');
65 });
66 }));
67 });
68 },
69
70 function executeJavaScriptCodeShouldFail() {
71 testingFailure = true;
72 chrome.tabs.update(tabId, { url: testFailureUrl },
73 pass(function() {
74 var script_file = {};
75 script_file.code = "document.title = 'executeScript';";
76 chrome.tabs.executeScript(tabId, script_file, fail(
77 'Cannot access contents of url "' + testFailureUrl +
78 '". Extension manifest must request permission to access this ' +
79 'host.'));}));
80 }
81 ]);
82 });
83
84 chrome.tabs.create({ url: testUrl });
85
86 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698