зеркало из https://github.com/mozilla/gecko-dev.git
Bug 966416 - Uplift Add-on SDK to Firefox
This commit is contained in:
Родитель
1bcd3ceed8
Коммит
5daec585b5
|
@ -18,7 +18,7 @@
|
|||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>21.0</em:minVersion>
|
||||
<em:maxVersion>25.0a1</em:maxVersion>
|
||||
<em:maxVersion>29.0a1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ exports.Reactor = Reactor;
|
|||
*/
|
||||
|
||||
function stripListeners (object) {
|
||||
return Object.keys(object).reduce((agg, key) => {
|
||||
return Object.keys(object || {}).reduce((agg, key) => {
|
||||
if (!EVENT_TYPE_PATTERN.test(key))
|
||||
agg[key] = object[key];
|
||||
return agg;
|
||||
|
|
|
@ -9,7 +9,7 @@ const { id: jetpackId} = require('../self');
|
|||
|
||||
const OPTIONS_DISPLAYED = "addon-options-displayed";
|
||||
|
||||
function onOptionsDisplayed({ subjec: document, data: addonId }) {
|
||||
function onOptionsDisplayed({ subject: document, data: addonId }) {
|
||||
if (addonId !== jetpackId)
|
||||
return;
|
||||
let query = 'setting[data-jetpack-id="' + jetpackId + '"][pref-name], ' +
|
||||
|
|
|
@ -693,7 +693,9 @@ const Loader = iced(function Loader(options) {
|
|||
} = override({
|
||||
paths: {},
|
||||
modules: {},
|
||||
globals: {},
|
||||
globals: {
|
||||
console: console
|
||||
},
|
||||
resolve: options.isNative ?
|
||||
exports.nodeResolve :
|
||||
exports.resolve,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
somePreference_title=A
|
|
@ -0,0 +1,57 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
'use strict';
|
||||
|
||||
const { Cu } = require('chrome');
|
||||
const sp = require('sdk/simple-prefs');
|
||||
const app = require('sdk/system/xul-app');
|
||||
const self = require('sdk/self');
|
||||
const tabs = require('sdk/tabs');
|
||||
const { preferencesBranch } = require('sdk/self');
|
||||
|
||||
const { AddonManager } = Cu.import('resource://gre/modules/AddonManager.jsm', {});
|
||||
|
||||
exports.testAOMLocalization = function(assert, done) {
|
||||
tabs.open({
|
||||
url: 'about:addons',
|
||||
onReady: function(tab) {
|
||||
tab.attach({
|
||||
contentScriptWhen: 'end',
|
||||
contentScript: 'function onLoad() {\n' +
|
||||
'unsafeWindow.removeEventListener("load", onLoad, false);\n' +
|
||||
'AddonManager.getAddonByID("' + self.id + '", function(aAddon) {\n' +
|
||||
'unsafeWindow.gViewController.viewObjects.detail.node.addEventListener("ViewChanged", function whenViewChanges() {\n' +
|
||||
'unsafeWindow.gViewController.viewObjects.detail.node.removeEventListener("ViewChanged", whenViewChanges, false);\n' +
|
||||
'setTimeout(function() {\n' + // TODO: figure out why this is necessary..
|
||||
'self.postMessage({\n' +
|
||||
'somePreference: getAttributes(unsafeWindow.document.querySelector("setting[data-jetpack-id=\'' + self.id + '\']"))\n' +
|
||||
'});\n' +
|
||||
'}, 250);\n' +
|
||||
'}, false);\n' +
|
||||
'unsafeWindow.gViewController.commands.cmd_showItemDetails.doCommand(aAddon, true);\n' +
|
||||
'});\n' +
|
||||
'function getAttributes(ele) {\n' +
|
||||
'if (!ele) return {};\n' +
|
||||
'return {\n' +
|
||||
'title: ele.getAttribute("title")\n' +
|
||||
'}\n' +
|
||||
'}\n' +
|
||||
'}\n' +
|
||||
// Wait for the load event ?
|
||||
'if (document.readyState == "complete") {\n' +
|
||||
'onLoad()\n' +
|
||||
'} else {\n' +
|
||||
'unsafeWindow.addEventListener("load", onLoad, false);\n' +
|
||||
'}\n',
|
||||
onMessage: function(msg) {
|
||||
// test somePreference
|
||||
assert.equal(msg.somePreference.title, 'A', 'somePreference title is correct');
|
||||
tab.close(done);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
require('sdk/test/runner').runTestsFromModule(module);
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"id": "test-simple-prefs-l10n",
|
||||
"preferences": [{
|
||||
"name": "somePreference",
|
||||
"title": "some-title",
|
||||
"description": "Some short description for the preference",
|
||||
"type": "string",
|
||||
"value": "TEST"
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
'use strict';
|
||||
exports.console = console;
|
|
@ -327,4 +327,20 @@ exports['test invisibleToDebugger: true'] = function (assert) {
|
|||
}
|
||||
};
|
||||
|
||||
exports['test console global by default'] = function (assert) {
|
||||
let uri = root + '/fixtures/loader/globals/';
|
||||
let loader = Loader({ paths: { '': uri }});
|
||||
let program = main(loader, 'main');
|
||||
|
||||
assert.ok(typeof program.console === 'object', 'global `console` exists');
|
||||
assert.ok(typeof program.console.log === 'function', 'global `console.log` exists');
|
||||
|
||||
let loader2 = Loader({ paths: { '': uri }, globals: { console: fakeConsole }});
|
||||
let program2 = main(loader2, 'main');
|
||||
|
||||
assert.equal(program2.console, fakeConsole,
|
||||
'global console can be overridden with Loader options');
|
||||
function fakeConsole () {};
|
||||
};
|
||||
|
||||
require('test').run(exports);
|
||||
|
|
|
@ -965,6 +965,13 @@ exports['test emits on url changes'] = function (assert, done) {
|
|||
});
|
||||
};
|
||||
|
||||
exports['test panel can be constructed without any arguments'] = function (assert) {
|
||||
const { Panel } = require('sdk/panel');
|
||||
|
||||
let panel = Panel();
|
||||
assert.ok(true, "Creating a panel with no arguments does not throw");
|
||||
};
|
||||
|
||||
if (isWindowPBSupported) {
|
||||
exports.testGetWindow = function(assert, done) {
|
||||
let activeWindow = getMostRecentBrowserWindow();
|
||||
|
|
Загрузка…
Ссылка в новой задаче