File tree Expand file tree Collapse file tree 5 files changed +82
-0
lines changed Expand file tree Collapse file tree 5 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ CONSOLE: resources/check-layout-th.js
108
108
CONSOLE: resources/chromium/*
109
109
CONSOLE: resources/idlharness.js
110
110
CONSOLE: streams/resources/test-utils.js
111
+ CONSOLE: weakrefs/resources/test-utils.js
111
112
CONSOLE: service-workers/service-worker/resources/navigation-redirect-other-origin.html
112
113
CONSOLE: service-workers/service-worker/navigation-redirect.https.html
113
114
CONSOLE: service-workers/service-worker/resources/clients-get-other-origin.html
Original file line number Diff line number Diff line change
1
+ spec : https://tc39.es/proposal-weakrefs/
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < script src ="/resources/testharness.js "> </ script >
3
+ < script src ="/resources/testharnessreport.js "> </ script >
4
+ < script type ="module ">
5
+ import garbageCollect from './resources/test-utils.js' ;
6
+
7
+ async_test ( function ( ) {
8
+ let called = false ;
9
+
10
+ const callback = this . step_func ( function ( iter ) {
11
+ const values = [ ...iter ] ;
12
+ assert_equals ( values [ 0 ] , 'holdings' ,
13
+ 'holdings should be initialized correctly' ) ;
14
+ this . done ( ) ;
15
+ } ) ;
16
+
17
+ const fg = new FinalizationGroup ( callback ) ;
18
+
19
+ ( function ( ) {
20
+ let x = { } ;
21
+ fg . register ( x , 'holdings' ) ;
22
+ x = null ;
23
+ } ) ( ) ;
24
+
25
+ assert_false ( called , 'finalizer should not be called in the same turn' ) ;
26
+
27
+ garbageCollect ( ) ;
28
+
29
+ assert_false ( called , 'finalizer should not be called in the same turn' ) ;
30
+
31
+ } , `FinalizationGroup registers an object and calls finalizer` ) ;
32
+ </ script >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < script src ="/resources/testharness.js "> </ script >
3
+ < script src ="/resources/testharnessreport.js "> </ script >
4
+ < script type ="module ">
5
+ import garbageCollect from './resources/test-utils.js' ;
6
+
7
+ test ( function ( ) {
8
+ let called = false ;
9
+ function callback ( iter ) {
10
+ called = true ;
11
+ const values = [ ...iter ] ;
12
+ assert_equals ( values [ 0 ] , 'holdings' ,
13
+ 'holdings should be initialized correctly' ) ;
14
+ } ;
15
+
16
+ const fg = new FinalizationGroup ( callback ) ;
17
+
18
+ ( function ( ) {
19
+ let x = { } ;
20
+ fg . register ( x , 'holdings' ) ;
21
+ x = null ;
22
+ } ) ( ) ;
23
+
24
+ assert_false ( called , 'finalizer should not be called yet' ) ;
25
+
26
+ garbageCollect ( ) ;
27
+
28
+ fg . cleanupSome ( ) ;
29
+ assert_true ( called , 'finalizer should be called' ) ;
30
+
31
+ } , `FinalizationGroup.cleanupSome calls finalizer in same turn` ) ;
32
+ </ script >
Original file line number Diff line number Diff line change
1
+ export default function ( ) {
2
+ if ( self . gc ) {
3
+ // Use --expose_gc for V8 (and Node.js)
4
+ // to pass this flag at chrome launch use: --js-flags="--expose-gc"
5
+ // Exposed in SpiderMonkey shell as well
6
+ self . gc ( ) ;
7
+ } else if ( self . GCController ) {
8
+ // Present in some WebKit development environments
9
+ GCController . collect ( ) ;
10
+ } else {
11
+ /* eslint-disable no-console */
12
+ console . warn ( 'Tests are running without the ability to do manual garbage collection. They will still work, but ' +
13
+ 'coverage will be suboptimal.' ) ;
14
+ /* eslint-enable no-console */
15
+ }
16
+ } ;
You can’t perform that action at this time.
0 commit comments