Index: third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html |
diff --git a/third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html b/third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html |
index 10ec4fb82fc8bd698b73ada8174b9d071dd83fdf..1112ed393c207bd74941034a63baff0fe5440d1c 100644 |
--- a/third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html |
+++ b/third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html |
@@ -12,17 +12,29 @@ shouldBe('typeof window.internals.observeGC', '"function"', |
'this test requires window.internals'); |
var childFrame = document.createElement('iframe'); |
-var childFrameObserver = internals.observeGC(childFrame); |
+// 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 childFrameObserver = internals.observeGC((() => {return childFrame;})()); |
document.body.appendChild(childFrame); |
var childConnection = childFrame.contentWindow.navigator.connection; |
-var childConnectionObserver = internals.observeGC(childConnection); |
+// 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 childConnectionObserver = internals.observeGC((() => {return childConnection;})()); |
var callback = function(e) { |
testFailed("Should not get here."); |
}; |
-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;})()); |
// Add the event listener and make sure it doesn't get collected. |
childConnection.addEventListener('typechange', callback); |