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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/messaging/externally_connectable/sites/assertions.js
diff --git a/chrome/test/data/extensions/api_test/messaging/externally_connectable/sites/assertions.js b/chrome/test/data/extensions/api_test/messaging/externally_connectable/sites/assertions.js
index fae9c574c99837f02dcff01c1d47044ef8d21d18..b6fb3151db8870a1a4aa43d77870c2bcfbcb597b 100644
--- a/chrome/test/data/extensions/api_test/messaging/externally_connectable/sites/assertions.js
+++ b/chrome/test/data/extensions/api_test/messaging/externally_connectable/sites/assertions.js
@@ -263,6 +263,46 @@ window.assertions = {
});
},
+ tryIllegalArguments: function() {
+ // Tests that illegal arguments to messaging functions throw exceptions.
+ // Regression test for crbug.com/472700, where they crashed the renderer.
+ function runIllegalFunction(fun) {
+ try {
+ fun();
+ } catch(e) {
+ return true;
+ }
+ console.error('Function did not throw exception: ' + fun);
+ sendToBrowser(false);
+ return false;
+ }
+ var result =
+ runIllegalFunction(chrome.runtime.connect) &&
+ runIllegalFunction(function() {
+ chrome.runtime.connect('');
+ }) &&
+ runIllegalFunction(function() {
+ chrome.runtime.connect(42);
+ }) &&
+ runIllegalFunction(function() {
+ chrome.runtime.connect('', 42);
+ }) &&
+ runIllegalFunction(function() {
+ chrome.runtime.connect({name: 'noname'});
+ }) &&
+ runIllegalFunction(chrome.runtime.sendMessage) &&
+ runIllegalFunction(function() {
+ chrome.runtime.sendMessage('');
+ }) &&
+ runIllegalFunction(function() {
+ chrome.runtime.sendMessage(42);
+ }) &&
+ runIllegalFunction(function() {
+ chrome.runtime.sendMessage('', 42);
+ }) &&
+ sendToBrowser(true);
+ },
+
areAnyRuntimePropertiesDefined: function(names) {
var result = false;
if (chrome.runtime) {
« 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