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

Side by Side Diff: chrome/test/data/extensions/api_test/messaging/externally_connectable/sites/assertions.js

Issue 1129033008: Don't crash on chrome.runtime.connect(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tests Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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() { 5 (function() {
6 6
7 // We are going to kill all of the builtins, so hold onto the ones we need. 7 // We are going to kill all of the builtins, so hold onto the ones we need.
8 var defineGetter = Object.prototype.__defineGetter__; 8 var defineGetter = Object.prototype.__defineGetter__;
9 var defineSetter = Object.prototype.__defineSetter__; 9 var defineSetter = Object.prototype.__defineSetter__;
10 var Error = window.Error; 10 var Error = window.Error;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 canConnectAndSendMessages(sendToBrowser); 256 canConnectAndSendMessages(sendToBrowser);
257 }); 257 });
258 }, 258 },
259 259
260 trySendMessage: function(extensionId) { 260 trySendMessage: function(extensionId) {
261 chrome.runtime.sendMessage(extensionId, kMessage, function(response) { 261 chrome.runtime.sendMessage(extensionId, kMessage, function(response) {
262 // The result is unimportant. All that matters is the attempt. 262 // The result is unimportant. All that matters is the attempt.
263 }); 263 });
264 }, 264 },
265 265
266 tryIllegalArguments: function() {
267 // Tests that illegal arguments to messaging functions throw exceptions.
268 // Regression test for crbug.com/472700, where they crashed the renderer.
269 function runIllegalFunction(fun) {
270 try {
271 fun();
272 } catch(e) {
273 return true;
274 }
275 console.error('Function did not throw exception: ' + fun);
276 sendToBrowser(false);
277 return false;
278 }
279 var result =
280 runIllegalFunction(chrome.runtime.connect) &&
281 runIllegalFunction(function() {
282 chrome.runtime.connect('');
283 }) &&
284 runIllegalFunction(function() {
285 chrome.runtime.connect(42);
286 }) &&
287 runIllegalFunction(function() {
288 chrome.runtime.connect('', 42);
289 }) &&
290 runIllegalFunction(function() {
291 chrome.runtime.connect({name: 'noname'});
292 }) &&
293 runIllegalFunction(chrome.runtime.sendMessage) &&
294 runIllegalFunction(function() {
295 chrome.runtime.sendMessage('');
296 }) &&
297 runIllegalFunction(function() {
298 chrome.runtime.sendMessage(42);
299 }) &&
300 runIllegalFunction(function() {
301 chrome.runtime.sendMessage('', 42);
302 }) &&
303 sendToBrowser(true);
304 },
305
266 areAnyRuntimePropertiesDefined: function(names) { 306 areAnyRuntimePropertiesDefined: function(names) {
267 var result = false; 307 var result = false;
268 if (chrome.runtime) { 308 if (chrome.runtime) {
269 forEach.call(names, function(name) { 309 forEach.call(names, function(name) {
270 if (chrome.runtime[name]) { 310 if (chrome.runtime[name]) {
271 console.log('runtime.' + name + ' is defined'); 311 console.log('runtime.' + name + ' is defined');
272 result = true; 312 result = true;
273 } 313 }
274 }); 314 });
275 } 315 }
(...skipping 22 matching lines...) Expand all
298 if (!message) 338 if (!message)
299 message = kMessage; 339 message = kMessage;
300 340
301 chrome.runtime.sendMessage(extensionId, message, 341 chrome.runtime.sendMessage(extensionId, message,
302 {'includeTlsChannelId': includeTlsChannelId}, 342 {'includeTlsChannelId': includeTlsChannelId},
303 checkTlsChannelIdResponse); 343 checkTlsChannelIdResponse);
304 } 344 }
305 }; 345 };
306 346
307 }()); 347 }());
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | extensions/renderer/resources/runtime_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698