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

Side by Side Diff: tools/detect-builtins.js

Issue 554683002: Add a script that can generate simple test cases for user-exposed JS builtins (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: use variables instead of literals Created 6 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
« no previous file with comments | « no previous file | tools/generate-builtins-tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function(global) {
6
7 var GetProperties = function(this_name, object) {
8 var result = {};
9 try {
10 var names = Object.getOwnPropertyNames(object);
11 } catch(e) {
12 return;
13 }
14 for (var i = 0; i < names.length; ++i) {
15 var name = names[i];
16 if (typeof object === "function") {
17 if (name === "length" ||
18 name === "name" ||
19 name === "arguments" ||
20 name === "caller" ||
21 name === "prototype") {
22 continue;
23 }
24 }
25 // Avoid endless recursion.
26 if (this_name === "prototype" && name === "constructor") continue;
27 // Could get this from the parent, but having it locally is easier.
28 var property = { "name": name };
29 try {
30 var value = object[name];
31 } catch(e) {
32 property.type = "getter";
33 result[name] = property;
34 continue;
35 }
36 var type = typeof value;
37 property.type = type;
38 if (type === "function") {
39 property.length = value.length;
40 property.prototype = GetProperties("prototype", value.prototype);
41 }
42 property.properties = GetProperties(name, value);
43 result[name] = property;
44 }
45 return result;
46 };
47
48 var g = GetProperties("", global, "");
49 print(JSON.stringify(g, undefined, 2));
50
51 })(this); // Must wrap in anonymous closure or it'll detect itself as builtin.
OLDNEW
« no previous file with comments | « no previous file | tools/generate-builtins-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698