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

Side by Side Diff: chrome/renderer/resources/extension_apitest.js

Issue 199074: Don't allow updating tabs to javascript URLs without host (Closed)
Patch Set: Remove unchanged file 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
OLDNEW
1 // extension_apitest.js 1 // extension_apitest.js
2 // mini-framework for ExtensionApiTest browser tests 2 // mini-framework for ExtensionApiTest browser tests
3 3
4 var chrome = chrome || {}; 4 var chrome = chrome || {};
5 (function() { 5 (function() {
6 chrome.test = chrome.test || {}; 6 chrome.test = chrome.test || {};
7 7
8 chrome.test.tests = chrome.test.tests || []; 8 chrome.test.tests = chrome.test.tests || [];
9 9
10 var completed = false; 10 var completed = false;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } else { 144 } else {
145 msg += "\n(no stack available)"; 145 msg += "\n(no stack available)";
146 } 146 }
147 chrome.test.fail(msg); 147 chrome.test.fail(msg);
148 } 148 }
149 }; 149 };
150 150
151 // Wrapper for generating test functions, that takes care of calling 151 // Wrapper for generating test functions, that takes care of calling
152 // assertNoLastError() and (optionally) succeed() for you. 152 // assertNoLastError() and (optionally) succeed() for you.
153 chrome.test.callback = function(func, expectedError) { 153 chrome.test.callback = function(func, expectedError) {
154 chrome.test.assertEq(typeof(func), 'function'); 154 if (func) {
155 chrome.test.assertEq(typeof(func), 'function');
156 }
157
155 callbackAdded(); 158 callbackAdded();
159
156 return function() { 160 return function() {
157 if (expectedError == null) { 161 if (expectedError == null) {
158 chrome.test.assertNoLastError(); 162 chrome.test.assertNoLastError();
159 } else { 163 } else {
160 chrome.test.assertEq(typeof(expectedError), 'string'); 164 chrome.test.assertEq(typeof(expectedError), 'string');
161 chrome.test.assertEq(expectedError, chrome.extension.lastError.message); 165 chrome.test.assertEq(expectedError, chrome.extension.lastError.message);
162 } 166 }
163 safeFunctionApply(func, arguments); 167
168 if (func) {
169 safeFunctionApply(func, arguments);
170 }
171
164 callbackCompleted(); 172 callbackCompleted();
165 }; 173 };
166 }; 174 };
167 175
168 chrome.test.listenOnce = function(event, func) { 176 chrome.test.listenOnce = function(event, func) {
169 callbackAdded(); 177 callbackAdded();
170 var listener = function() { 178 var listener = function() {
171 event.removeListener(listener); 179 event.removeListener(listener);
172 safeFunctionApply(func, arguments); 180 safeFunctionApply(func, arguments);
173 callbackCompleted(); 181 callbackCompleted();
174 }; 182 };
175 event.addListener(listener); 183 event.addListener(listener);
176 }; 184 };
177 185
178 chrome.test.callbackPass = function(func) { 186 chrome.test.callbackPass = function(func) {
179 return chrome.test.callback(func); 187 return chrome.test.callback(func);
180 }; 188 };
181 189
182 chrome.test.callbackFail = function(func, expectedError) { 190 chrome.test.callbackFail = function(expectedError) {
183 return chrome.test.callback(func, expectedError); 191 return chrome.test.callback(null, expectedError);
184 }; 192 };
185 193
186 // TODO(erikkay) This is deprecated and should be removed. 194 // TODO(erikkay) This is deprecated and should be removed.
187 chrome.test.testCallback = function(succeedWhenDone, func) { 195 chrome.test.testCallback = function(succeedWhenDone, func) {
188 return chrome.test.callback(func); 196 return chrome.test.callback(func);
189 }; 197 };
190 198
191 chrome.test.runTests = function(tests) { 199 chrome.test.runTests = function(tests) {
192 chrome.test.tests = tests; 200 chrome.test.tests = tests;
193 chrome.test.runNextTest(); 201 chrome.test.runNextTest();
194 }; 202 };
195 203
196 })(); 204 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698