Bug 964545 Add-on SDK page-mods are now debuggable r=dcamp

This commit is contained in:
Erik Vold
2014-01-27 23:21:31 -08:00
parent f8eb9b9a15
commit f97a9b2461
16 changed files with 549 additions and 16 deletions

View File

@@ -18,6 +18,7 @@ const { URL } = require('../url');
const { sandbox, evaluate, load } = require('../loader/sandbox');
const { merge } = require('../util/object');
const { getTabForContentWindow } = require('../tabs/utils');
const { getInnerId } = require('../window/utils');
// WeakMap of sandboxes so we can access private values
const sandboxes = new WeakMap();
@@ -28,12 +29,13 @@ const sandboxes = new WeakMap();
*/
let prefix = module.uri.split('sandbox.js')[0];
const CONTENT_WORKER_URL = prefix + 'content-worker.js';
const metadata = require('@loader/options').metadata;
// Fetch additional list of domains to authorize access to for each content
// script. It is stored in manifest `metadata` field which contains
// package.json data. This list is originaly defined by authors in
// `permissions` attribute of their package.json addon file.
const permissions = require('@loader/options').metadata['permissions'] || {};
const permissions = (metadata && metadata['permissions']) || {};
const EXPANDED_PRINCIPALS = permissions['cross-domain-content'] || [];
const JS_VERSION = '1.8';
@@ -128,7 +130,10 @@ const WorkerSandbox = Class({
wantXrays: true,
wantGlobalProperties: wantGlobalProperties,
sameZoneAs: window,
metadata: { SDKContentScript: true }
metadata: {
SDKContentScript: true,
'inner-window-id': getInnerId(window)
}
});
model.sandbox = content;