OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 var names = Object.getOwnPropertyNames(builtins); | 35 var names = Object.getOwnPropertyNames(builtins); |
36 | 36 |
37 function isFunction(obj) { | 37 function isFunction(obj) { |
38 return typeof obj == "function"; | 38 return typeof obj == "function"; |
39 } | 39 } |
40 | 40 |
41 function isV8Native(name) { | 41 function isV8Native(name) { |
42 return name == "GeneratorFunctionPrototype" || | 42 return name == "GeneratorFunctionPrototype" || |
43 name == "SetIterator" || | 43 name == "SetIterator" || |
44 name == "MapIterator"; | 44 name == "MapIterator" || |
| 45 name == "ArrayIterator" || |
| 46 name == "StringIterator"; |
45 } | 47 } |
46 | 48 |
47 function checkConstructor(func, name) { | 49 function checkConstructor(func, name) { |
48 // A constructor is a function with a prototype and properties on the | 50 // A constructor is a function with a prototype and properties on the |
49 // prototype object besides "constructor"; | 51 // prototype object besides "constructor"; |
50 if (name.charAt(0) == "$") return; | 52 if (name.charAt(0) == "$") return; |
51 if (typeof func.prototype != "object") return; | 53 if (typeof func.prototype != "object") return; |
52 var propNames = Object.getOwnPropertyNames(func.prototype); | 54 var propNames = Object.getOwnPropertyNames(func.prototype); |
53 if (propNames.length == 0 || | 55 if (propNames.length == 0 || |
54 (propNames.length == 1 && propNames[0] == "constructor")) { | 56 (propNames.length == 1 && propNames[0] == "constructor")) { |
(...skipping 24 matching lines...) Expand all Loading... |
79 | 81 |
80 for (var i = 0; i < names.length; i++) { | 82 for (var i = 0; i < names.length; i++) { |
81 var name = names[i]; | 83 var name = names[i]; |
82 var desc = Object.getOwnPropertyDescriptor(builtins, name); | 84 var desc = Object.getOwnPropertyDescriptor(builtins, name); |
83 assertTrue(desc.hasOwnProperty("value")); | 85 assertTrue(desc.hasOwnProperty("value")); |
84 var value = desc.value; | 86 var value = desc.value; |
85 if (isFunction(value)) { | 87 if (isFunction(value)) { |
86 checkConstructor(value, name); | 88 checkConstructor(value, name); |
87 } | 89 } |
88 } | 90 } |
OLD | NEW |