test-memory.js 642 B

12345678910111213141516171819202122
  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 memory = require("sdk/deprecated/memory");
  6. const { gc } = require("sdk/test/memory");
  7. exports.testMemory = function(assert) {
  8. var obj = {};
  9. memory.track(obj, "testMemory.testObj");
  10. var objs = memory.getObjects("testMemory.testObj");
  11. assert.equal(objs[0].weakref.get(), obj);
  12. obj = null;
  13. gc().then(function() {
  14. assert.equal(objs[0].weakref.get(), null);
  15. });
  16. };
  17. require('sdk/test').run(exports);