OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Test that we can set function prototypes to non-object values. The | 28 // Test that we can set function prototypes to non-object values. The |
29 // prototype used for instances in that case should be the initial | 29 // prototype used for instances in that case should be the initial |
30 // object prototype. ECMA-262 13.2.2. | 30 // object prototype. ECMA-262 13.2.2. |
31 function TestNonObjectPrototype(value) { | 31 function TestNonObjectPrototype(value) { |
32 function F() {}; | 32 function F() {}; |
33 F.prototype = value; | 33 F.prototype = value; |
34 var f = new F(); | 34 var f = new F(); |
35 assertEquals(value, F.prototype); | 35 assertEquals(value, F.prototype); |
36 assertEquals(Object.prototype, f.__proto__); | 36 assertEquals(Object.prototype, f.__proto__); |
| 37 // Test that map transitions don't break anything. |
| 38 F.property = "value"; |
| 39 assertEquals(value, F.prototype); |
37 } | 40 } |
38 | 41 |
39 var values = [123, "asdf", true]; | 42 var values = [123, "asdf", true]; |
40 | 43 |
41 values.forEach(TestNonObjectPrototype); | 44 values.forEach(TestNonObjectPrototype); |
42 | 45 |
43 | 46 |
44 // Test moving between non-object and object values. | 47 // Test moving between non-object and object values. |
45 function F() {}; | 48 function F() {}; |
46 var f = new F(); | 49 var f = new F(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 var desc = Object.getOwnPropertyDescriptor(f, "prototype"); | 111 var desc = Object.getOwnPropertyDescriptor(f, "prototype"); |
109 assertFalse(desc.configurable); | 112 assertFalse(desc.configurable); |
110 assertFalse(desc.enumerable); | 113 assertFalse(desc.enumerable); |
111 assertTrue(desc.writable); | 114 assertTrue(desc.writable); |
112 | 115 |
113 f = function () { return 1; } | 116 f = function () { return 1; } |
114 var desc = Object.getOwnPropertyDescriptor(f, "prototype"); | 117 var desc = Object.getOwnPropertyDescriptor(f, "prototype"); |
115 assertFalse(desc.configurable); | 118 assertFalse(desc.configurable); |
116 assertFalse(desc.enumerable); | 119 assertFalse(desc.enumerable); |
117 assertTrue(desc.writable); | 120 assertTrue(desc.writable); |
OLD | NEW |