1
0
Fork 0

Added test to ensure users can't be tricky and try to break static property encapsulation

closure/master
Mike Gerwitz 2011-05-13 21:27:53 -04:00
parent 775438c1b6
commit d59bac0978
1 changed files with 29 additions and 0 deletions

View File

@ -733,3 +733,32 @@ var common = require( './common' ),
);
} )();
/**
* This tests very closely to the implementation, which is not good. However,
* it's important to protecting the data. The accessor method works off of
* context, so it's important to ensure that the data will remain encapsulated
* if the user attempts to be tricky and bind to a supertype.
*/
( function testCannotExploitAccessorMethodToGainAccessToParentPrivateProps()
{
var Foo = builder.build(
{
'private static foo': 'bar',
} ),
SubFoo = builder.build( Foo,
{
'public static getParentPrivate': function()
{
return this.$.call( Foo, 'foo' );
}
} )
;
assert.equal( SubFoo.getParentPrivate(), undefined,
"Cannot exploit accses modifier to gain access to parent private props"
);
} )();