Bug 1146603: Use messaging to set up the parent and child workers for tab.attach. r=jsantell
This commit is contained in:
@@ -12,6 +12,7 @@ let { data } = require('../self');
|
||||
let assetsURI = data.url();
|
||||
let isArray = Array.isArray;
|
||||
let method = require('../../method/core');
|
||||
let { uuid } = require('../util/uuid');
|
||||
|
||||
const isAddonContent = ({ contentURL }) =>
|
||||
contentURL && data.url(contentURL).startsWith(assetsURI);
|
||||
@@ -84,3 +85,21 @@ function WorkerHost (workerFor) {
|
||||
}
|
||||
}
|
||||
exports.WorkerHost = WorkerHost;
|
||||
|
||||
function makeChildOptions(options) {
|
||||
function makeStringArray(arrayOrValue) {
|
||||
if (!arrayOrValue)
|
||||
return [];
|
||||
return [String(v) for (v of [].concat(arrayOrValue))];
|
||||
}
|
||||
|
||||
return {
|
||||
id: String(uuid()),
|
||||
contentScript: makeStringArray(options.contentScript),
|
||||
contentScriptFile: makeStringArray(options.contentScriptFile),
|
||||
contentScriptOptions: options.contentScriptOptions ?
|
||||
JSON.stringify(options.contentScriptOptions) :
|
||||
null,
|
||||
}
|
||||
}
|
||||
exports.makeChildOptions = makeChildOptions;
|
||||
|
||||
Reference in New Issue
Block a user