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

Side by Side Diff: src/v8natives.js

Issue 7701023: Added access check to Runtime_GetPrototype. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Allow JSProxy in GetPrototype, but only without access checks. Created 9 years, 3 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 | « src/runtime.cc ('k') | test/cctest/test-api.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 function CallTrap1(handler, name, defaultTrap, x) { 614 function CallTrap1(handler, name, defaultTrap, x) {
615 return %_CallFunction(handler, x, GetTrap(handler, name, defaultTrap)); 615 return %_CallFunction(handler, x, GetTrap(handler, name, defaultTrap));
616 } 616 }
617 617
618 618
619 function CallTrap2(handler, name, defaultTrap, x, y) { 619 function CallTrap2(handler, name, defaultTrap, x, y) {
620 return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap)); 620 return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap));
621 } 621 }
622 622
623 623
624 // ES5 section 8.12.2.
625 function GetProperty(obj, p) {
626 if (%IsJSProxy(obj)) {
627 var handler = %GetHandler(obj);
628 var descriptor = CallTrap1(obj, "getPropertyDescriptor", void 0, p);
629 if (IS_UNDEFINED(descriptor)) return descriptor;
630 var desc = ToCompletePropertyDescriptor(descriptor);
631 if (!desc.isConfigurable()) {
632 throw MakeTypeError("proxy_prop_not_configurable",
633 [handler, "getPropertyDescriptor", p, descriptor]);
634 }
635 return desc;
636 }
637 var prop = GetOwnProperty(obj);
638 if (!IS_UNDEFINED(prop)) return prop;
639 var proto = %GetPrototype(obj);
640 if (IS_NULL(proto)) return void 0;
641 return GetProperty(proto, p);
642 }
643
644
645 // ES5 section 8.12.6
646 function HasProperty(obj, p) {
647 if (%IsJSProxy(obj)) {
648 var handler = %GetHandler(obj);
649 return ToBoolean(CallTrap1(handler, "has", DerivedHasTrap, p));
650 }
651 var desc = GetProperty(obj, p);
652 return IS_UNDEFINED(desc) ? false : true;
653 }
654
655
656 // ES5 section 8.12.1. 624 // ES5 section 8.12.1.
657 function GetOwnProperty(obj, v) { 625 function GetOwnProperty(obj, v) {
658 var p = ToString(v); 626 var p = ToString(v);
659 if (%IsJSProxy(obj)) { 627 if (%IsJSProxy(obj)) {
660 var handler = %GetHandler(obj); 628 var handler = %GetHandler(obj);
661 var descriptor = CallTrap1(handler, "getOwnPropertyDescriptor", void 0, p); 629 var descriptor = CallTrap1(handler, "getOwnPropertyDescriptor", void 0, p);
662 if (IS_UNDEFINED(descriptor)) return descriptor; 630 if (IS_UNDEFINED(descriptor)) return descriptor;
663 var desc = ToCompletePropertyDescriptor(descriptor); 631 var desc = ToCompletePropertyDescriptor(descriptor);
664 if (!desc.isConfigurable()) { 632 if (!desc.isConfigurable()) {
665 throw MakeTypeError("proxy_prop_not_configurable", 633 throw MakeTypeError("proxy_prop_not_configurable",
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 // ---------------------------------------------------------------------------- 1506 // ----------------------------------------------------------------------------
1539 1507
1540 function SetupFunction() { 1508 function SetupFunction() {
1541 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1509 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1542 "bind", FunctionBind, 1510 "bind", FunctionBind,
1543 "toString", FunctionToString 1511 "toString", FunctionToString
1544 )); 1512 ));
1545 } 1513 }
1546 1514
1547 SetupFunction(); 1515 SetupFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698