| 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 1112ed393c207bd74941034a63baff0fe5440d1c..12b385602dc06cfc4f6e1f907011ece09b715de8 100644
|
| --- a/third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html
|
| +++ b/third_party/WebKit/LayoutTests/netinfo/gc-frame-listeners.html
|
| @@ -11,42 +11,35 @@ description('Tests that listeners in closed frames are collected.');
|
| shouldBe('typeof window.internals.observeGC', '"function"',
|
| 'this test requires window.internals');
|
|
|
| -var childFrame = document.createElement('iframe');
|
| -// 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;
|
| -// 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.");
|
| -};
|
| -// 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);
|
| -childConnection = null;
|
| -callback = null;
|
| +var childFrame;
|
| +var childFrameObserver, childConnectionObserver, callbackObserver;
|
| +
|
| +// Do initialization work in an inner function to avoid references to
|
| +// objects remaining live on this function's stack frame.
|
| +// (http://crbug.com/595672/).
|
| +(function() {
|
| + var callback = function(e) {
|
| + testFailed("Should not get here.");
|
| + };
|
| +
|
| + childFrame = document.createElement('iframe');
|
| + childFrameObserver = internals.observeGC(childFrame);
|
| + document.body.appendChild(childFrame);
|
| + var childConnection = childFrame.contentWindow.navigator.connection;
|
| + childConnectionObserver = internals.observeGC(childConnection);
|
| + callbackObserver = internals.observeGC(callback);
|
| + childConnection.addEventListener('typechange', callback);
|
| +})();
|
| +
|
| gc();
|
| childFrame.contentWindow.gc();
|
| shouldBeFalse('childFrameObserver.wasCollected');
|
| shouldBeFalse('childConnectionObserver.wasCollected');
|
| shouldBeFalse('callbackObserver.wasCollected');
|
|
|
| -document.body.removeChild(childFrame);
|
| +// Access objects in an inner function to avoid references to objects
|
| +// remaining live on this function's stack frame (http://crbug.com/595672/).
|
| +(() => {document.body.removeChild(childFrame);})();
|
| childFrame = null;
|
| gc();
|
| shouldBeTrue('childFrameObserver.wasCollected');
|
|
|