Index: third_party/WebKit/LayoutTests/netinfo/gc-unused-listeners.html |
diff --git a/third_party/WebKit/LayoutTests/netinfo/gc-unused-listeners.html b/third_party/WebKit/LayoutTests/netinfo/gc-unused-listeners.html |
index 85ce3d14faa8803a2a9ea6ecc43a222a4c2514be..da73c390937e66afc74a345e28ae58c4fa336f76 100644 |
--- a/third_party/WebKit/LayoutTests/netinfo/gc-unused-listeners.html |
+++ b/third_party/WebKit/LayoutTests/netinfo/gc-unused-listeners.html |
@@ -16,7 +16,11 @@ var callback = function(e) { |
}; |
// Add a listener. |
-var callbackObserver = internals.observeGC(callback); |
+// Do not pass the object directly to observeGC function. This may |
+// remain live on this function's stack preventing GC from collecting |
+// it. Accessing the object inside an inner function will prevent any |
+// unneeded references on this function's stack. |
+var callbackObserver = internals.observeGC((() => {return callback;})()); |
connection.addEventListener('typechange', callback); |
gc(); |
shouldBeFalse('callbackObserver.wasCollected'); |