test-test-memory.js 837 B

1234567891011121314151617181920212223
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. 'use strict';
  5. const { Cc, Ci, Cu, components } = require('chrome');
  6. const { gc } = require('sdk/test/memory');
  7. exports.testGC = function(assert, done) {
  8. let weakref;
  9. let (tempObj = {}) {
  10. weakref = Cu.getWeakReference(tempObj);
  11. assert.equal(weakref.get(), tempObj, 'the weakref returned the tempObj');
  12. }
  13. gc().then(function(arg) {
  14. assert.equal(arg, undefined, 'there is no argument');
  15. assert.pass('gc() returns a promise which eventually resolves');
  16. assert.equal(weakref.get(), undefined, 'the weakref returned undefined');
  17. }).then(done).then(null, assert.fail);
  18. };
  19. require('sdk/test').run(exports);