@@ -59,6 +59,7 @@ Copyright (c) 2017, Tetsuya Mori <
[email protected] >. All rights reserved.
59
59
}
60
60
var _globalMethods = new Map ( ) ;
61
61
const excludedGlobalProperties = { isSecureContext : true } ;
62
+ const mainGlobalObjectName = typeof window === 'object' ? 'window' : 'self' ;
62
63
Object . entries ( Object . getOwnPropertyDescriptors ( _global ) )
63
64
. filter ( ( [ name , desc ] ) => desc . get && desc . set && desc . configurable &&
64
65
( name . startsWith ( 'on' ) ||
@@ -71,12 +72,12 @@ Copyright (c) 2017, Tetsuya Mori <
[email protected] >. All rights reserved.
71
72
var _globalObjects = Object . keys ( _globalPropertyDescriptors )
72
73
. sort ( )
73
74
. reduce ( ( acc , curr ) => {
74
- const globalObjectNames = [ '_global' , 'frames' , 'top' , 'global' , 'self' , 'window' ] ;
75
+ const globalObjectNames = [ '_global' , 'frames' , 'top' , 'global' , 'self' , 'window' , 'parent' ] ;
75
76
//const globalProperties = { history: true, navigator: true, applicationCache: true, crypto: true, localStorage: true, indexedDB: true, caches: true, sessionStorage: true, document: true };
76
77
if ( _globalPropertyDescriptors [ curr ] . value && typeof _globalPropertyDescriptors [ curr ] . value !== 'number' ) {
77
78
let existing = acc . get ( _globalPropertyDescriptors [ curr ] . value ) ;
78
79
if ( globalObjectNames . indexOf ( curr ) >= 0 ) {
79
- if ( globalObjectNames . indexOf ( existing ) < globalObjectNames . indexOf ( curr ) ) {
80
+ if ( curr === mainGlobalObjectName ) {
80
81
acc . set ( _globalPropertyDescriptors [ curr ] . value , curr ) ;
81
82
let properties = Object . getOwnPropertyDescriptors ( _globalPropertyDescriptors [ curr ] . value ) ;
82
83
let prop ;
@@ -109,7 +110,7 @@ Copyright (c) 2017, Tetsuya Mori <
[email protected] >. All rights reserved.
109
110
else if ( _globalPropertyDescriptors [ curr ] . get && typeof _globalPropertyDescriptors [ curr ] . get === 'function' && _global [ curr ] /*&& !_globalPropertyDescriptors[curr].set*/ ) {
110
111
let existing = acc . get ( _global [ curr ] ) ;
111
112
if ( globalObjectNames . indexOf ( curr ) >= 0 ) {
112
- if ( globalObjectNames . indexOf ( existing ) < globalObjectNames . indexOf ( curr ) ) {
113
+ if ( curr === mainGlobalObjectName ) {
113
114
if ( _global [ curr ] ) {
114
115
acc . set ( _global [ curr ] , curr ) ;
115
116
let properties = Object . getOwnPropertyDescriptors ( _global [ curr ] ) ;
@@ -950,8 +951,13 @@ Copyright (c) 2017, Tetsuya Mori <
[email protected] >. All rights reserved.
950
951
__unexpected_access_to_hook_alias_object__ : '---' ,
951
952
hook : '---' ,
952
953
$hook$ : '---' ,
953
- // blacklist properties
954
- window : {
954
+ top : 'r--' ,
955
+ parent : 'r--' ,
956
+ frames : 'r--' ,
957
+ global : 'r--' ,
958
+ self : 'r--' ,
959
+ _global : 'r--' ,
960
+ [ mainGlobalObjectName ] : { // overwrite self: in worker threads
955
961
[ S_OBJECT ] : 'r--' ,
956
962
[ S_DEFAULT ] : Policy . avoidGlobalClone ( ) ,
957
963
[ S_ALL ] : '---' ,
@@ -3507,7 +3513,7 @@ Copyright (c) 2017, Tetsuya Mori <
[email protected] >. All rights reserved.
3507
3513
'hookBenchmark' ,
3508
3514
] . forEach ( n => {
3509
3515
Object . assign ( acl , { [ n ] : '---' } ) ;
3510
- Object . assign ( acl . window , { [ n ] : '---' } ) ;
3516
+ Object . assign ( acl [ mainGlobalObjectName ] , { [ n ] : '---' } ) ;
3511
3517
} ) ;
3512
3518
const chainAcl = function chainAcl ( _acl , path = [ [ _acl , 'acl' ] ] ) {
3513
3519
let properties = Object . getOwnPropertySymbols ( _acl ) . concat ( Object . getOwnPropertyNames ( _acl ) ) ;
0 commit comments