Skip to content

Commit aba8de6

Browse files
committed
test(runtime): check the leak probe's rebuilt-canary fixture was rebuilt
The spec passed whether the probe saw the original canary or a rebuilt one, so a regression that kept the original alive went unnoticed. It now counts canaryRebuilds around the read that rebuilds the canary and requires one in canary mode. A WeakRef cannot show the original died there: canary mode's WeakRef.deref() builds a new canary while Java holds the object.
1 parent c645dc5 commit aba8de6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎test-app/app/src/main/assets/app/tests/testWrapperLifetimeLeaks.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe("Wrapper lifetime leak probe", function () {
88
// Alive for the whole suite: what leaks is the entry's value.
99
var probeMap = new WeakMap();
1010
var report;
11+
var canaryRebuilds;
1112

1213
function cyclesThrough(edge) {
1314
return report.cycles.filter(function (cycle) {
@@ -35,10 +36,12 @@ describe("Wrapper lifetime leak probe", function () {
3536
java.lang.Runtime.getRuntime().gc();
3637
gc();
3738
java.lang.System.nanoTime();
39+
var rebuildsBefore = runtime.getWrapperLifetimeStats().canaryRebuilds;
3840
(function () {
3941
// A read: the rebuilt canary's copy stays current.
4042
Holder.held.get(0).probeRebuiltList.size();
4143
})();
44+
canaryRebuilds = runtime.getWrapperLifetimeStats().canaryRebuilds - rebuildsBefore;
4245
Holder.held = null;
4346
(function () {
4447
// A JS property referencing its own object.
@@ -188,6 +191,7 @@ describe("Wrapper lifetime leak probe", function () {
188191
expect(cycles.length).toBe(0);
189192
return;
190193
}
194+
expect(canaryRebuilds).toBeGreaterThan(0);
191195
expect(cycles.length).toBe(1);
192196
});
193197

0 commit comments

Comments
 (0)