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

Side by Side Diff: src/v8natives.js

Issue 7146010: Give correct error message when Object.isExtensible is called on a non object (fixes issue 1452) (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 6 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 | no next file » | 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 // A false value here means that access checks failed. 622 // A false value here means that access checks failed.
623 if (current_or_access === false) return void 0; 623 if (current_or_access === false) return void 0;
624 624
625 var current = ConvertDescriptorArrayToDescriptor(current_or_access); 625 var current = ConvertDescriptorArrayToDescriptor(current_or_access);
626 var extensible = %IsExtensible(ToObject(obj)); 626 var extensible = %IsExtensible(ToObject(obj));
627 627
628 // Error handling according to spec. 628 // Error handling according to spec.
629 // Step 3 629 // Step 3
630 if (IS_UNDEFINED(current) && !extensible) { 630 if (IS_UNDEFINED(current) && !extensible) {
631 if (should_throw) { 631 if (should_throw) {
632 throw MakeTypeError("define_disallowed", ["defineProperty"]); 632 throw MakeTypeError("define_disallowed", ["defineProperty"]);
Lasse Reichstein 2011/06/14 10:30:46 While you are at it ...., The message for define_d
633 } else { 633 } else {
634 return; 634 return;
635 } 635 }
636 } 636 }
637 637
638 if (!IS_UNDEFINED(current)) { 638 if (!IS_UNDEFINED(current)) {
639 // Step 5 and 6 639 // Step 5 and 6
640 if ((IsGenericDescriptor(desc) || 640 if ((IsGenericDescriptor(desc) ||
641 IsDataDescriptor(desc) == IsDataDescriptor(current)) && 641 IsDataDescriptor(desc) == IsDataDescriptor(current)) &&
642 (!desc.hasEnumerable() || 642 (!desc.hasEnumerable() ||
643 SameValue(desc.isEnumerable(), current.isEnumerable())) && 643 SameValue(desc.isEnumerable(), current.isEnumerable())) &&
644 (!desc.hasConfigurable() || 644 (!desc.hasConfigurable() ||
645 SameValue(desc.isConfigurable(), current.isConfigurable())) && 645 SameValue(desc.isConfigurable(), current.isConfigurable())) &&
646 (!desc.hasWritable() || 646 (!desc.hasWritable() ||
647 SameValue(desc.isWritable(), current.isWritable())) && 647 SameValue(desc.isWritable(), current.isWritable())) &&
648 (!desc.hasValue() || 648 (!desc.hasValue() ||
649 SameValue(desc.getValue(), current.getValue())) && 649 SameValue(desc.getValue(), current.getValue())) &&
650 (!desc.hasGetter() || 650 (!desc.hasGetter() ||
651 SameValue(desc.getGet(), current.getGet())) && 651 SameValue(desc.getGet(), current.getGet())) &&
652 (!desc.hasSetter() || 652 (!desc.hasSetter() ||
653 SameValue(desc.getSet(), current.getSet()))) { 653 SameValue(desc.getSet(), current.getSet()))) {
654 return true; 654 return true;
655 } 655 }
656 if (!current.isConfigurable()) { 656 if (!current.isConfigurable()) {
657 // Step 7 657 // Step 7
658 if (desc.isConfigurable() || 658 if (desc.isConfigurable() ||
659 (desc.hasEnumerable() && 659 (desc.hasEnumerable() &&
660 desc.isEnumerable() != current.isEnumerable())) { 660 desc.isEnumerable() != current.isEnumerable())) {
661 if (should_throw) { 661 if (should_throw) {
662 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 662 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
Lasse Reichstein 2011/06/14 10:30:46 And this error message suggests that the parameter
663 } else { 663 } else {
664 return; 664 return;
665 } 665 }
666 } 666 }
667 // Step 8 667 // Step 8
668 if (!IsGenericDescriptor(desc)) { 668 if (!IsGenericDescriptor(desc)) {
669 // Step 9a 669 // Step 9a
670 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { 670 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) {
671 if (should_throw) { 671 if (should_throw) {
672 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 672 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 if (!ObjectIsExtensible(obj)) { 1009 if (!ObjectIsExtensible(obj)) {
1010 return true; 1010 return true;
1011 } 1011 }
1012 return false; 1012 return false;
1013 } 1013 }
1014 1014
1015 1015
1016 // ES5 section 15.2.3.13 1016 // ES5 section 15.2.3.13
1017 function ObjectIsExtensible(obj) { 1017 function ObjectIsExtensible(obj) {
1018 if (!IS_SPEC_OBJECT(obj)) { 1018 if (!IS_SPEC_OBJECT(obj)) {
1019 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); 1019 throw MakeTypeError("obj_ctor_property_non_object", ["isExtensible"]);
1020 } 1020 }
1021 return %IsExtensible(obj); 1021 return %IsExtensible(obj);
1022 } 1022 }
1023 1023
1024 1024
1025 %SetCode($Object, function(x) { 1025 %SetCode($Object, function(x) {
1026 if (%_IsConstructCall()) { 1026 if (%_IsConstructCall()) {
1027 if (x == null) return this; 1027 if (x == null) return this;
1028 return ToObject(x); 1028 return ToObject(x);
1029 } else { 1029 } else {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 // ---------------------------------------------------------------------------- 1390 // ----------------------------------------------------------------------------
1391 1391
1392 function SetupFunction() { 1392 function SetupFunction() {
1393 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1393 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1394 "bind", FunctionBind, 1394 "bind", FunctionBind,
1395 "toString", FunctionToString 1395 "toString", FunctionToString
1396 )); 1396 ));
1397 } 1397 }
1398 1398
1399 SetupFunction(); 1399 SetupFunction();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698