@@ -455,4 +455,56 @@ describe('Object', function () {
455455 assert . strictEqual ( module . Object_GetRealNamedPropertyAttributes ( o , "accessor" ) , 6 /* DontEnum | DontDelete */ ) ;
456456 } ) ;
457457 } ) ;
458+ describe ( 'SetIntegrityLevel' , function ( ) {
459+ it ( 'should freeze the object' , function ( ) {
460+ var o = {
461+ bar : 42
462+ } ;
463+ assert . strictEqual ( module . Object_SetIntegrityLevel ( o , true ) , true ) ;
464+ assert . throws ( function ( ) {
465+ "use strict" ;
466+ o . bar = 211 ;
467+ } , TypeError ) ;
468+ assert . throws ( function ( ) {
469+ "use strict" ;
470+ o . foo = 42 ;
471+ } , TypeError ) ;
472+ } ) ;
473+ it ( 'should seal the object' , function ( ) {
474+ var o = {
475+ bar : 42
476+ } ;
477+ assert . strictEqual ( module . Object_SetIntegrityLevel ( o , false ) , true ) ;
478+ o . bar = 211 ; // value of an existing property can be modified
479+ assert . strictEqual ( o . bar , 211 ) ;
480+ assert . throws ( function ( ) {
481+ "use strict" ;
482+ o . foo = 42 ;
483+ } , TypeError ) ;
484+ } ) ;
485+ var proxy = new Proxy ( { } , {
486+ preventExtensions : function ( ) {
487+ return false ;
488+ }
489+ } ) ;
490+ it ( 'should throw for a Proxy refusing to prevent extensions (freeze)' , function ( ) {
491+ assert . throws ( function ( ) {
492+ module . Object_SetIntegrityLevel ( proxy , true ) ;
493+ } , TypeError ) ;
494+ } ) ;
495+ it ( 'should throw for a Proxy refusing to prevent extensions (seal)' , function ( ) {
496+ assert . throws ( function ( ) {
497+ module . Object_SetIntegrityLevel ( proxy , false ) ;
498+ } , TypeError ) ;
499+ } ) ;
500+ if ( typeof java === 'object' ) {
501+ var point = new java . awt . Point ( ) ;
502+ it ( 'should not crash for foreign objects (freeze)' , function ( ) {
503+ assert . strictEqual ( module . Object_SetIntegrityLevel ( point , true ) , true ) ;
504+ } ) ;
505+ it ( 'should not crash for foreign objects (seal)' , function ( ) {
506+ assert . strictEqual ( module . Object_SetIntegrityLevel ( point , false ) , true ) ;
507+ } ) ;
508+ }
509+ } ) ;
458510} ) ;
0 commit comments