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

Side by Side Diff: test/mjsunit/harmony/object-observe.js

Issue 139983003: Revert "Make Function.length and Function.name configurable properties." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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 | « test/cctest/test-accessors.cc ('k') | test/mjsunit/regress/regress-1530.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 obj[symbol]++; 969 obj[symbol]++;
970 obj[symbol] *= 3; 970 obj[symbol] *= 3;
971 delete obj[symbol]; 971 delete obj[symbol];
972 obj.__defineSetter__(symbol, function() {}); 972 obj.__defineSetter__(symbol, function() {});
973 obj.__defineGetter__(symbol, function() {}); 973 obj.__defineGetter__(symbol, function() {});
974 Object.deliverChangeRecords(observer.callback); 974 Object.deliverChangeRecords(observer.callback);
975 observer.assertNotCalled(); 975 observer.assertNotCalled();
976 976
977 977
978 // Test all kinds of objects generically. 978 // Test all kinds of objects generically.
979 function TestObserveConfigurable(obj, prop, is_writable) { 979 function TestObserveConfigurable(obj, prop) {
980 reset(); 980 reset();
981 var valueWhenDeleted = is_writable ? 3 : obj[prop];
982 Object.observe(obj, observer.callback); 981 Object.observe(obj, observer.callback);
983 Object.unobserve(obj, observer.callback); 982 Object.unobserve(obj, observer.callback);
984 obj[prop] = 1; 983 obj[prop] = 1;
985 Object.observe(obj, observer.callback); 984 Object.observe(obj, observer.callback);
986 obj[prop] = 2; 985 obj[prop] = 2;
987 obj[prop] = valueWhenDeleted; 986 obj[prop] = 3;
988 delete obj[prop]; 987 delete obj[prop];
989 // If the deleted obj[prop] exposed another 'prop' along the 988 obj[prop] = 4;
990 // prototype chain, only update it if it doesn't have an
991 // (inheritable) accessor or it is a read-only data property. If
992 // either of those is true, then instead create an own property with
993 // the descriptor that [[Put]] mandates for a new property (ES-5.1,
994 // 8.12.5.6)
995 var createOwnProperty = false;
996 for (var o = Object.getPrototypeOf(obj); o; o = Object.getPrototypeOf(o)) {
997 var desc = Object.getOwnPropertyDescriptor(o, prop);
998 if (desc) {
999 if (!desc.writable)
1000 createOwnProperty = true;
1001 break;
1002 }
1003 }
1004 if (createOwnProperty)
1005 Object.defineProperty(obj, prop, {
1006 value: 4,
1007 writable: true,
1008 enumerable: true,
1009 configurable: true
1010 });
1011 else
1012 obj[prop] = 4;
1013 obj[prop] = 4; // ignored 989 obj[prop] = 4; // ignored
1014 obj[prop] = 5; 990 obj[prop] = 5;
1015 Object.defineProperty(obj, prop, {value: 6}); 991 Object.defineProperty(obj, prop, {value: 6});
1016 Object.defineProperty(obj, prop, {writable: false}); 992 Object.defineProperty(obj, prop, {writable: false});
1017 obj[prop] = 7; // ignored 993 obj[prop] = 7; // ignored
1018 Object.defineProperty(obj, prop, {value: 8}); 994 Object.defineProperty(obj, prop, {value: 8});
1019 Object.defineProperty(obj, prop, {value: 7, writable: true}); 995 Object.defineProperty(obj, prop, {value: 7, writable: true});
1020 Object.defineProperty(obj, prop, {get: function() {}}); 996 Object.defineProperty(obj, prop, {get: function() {}});
1021 Object.defineProperty(obj, prop, {get: frozenFunction}); 997 Object.defineProperty(obj, prop, {get: frozenFunction});
1022 Object.defineProperty(obj, prop, {get: frozenFunction}); // ignored 998 Object.defineProperty(obj, prop, {get: frozenFunction}); // ignored
1023 Object.defineProperty(obj, prop, {get: frozenFunction, set: frozenFunction}); 999 Object.defineProperty(obj, prop, {get: frozenFunction, set: frozenFunction});
1024 Object.defineProperty(obj, prop, {set: frozenFunction}); // ignored 1000 Object.defineProperty(obj, prop, {set: frozenFunction}); // ignored
1025 Object.defineProperty(obj, prop, {get: undefined, set: frozenFunction}); 1001 Object.defineProperty(obj, prop, {get: undefined, set: frozenFunction});
1026 obj.__defineSetter__(prop, frozenFunction); // ignored 1002 obj.__defineSetter__(prop, frozenFunction); // ignored
1027 obj.__defineSetter__(prop, function() {}); 1003 obj.__defineSetter__(prop, function() {});
1028 obj.__defineGetter__(prop, function() {}); 1004 obj.__defineGetter__(prop, function() {});
1029 delete obj[prop]; 1005 delete obj[prop];
1030 delete obj[prop]; // ignored 1006 delete obj[prop]; // ignored
1031 obj.__defineGetter__(prop, function() {}); 1007 obj.__defineGetter__(prop, function() {});
1032 delete obj[prop]; 1008 delete obj[prop];
1033 Object.defineProperty(obj, prop, {get: function() {}, configurable: true}); 1009 Object.defineProperty(obj, prop, {get: function() {}, configurable: true});
1034 Object.defineProperty(obj, prop, {value: 9, writable: true}); 1010 Object.defineProperty(obj, prop, {value: 9, writable: true});
1035 obj[prop] = 10; 1011 obj[prop] = 10;
1036 ++obj[prop]; 1012 ++obj[prop];
1037 obj[prop]++; 1013 obj[prop]++;
1038 obj[prop] *= 3; 1014 obj[prop] *= 3;
1039 delete obj[prop]; 1015 delete obj[prop];
1040 Object.defineProperty(obj, prop, {value: 11, configurable: true}); 1016 Object.defineProperty(obj, prop, {value: 11, configurable: true});
1041 Object.deliverChangeRecords(observer.callback); 1017 Object.deliverChangeRecords(observer.callback);
1042 1018 observer.assertCallbackRecords([
1043 var expected = [ 1019 { object: obj, name: prop, type: "update", oldValue: 1 },
1044 { object: obj, name: prop, type: "delete", oldValue: valueWhenDeleted }, 1020 { object: obj, name: prop, type: "update", oldValue: 2 },
1021 { object: obj, name: prop, type: "delete", oldValue: 3 },
1045 { object: obj, name: prop, type: "add" }, 1022 { object: obj, name: prop, type: "add" },
1046 { object: obj, name: prop, type: "update", oldValue: 4 }, 1023 { object: obj, name: prop, type: "update", oldValue: 4 },
1047 { object: obj, name: prop, type: "update", oldValue: 5 }, 1024 { object: obj, name: prop, type: "update", oldValue: 5 },
1048 { object: obj, name: prop, type: "reconfigure" }, 1025 { object: obj, name: prop, type: "reconfigure" },
1049 { object: obj, name: prop, type: "update", oldValue: 6 }, 1026 { object: obj, name: prop, type: "update", oldValue: 6 },
1050 { object: obj, name: prop, type: "reconfigure", oldValue: 8 }, 1027 { object: obj, name: prop, type: "reconfigure", oldValue: 8 },
1051 { object: obj, name: prop, type: "reconfigure", oldValue: 7 }, 1028 { object: obj, name: prop, type: "reconfigure", oldValue: 7 },
1052 { object: obj, name: prop, type: "reconfigure" }, 1029 { object: obj, name: prop, type: "reconfigure" },
1053 { object: obj, name: prop, type: "reconfigure" }, 1030 { object: obj, name: prop, type: "reconfigure" },
1054 { object: obj, name: prop, type: "reconfigure" }, 1031 { object: obj, name: prop, type: "reconfigure" },
1055 { object: obj, name: prop, type: "reconfigure" }, 1032 { object: obj, name: prop, type: "reconfigure" },
1056 { object: obj, name: prop, type: "reconfigure" }, 1033 { object: obj, name: prop, type: "reconfigure" },
1057 { object: obj, name: prop, type: "delete" }, 1034 { object: obj, name: prop, type: "delete" },
1058 { object: obj, name: prop, type: "add" }, 1035 { object: obj, name: prop, type: "add" },
1059 { object: obj, name: prop, type: "delete" }, 1036 { object: obj, name: prop, type: "delete" },
1060 { object: obj, name: prop, type: "add" }, 1037 { object: obj, name: prop, type: "add" },
1061 { object: obj, name: prop, type: "reconfigure" }, 1038 { object: obj, name: prop, type: "reconfigure" },
1062 { object: obj, name: prop, type: "update", oldValue: 9 }, 1039 { object: obj, name: prop, type: "update", oldValue: 9 },
1063 { object: obj, name: prop, type: "update", oldValue: 10 }, 1040 { object: obj, name: prop, type: "update", oldValue: 10 },
1064 { object: obj, name: prop, type: "update", oldValue: 11 }, 1041 { object: obj, name: prop, type: "update", oldValue: 11 },
1065 { object: obj, name: prop, type: "update", oldValue: 12 }, 1042 { object: obj, name: prop, type: "update", oldValue: 12 },
1066 { object: obj, name: prop, type: "delete", oldValue: 36 }, 1043 { object: obj, name: prop, type: "delete", oldValue: 36 },
1067 { object: obj, name: prop, type: "add" }, 1044 { object: obj, name: prop, type: "add" },
1068 ]; 1045 ]);
1069
1070 if (is_writable) {
1071 expected.unshift(
1072 { object: obj, name: prop, type: "update", oldValue: 1 },
1073 { object: obj, name: prop, type: "update", oldValue: 2 });
1074 }
1075
1076 observer.assertCallbackRecords(expected);
1077 Object.unobserve(obj, observer.callback); 1046 Object.unobserve(obj, observer.callback);
1078 delete obj[prop]; 1047 delete obj[prop];
1079 } 1048 }
1080 1049
1081 function TestObserveNonConfigurable(obj, prop, desc) { 1050 function TestObserveNonConfigurable(obj, prop, desc) {
1082 reset(); 1051 reset();
1083 Object.observe(obj, observer.callback); 1052 Object.observe(obj, observer.callback);
1084 Object.unobserve(obj, observer.callback); 1053 Object.unobserve(obj, observer.callback);
1085 obj[prop] = 1; 1054 obj[prop] = 1;
1086 Object.observe(obj, observer.callback); 1055 Object.observe(obj, observer.callback);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 (obj instanceof ArrayBuffer && prop == 1) 1137 (obj instanceof ArrayBuffer && prop == 1)
1169 } 1138 }
1170 1139
1171 for (var i in objects) for (var j in properties) { 1140 for (var i in objects) for (var j in properties) {
1172 var obj = objects[i]; 1141 var obj = objects[i];
1173 var prop = properties[j]; 1142 var prop = properties[j];
1174 if (blacklisted(obj, prop)) continue; 1143 if (blacklisted(obj, prop)) continue;
1175 var desc = Object.getOwnPropertyDescriptor(obj, prop); 1144 var desc = Object.getOwnPropertyDescriptor(obj, prop);
1176 print("***", typeof obj, stringifyNoThrow(obj), prop); 1145 print("***", typeof obj, stringifyNoThrow(obj), prop);
1177 if (!desc || desc.configurable) 1146 if (!desc || desc.configurable)
1178 TestObserveConfigurable(obj, prop, !desc || desc.writable); 1147 TestObserveConfigurable(obj, prop);
1179 else if (desc.writable) 1148 else if (desc.writable)
1180 TestObserveNonConfigurable(obj, prop, desc); 1149 TestObserveNonConfigurable(obj, prop, desc);
1181 } 1150 }
1182 1151
1183 1152
1184 // Observing array length (including truncation) 1153 // Observing array length (including truncation)
1185 reset(); 1154 reset();
1186 var arr = ['a', 'b', 'c', 'd']; 1155 var arr = ['a', 'b', 'c', 'd'];
1187 var arr2 = ['alpha', 'beta']; 1156 var arr2 = ['alpha', 'beta'];
1188 var arr3 = ['hello']; 1157 var arr3 = ['hello'];
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 for (var n1 = 0; n1 < 3; ++n1) 1780 for (var n1 = 0; n1 < 3; ++n1)
1812 for (var n2 = 0; n2 < 3; ++n2) 1781 for (var n2 = 0; n2 < 3; ++n2)
1813 for (var i in mutation) 1782 for (var i in mutation)
1814 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); 1783 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2);
1815 1784
1816 for (var b1 = 0; b1 < 2; ++b1) 1785 for (var b1 = 0; b1 < 2; ++b1)
1817 for (var b2 = 0; b2 < 2; ++b2) 1786 for (var b2 = 0; b2 < 2; ++b2)
1818 for (var n = 0; n < 3; ++n) 1787 for (var n = 0; n < 3; ++n)
1819 for (var i in mutationByIncr) 1788 for (var i in mutationByIncr)
1820 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); 1789 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1);
OLDNEW
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/mjsunit/regress/regress-1530.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698