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

Side by Side Diff: src/v8natives.js

Issue 6695018: Follow Safari on not throwing when __defineGetter__ fails.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | test/mjsunit/regress/regress-1240.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (this == null && !IS_UNDETECTABLE(this)) { 248 if (this == null && !IS_UNDETECTABLE(this)) {
249 throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); 249 throw new $TypeError('Object.prototype.__defineGetter__: this is Null');
250 } 250 }
251 if (!IS_FUNCTION(fun)) { 251 if (!IS_FUNCTION(fun)) {
252 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function' ); 252 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function' );
253 } 253 }
254 var desc = new PropertyDescriptor(); 254 var desc = new PropertyDescriptor();
255 desc.setGet(fun); 255 desc.setGet(fun);
256 desc.setEnumerable(true); 256 desc.setEnumerable(true);
257 desc.setConfigurable(true); 257 desc.setConfigurable(true);
258 DefineOwnProperty(ToObject(this), ToString(name), desc, true); 258 DefineOwnProperty(ToObject(this), ToString(name), desc, false);
259 } 259 }
260 260
261 261
262 function ObjectLookupGetter(name) { 262 function ObjectLookupGetter(name) {
263 if (this == null && !IS_UNDETECTABLE(this)) { 263 if (this == null && !IS_UNDETECTABLE(this)) {
264 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); 264 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null');
265 } 265 }
266 return %LookupAccessor(ToObject(this), ToString(name), GETTER); 266 return %LookupAccessor(ToObject(this), ToString(name), GETTER);
267 } 267 }
268 268
269 269
270 function ObjectDefineSetter(name, fun) { 270 function ObjectDefineSetter(name, fun) {
271 if (this == null && !IS_UNDETECTABLE(this)) { 271 if (this == null && !IS_UNDETECTABLE(this)) {
272 throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); 272 throw new $TypeError('Object.prototype.__defineSetter__: this is Null');
273 } 273 }
274 if (!IS_FUNCTION(fun)) { 274 if (!IS_FUNCTION(fun)) {
275 throw new $TypeError( 275 throw new $TypeError(
276 'Object.prototype.__defineSetter__: Expecting function'); 276 'Object.prototype.__defineSetter__: Expecting function');
277 } 277 }
278 var desc = new PropertyDescriptor(); 278 var desc = new PropertyDescriptor();
279 desc.setSet(fun); 279 desc.setSet(fun);
280 desc.setEnumerable(true); 280 desc.setEnumerable(true);
281 desc.setConfigurable(true); 281 desc.setConfigurable(true);
282 DefineOwnProperty(ToObject(this), ToString(name), desc, true); 282 DefineOwnProperty(ToObject(this), ToString(name), desc, false);
283 } 283 }
284 284
285 285
286 function ObjectLookupSetter(name) { 286 function ObjectLookupSetter(name) {
287 if (this == null && !IS_UNDETECTABLE(this)) { 287 if (this == null && !IS_UNDETECTABLE(this)) {
288 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); 288 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null');
289 } 289 }
290 return %LookupAccessor(ToObject(this), ToString(name), SETTER); 290 return %LookupAccessor(ToObject(this), ToString(name), SETTER);
291 } 291 }
292 292
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 function DefineOwnProperty(obj, p, desc, should_throw) { 566 function DefineOwnProperty(obj, p, desc, should_throw) {
567 var current_or_access = %GetOwnProperty(ToObject(obj), ToString(p)); 567 var current_or_access = %GetOwnProperty(ToObject(obj), ToString(p));
568 // A false value here means that access checks failed. 568 // A false value here means that access checks failed.
569 if (current_or_access === false) return void 0; 569 if (current_or_access === false) return void 0;
570 570
571 var current = ConvertDescriptorArrayToDescriptor(current_or_access); 571 var current = ConvertDescriptorArrayToDescriptor(current_or_access);
572 var extensible = %IsExtensible(ToObject(obj)); 572 var extensible = %IsExtensible(ToObject(obj));
573 573
574 // Error handling according to spec. 574 // Error handling according to spec.
575 // Step 3 575 // Step 3
576 if (IS_UNDEFINED(current) && !extensible) 576 if (IS_UNDEFINED(current) && !extensible) {
577 throw MakeTypeError("define_disallowed", ["defineProperty"]); 577 if (should_throw) {
578 throw MakeTypeError("define_disallowed", ["defineProperty"]);
579 } else {
580 return;
581 }
582 }
578 583
579 if (!IS_UNDEFINED(current)) { 584 if (!IS_UNDEFINED(current)) {
580 // Step 5 and 6 585 // Step 5 and 6
581 if ((IsGenericDescriptor(desc) || 586 if ((IsGenericDescriptor(desc) ||
582 IsDataDescriptor(desc) == IsDataDescriptor(current)) && 587 IsDataDescriptor(desc) == IsDataDescriptor(current)) &&
583 (!desc.hasEnumerable() || 588 (!desc.hasEnumerable() ||
584 SameValue(desc.isEnumerable(), current.isEnumerable())) && 589 SameValue(desc.isEnumerable(), current.isEnumerable())) &&
585 (!desc.hasConfigurable() || 590 (!desc.hasConfigurable() ||
586 SameValue(desc.isConfigurable(), current.isConfigurable())) && 591 SameValue(desc.isConfigurable(), current.isConfigurable())) &&
587 (!desc.hasWritable() || 592 (!desc.hasWritable() ||
588 SameValue(desc.isWritable(), current.isWritable())) && 593 SameValue(desc.isWritable(), current.isWritable())) &&
589 (!desc.hasValue() || 594 (!desc.hasValue() ||
590 SameValue(desc.getValue(), current.getValue())) && 595 SameValue(desc.getValue(), current.getValue())) &&
591 (!desc.hasGetter() || 596 (!desc.hasGetter() ||
592 SameValue(desc.getGet(), current.getGet())) && 597 SameValue(desc.getGet(), current.getGet())) &&
593 (!desc.hasSetter() || 598 (!desc.hasSetter() ||
594 SameValue(desc.getSet(), current.getSet()))) { 599 SameValue(desc.getSet(), current.getSet()))) {
595 return true; 600 return true;
596 } 601 }
597 if (!current.isConfigurable()) { 602 if (!current.isConfigurable()) {
598 // Step 7 603 // Step 7
599 if (desc.isConfigurable() || 604 if (desc.isConfigurable() ||
600 (desc.hasEnumerable() && 605 (desc.hasEnumerable() &&
601 desc.isEnumerable() != current.isEnumerable())) { 606 desc.isEnumerable() != current.isEnumerable())) {
602 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 607 if (should_throw) {
608 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
609 } else {
610 return;
611 }
603 } 612 }
604 // Step 8 613 // Step 8
605 if (!IsGenericDescriptor(desc)) { 614 if (!IsGenericDescriptor(desc)) {
606 // Step 9a 615 // Step 9a
607 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { 616 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) {
608 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 617 if (should_throw) {
618 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
619 } else {
620 return;
621 }
609 } 622 }
610 // Step 10a 623 // Step 10a
611 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 624 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
612 if (!current.isWritable() && desc.isWritable()) { 625 if (!current.isWritable() && desc.isWritable()) {
613 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 626 if (should_throw) {
627 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
628 } else {
629 return;
630 }
614 } 631 }
615 if (!current.isWritable() && desc.hasValue() && 632 if (!current.isWritable() && desc.hasValue() &&
616 !SameValue(desc.getValue(), current.getValue())) { 633 !SameValue(desc.getValue(), current.getValue())) {
617 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 634 if (should_throw) {
635 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
636 } else {
637 return;
638 }
618 } 639 }
619 } 640 }
620 // Step 11 641 // Step 11
621 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { 642 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
622 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) { 643 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) {
623 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 644 if (should_throw) {
645 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
646 } else {
647 return;
648 }
624 } 649 }
625 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) { 650 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) {
626 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 651 if (should_throw) {
652 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
653 } else {
654 return;
655 }
627 } 656 }
628 } 657 }
629 } 658 }
630 } 659 }
631 } 660 }
632 661
633 // Send flags - enumerable and configurable are common - writable is 662 // Send flags - enumerable and configurable are common - writable is
634 // only send to the data descriptor. 663 // only send to the data descriptor.
635 // Take special care if enumerable and configurable is not defined on 664 // Take special care if enumerable and configurable is not defined on
636 // desc (we need to preserve the existing values from current). 665 // desc (we need to preserve the existing values from current).
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 // ---------------------------------------------------------------------------- 1284 // ----------------------------------------------------------------------------
1256 1285
1257 function SetupFunction() { 1286 function SetupFunction() {
1258 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1287 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1259 "bind", FunctionBind, 1288 "bind", FunctionBind,
1260 "toString", FunctionToString 1289 "toString", FunctionToString
1261 )); 1290 ));
1262 } 1291 }
1263 1292
1264 SetupFunction(); 1293 SetupFunction();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1240.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698