OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 assertFalse(desc.configurable); | 859 assertFalse(desc.configurable); |
860 | 860 |
861 // Define non existing property - all attributes should default to false. | 861 // Define non existing property - all attributes should default to false. |
862 Object.defineProperty(arr, '15', descElement); | 862 Object.defineProperty(arr, '15', descElement); |
863 desc = Object.getOwnPropertyDescriptor(arr, '15'); | 863 desc = Object.getOwnPropertyDescriptor(arr, '15'); |
864 assertEquals(desc.value, 'foobar'); | 864 assertEquals(desc.value, 'foobar'); |
865 assertFalse(desc.writable); | 865 assertFalse(desc.writable); |
866 assertFalse(desc.enumerable); | 866 assertFalse(desc.enumerable); |
867 assertFalse(desc.configurable); | 867 assertFalse(desc.configurable); |
868 | 868 |
869 // See issue 968: http://code.google.com/p/v8/issues/detail?id=968 | |
870 var o = { x : 42 }; | |
871 Object.defineProperty(o, "x", { writable: false }); | |
872 assertEquals(42, o.x); | |
873 o.x = 37; | |
874 assertEquals(42, o.x); | |
875 | 869 |
876 o = { x : 42 }; | |
877 Object.defineProperty(o, "x", {}); | |
878 assertEquals(42, o.x); | |
879 o.x = 37; | |
880 // Writability is preserved. | |
881 assertEquals(37, o.x); | |
882 | |
883 var o = { }; | |
884 Object.defineProperty(o, "x", { writable: false }); | |
885 assertEquals(undefined, o.x); | |
886 o.x = 37; | |
887 assertEquals(undefined, o.x); | |
888 | |
889 o = { get x() { return 87; } }; | |
890 Object.defineProperty(o, "x", { writable: false }); | |
891 assertEquals(undefined, o.x); | |
892 o.x = 37; | |
893 assertEquals(undefined, o.x); | |
894 | |
895 // Ignore inherited properties. | |
896 o = { __proto__ : { x : 87 } }; | |
897 Object.defineProperty(o, "x", { writable: false }); | |
898 assertEquals(undefined, o.x); | |
899 o.x = 37; | |
900 assertEquals(undefined, o.x); | |
901 | |
OLD | NEW |