michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: 'use strict'; michael@0: michael@0: const { Cc, Ci, Cu, components } = require('chrome'); michael@0: const { gc } = require('sdk/test/memory'); michael@0: michael@0: exports.testGC = function(assert, done) { michael@0: let weakref; michael@0: let (tempObj = {}) { michael@0: weakref = Cu.getWeakReference(tempObj); michael@0: assert.equal(weakref.get(), tempObj, 'the weakref returned the tempObj'); michael@0: } michael@0: michael@0: gc().then(function(arg) { michael@0: assert.equal(arg, undefined, 'there is no argument'); michael@0: assert.pass('gc() returns a promise which eventually resolves'); michael@0: assert.equal(weakref.get(), undefined, 'the weakref returned undefined'); michael@0: }).then(done).then(null, assert.fail); michael@0: }; michael@0: michael@0: require('sdk/test').run(exports);