Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

WIP on 866535, currently non working #990

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/sdk/deprecated/unit-test-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const cuddlefish = require("sdk/loader/cuddlefish");

const NOT_TESTS = ['setup', 'teardown'];

const {loader_global} = require("sdk/test/harness");

var TestFinder = exports.TestFinder = function TestFinder(options) {
memory.track(this);
this.filter = options.filter;
Expand Down Expand Up @@ -55,7 +57,7 @@ TestFinder.prototype = {
function(suite) {
// Load each test file as a main module in its own loader instance
// `suite` is defined by cuddlefish/manifest.py:ManifestBuilder.build
var loader = Loader(module);
var loader = Loader(module,{global:loader_global});
var module = cuddlefish.main(loader, suite);

if (self.testInProcess)
Expand Down
6 changes: 4 additions & 2 deletions lib/sdk/test/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const unit = require("../deprecated/unit-test");
const test = require("../../test");
const url = require("../url");

const loader_global = exports.loader_global = {}; // useful for storing things like coverage testing.

var cService = Cc['@mozilla.org/consoleservice;1'].getService()
.QueryInterface(Ci.nsIConsoleService);

Expand Down Expand Up @@ -328,7 +330,7 @@ function getPotentialLeaks() {
console.error("Unable to parse compartment detail " + matches[1]);
return;
}

let item = {
path: matches[1],
principal: details[1],
Expand Down Expand Up @@ -580,7 +582,7 @@ var runTests = exports.runTests = function runTests(options) {

loader = Loader(module, {
console: testConsole,
global: {} // useful for storing things like coverage testing.
global: loader_global
});

// Load these before getting initial leak stats as they will still be in
Expand Down
10 changes: 10 additions & 0 deletions lib/sdk/test/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const { ensure } = require('../system/unload');
const addonWindow = require('../addon/window');
const { PlainTextConsole } = require("sdk/console/plain-text");

let log = function(){
let s = Array.join(Array.prototype.slice(arguments)," ");
dump(s)
};

function CustomLoader(module, globals, packaging) {
let options = packaging || require("@loader/options");
options = override(options, {
Expand All @@ -19,6 +24,11 @@ function CustomLoader(module, globals, packaging) {
})
});

let id = "<unk>"
if (module) {id = module.id}

//log(id, Object.keys(options.globals));

let loader = Loader(options);
let wrapper = Object.create(loader, descriptor({
require: Require(loader, module),
Expand Down