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

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

Issue 971343003: Extension test: Do not clobber function name property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
11 var forEach = Array.prototype.forEach; 11 var forEach = Array.prototype.forEach;
12 var push = Array.prototype.push; 12 var push = Array.prototype.push;
13 var hasOwnProperty = Object.prototype.hasOwnProperty; 13 var hasOwnProperty = Object.prototype.hasOwnProperty;
14 var getOwnPropertyNames = Object.getOwnPropertyNames; 14 var getOwnPropertyNames = Object.getOwnPropertyNames;
15 var stringify = JSON.stringify; 15 var stringify = JSON.stringify;
16 16
17 // Kill all of the builtins functions to give us a fairly high confidence that 17 // Kill all of the builtins functions to give us a fairly high confidence that
18 // the environment our bindings run in can't interfere with our code. 18 // the environment our bindings run in can't interfere with our code.
19 // These are taken from the ECMAScript spec. 19 // These are taken from the ECMAScript spec.
20 var builtinTypes = [ 20 var builtinTypes = [
21 Object, Function, Array, String, Boolean, Number, Math, Date, RegExp, JSON, 21 Object, Function, Array, String, Boolean, Number, Math, Date, RegExp, JSON,
22 ]; 22 ];
23 23
24 function clobber(obj, name, qualifiedName) { 24 function clobber(obj, name, qualifiedName) {
25 // Clobbering constructors would break everything. 25 // Clobbering constructors would break everything.
26 // Clobbering toString is annoying. 26 // Clobbering toString is annoying.
27 // Clobbering __proto__ breaks in ways that grep can't find. 27 // Clobbering __proto__ breaks in ways that grep can't find.
28 // Function name property is configurable.
not at google - send to devlin 2015/03/03 17:27:19 Instead, comment: // Clobbering Function.name wil
28 // Clobbering Function.call would make it impossible to implement these tests. 29 // Clobbering Function.call would make it impossible to implement these tests.
29 // Clobbering Object.valueOf breaks v8. 30 // Clobbering Object.valueOf breaks v8.
30 if (name == 'constructor' || 31 if (name == 'constructor' ||
31 name == 'toString' || 32 name == 'toString' ||
32 name == '__proto__' || 33 name == '__proto__' ||
34 name == 'name' ||
not at google - send to devlin 2015/03/03 17:27:19 Prefer: qualifiedName == 'Function.name'
arv (Not doing code reviews) 2015/03/03 17:36:34 That would not work. There are a bunch of other fu
33 qualifiedName == 'Function.call' || 35 qualifiedName == 'Function.call' ||
34 qualifiedName == 'Object.valueOf') { 36 qualifiedName == 'Object.valueOf') {
35 return; 37 return;
36 } 38 }
37 if (typeof(obj[name]) == 'function') { 39 if (typeof(obj[name]) == 'function') {
38 obj[name] = function() { 40 obj[name] = function() {
39 throw new Error('Clobbered ' + qualifiedName + ' function'); 41 throw new Error('Clobbered ' + qualifiedName + ' function');
40 }; 42 };
41 } else { 43 } else {
42 defineGetter.call(obj, name, function() { 44 defineGetter.call(obj, name, function() {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (!message) 293 if (!message)
292 message = kMessage; 294 message = kMessage;
293 295
294 chrome.runtime.sendMessage(extensionId, message, 296 chrome.runtime.sendMessage(extensionId, message,
295 {'includeTlsChannelId': includeTlsChannelId}, 297 {'includeTlsChannelId': includeTlsChannelId},
296 checkTlsChannelIdResponse); 298 checkTlsChannelIdResponse);
297 } 299 }
298 }; 300 };
299 301
300 }()); 302 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698