@@ -31,7 +31,8 @@ interface RealmFilter {
31
31
executionContextId ?: Protocol . Runtime . ExecutionContextId ;
32
32
origin ?: string ;
33
33
type ?: Script . RealmType ;
34
- sandbox ?: string ;
34
+ // null indicates no sandbox.
35
+ sandbox ?: string | null ;
35
36
cdpSessionId ?: Protocol . Target . SessionID ;
36
37
isHidden ?: boolean ;
37
38
}
@@ -59,6 +60,8 @@ export class RealmStorage {
59
60
60
61
/** Finds all realms that match the given filter. */
61
62
findRealms ( filter : RealmFilter ) : Realm [ ] {
63
+ const sandboxFilterValue =
64
+ filter . sandbox === null ? undefined : filter . sandbox ;
62
65
return Array . from ( this . #realmMap. values ( ) ) . filter ( ( realm ) => {
63
66
if ( filter . realmId !== undefined && filter . realmId !== realm . realmId ) {
64
67
return false ;
@@ -73,7 +76,8 @@ export class RealmStorage {
73
76
}
74
77
if (
75
78
filter . sandbox !== undefined &&
76
- ( ! ( realm instanceof WindowRealm ) || filter . sandbox !== realm . sandbox )
79
+ ( ! ( realm instanceof WindowRealm ) ||
80
+ sandboxFilterValue !== realm . sandbox )
77
81
) {
78
82
return false ;
79
83
}
@@ -106,11 +110,7 @@ export class RealmStorage {
106
110
}
107
111
108
112
findRealm ( filter : RealmFilter ) : Realm | undefined {
109
- const maybeRealms = this . findRealms ( filter ) ;
110
- if ( maybeRealms . length !== 1 ) {
111
- return undefined ;
112
- }
113
- return maybeRealms [ 0 ] ;
113
+ return this . findRealms ( filter ) [ 0 ] ;
114
114
}
115
115
116
116
/** Gets the only realm that matches the given filter, if any, otherwise throws. */
0 commit comments