Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit ccf77eb

Browse files
committed
Bug 844183: Uplift Add-on SDK changeset 2bee189e1cb87f5fbe38ce862c8ff35ee0978480
mozilla/addon-sdk@bf2c2f6...2bee189
1 parent 26263ff commit ccf77eb

27 files changed

Lines changed: 891 additions & 494 deletions

File tree

addon-sdk/source/LICENSE

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
The files which make up the SDK are developed by Mozilla and licensed
2-
under the MPL 2.0 (http://mozilla.org/MPL/2.0/), with the exception of the
3-
components listed below, which are made available by their authors under
4-
the licenses listed alongside.
5-
6-
syntaxhighlighter
7-
------------------
8-
doc/static-files/syntaxhighlighter
9-
Made available under the MIT license.
10-
11-
jQuery
12-
------
13-
examples/reddit-panel/data/jquery-1.4.4.min.js
14-
examples/annotator/data/jquery-1.4.2.min.js
15-
Made available under the MIT license.
16-
17-
simplejson
18-
----------
19-
python-lib/simplejson
20-
Made available under the MIT license.
21-
22-
Python Markdown
23-
---------------
24-
python-lib/markdown
25-
Made available under the BSD license.
26-
27-
LibraryDetector
28-
---------------
29-
examples/library-detector/data/library-detector.js
30-
Made available under the MIT license.
1+
The files which make up the SDK are developed by Mozilla and licensed
2+
under the MPL 2.0 (http://mozilla.org/MPL/2.0/), with the exception of the
3+
components listed below, which are made available by their authors under
4+
the licenses listed alongside.
5+
6+
syntaxhighlighter
7+
------------------
8+
doc/static-files/syntaxhighlighter
9+
Made available under the MIT license.
10+
11+
jQuery
12+
------
13+
examples/reddit-panel/data/jquery-1.4.4.min.js
14+
examples/annotator/data/jquery-1.4.2.min.js
15+
Made available under the MIT license.
16+
17+
simplejson
18+
----------
19+
python-lib/simplejson
20+
Made available under the MIT license.
21+
22+
Python Markdown
23+
---------------
24+
python-lib/markdown
25+
Made available under the BSD license.
26+
27+
LibraryDetector
28+
---------------
29+
examples/library-detector/data/library-detector.js
30+
Made available under the MIT license.

addon-sdk/source/README

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
Add-on SDK README
2-
==================
3-
4-
Before proceeding, please make sure you've installed Python 2.5,
5-
2.6, or 2.7 (if it's not already on your system):
6-
7-
http://python.org/download/
8-
9-
Note that Python 3.0 and 3.1 are not supported in this release.
10-
11-
For Windows users, MozillaBuild (https://wiki.mozilla.org/MozillaBuild)
12-
will install the correct version of Python and the MSYS package, which
13-
will make it easier to work with the SDK.
14-
15-
To get started, first enter the same directory that this README file
16-
is in (the SDK's root directory) using a shell program. On Unix systems
17-
or on Windows with MSYS, you can execute the following command:
18-
19-
source bin/activate
20-
21-
Windows users using cmd.exe should instead run:
22-
23-
bin\activate.bat
24-
25-
Then run:
26-
27-
cfx docs
28-
29-
This should start a documentation server and open a web browser
30-
with further instructions.
31-
32-
If you get an error when running cfx or have any other problems getting
33-
started, see the "Troubleshooting" guide at:
34-
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/troubleshooting.html
35-
36-
Bugs
37-
-------
38-
39-
* file a bug: https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK
40-
41-
42-
Style Guidelines
43-
--------------------
44-
1+
Add-on SDK README
2+
==================
3+
4+
Before proceeding, please make sure you've installed Python 2.5,
5+
2.6, or 2.7 (if it's not already on your system):
6+
7+
http://python.org/download/
8+
9+
Note that Python 3.0 and 3.1 are not supported in this release.
10+
11+
For Windows users, MozillaBuild (https://wiki.mozilla.org/MozillaBuild)
12+
will install the correct version of Python and the MSYS package, which
13+
will make it easier to work with the SDK.
14+
15+
To get started, first enter the same directory that this README file
16+
is in (the SDK's root directory) using a shell program. On Unix systems
17+
or on Windows with MSYS, you can execute the following command:
18+
19+
source bin/activate
20+
21+
Windows users using cmd.exe should instead run:
22+
23+
bin\activate.bat
24+
25+
Then run:
26+
27+
cfx docs
28+
29+
This should start a documentation server and open a web browser
30+
with further instructions.
31+
32+
If you get an error when running cfx or have any other problems getting
33+
started, see the "Troubleshooting" guide at:
34+
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/troubleshooting.html
35+
36+
Bugs
37+
-------
38+
39+
* file a bug: https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK
40+
41+
42+
Style Guidelines
43+
--------------------
44+
4545
* https://github.com/mozilla/addon-sdk/wiki/Coding-style-guide

addon-sdk/source/app-extension/bootstrap.js

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ const resourceHandler = ioService.getProtocolHandler('resource').
1919
const systemPrincipal = CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')();
2020
const scriptLoader = Cc['@mozilla.org/moz/jssubscript-loader;1'].
2121
getService(Ci.mozIJSSubScriptLoader);
22+
const prefService = Cc['@mozilla.org/preferences-service;1'].
23+
getService(Ci.nsIPrefService);
24+
const appInfo = Cc["@mozilla.org/xre/app-info;1"].
25+
getService(Ci.nsIXULAppInfo);
26+
const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
27+
getService(Ci.nsIVersionComparator);
28+
2229

2330
const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
2431
'install', 'uninstall', 'upgrade', 'downgrade' ];
@@ -120,19 +127,54 @@ function startup(data, reasonCode) {
120127
if (name == 'addon-sdk')
121128
paths['tests/'] = prefixURI + name + '/tests/';
122129

123-
// Maps sdk module folders to their resource folder
124-
paths['sdk/'] = prefixURI + 'addon-sdk/lib/sdk/';
125-
paths['toolkit/'] = prefixURI + 'addon-sdk/lib/toolkit/';
126-
// test.js is usually found in root commonjs or SDK_ROOT/lib/ folder,
127-
// so that it isn't shipped in the xpi. Keep a copy of it in sdk/ folder
128-
// until we no longer support SDK modules in XPI:
129-
paths['test'] = prefixURI + 'addon-sdk/lib/sdk/test.js';
130+
// Starting with Firefox 21.0a1, we start using modules shipped into firefox
131+
// Still allow using modules from the xpi if the manifest tell us to do so.
132+
// And only try to look for sdk modules in xpi if the xpi actually ship them
133+
if (options['is-sdk-bundled'] &&
134+
(vc.compare(appInfo.version, '21.0a1') < 0 ||
135+
options['force-use-bundled-sdk'])) {
136+
// Maps sdk module folders to their resource folder
137+
paths[''] = prefixURI + 'addon-sdk/lib/';
138+
// test.js is usually found in root commonjs or SDK_ROOT/lib/ folder,
139+
// so that it isn't shipped in the xpi. Keep a copy of it in sdk/ folder
140+
// until we no longer support SDK modules in XPI:
141+
paths['test'] = prefixURI + 'addon-sdk/lib/sdk/test.js';
142+
}
143+
144+
// Retrieve list of module folder overloads based on preferences in order to
145+
// eventually used a local modules instead of files shipped into Firefox.
146+
let branch = prefService.getBranch('extensions.modules.' + id + '.path');
147+
paths = branch.getChildList('', {}).reduce(function (result, name) {
148+
// Allows overloading of any sub folder by replacing . by / in pref name
149+
let path = name.substr(1).split('.').join('/');
150+
// Only accept overloading folder by ensuring always ending with `/`
151+
if (path) path += '/';
152+
let fileURI = branch.getCharPref(name);
153+
154+
// Maps the given file:// URI to a resource:// in order to avoid various
155+
// failure that happens with file:// URI and be close to production env
156+
let resourcesURI = ioService.newURI(fileURI, null, null);
157+
let resName = 'extensions.modules.' + domain + '.commonjs.path' + name;
158+
resourceHandler.setSubstitution(resName, resourcesURI);
159+
160+
result[path] = 'resource://' + resName + '/';
161+
return result;
162+
}, paths);
130163

131164
// Make version 2 of the manifest
132165
let manifest = options.manifest;
133166

134167
// Import `cuddlefish.js` module using a Sandbox and bootstrap loader.
135-
let cuddlefishURI = prefixURI + options.loader;
168+
let cuddlefishPath = 'loader/cuddlefish.js';
169+
let cuddlefishURI = 'resource://gre/modules/commonjs/sdk/' + cuddlefishPath;
170+
if (paths['sdk/']) { // sdk folder has been overloaded
171+
// (from pref, or cuddlefish is still in the xpi)
172+
cuddlefishURI = paths['sdk/'] + cuddlefishPath;
173+
}
174+
else if (paths['']) { // root modules folder has been overloaded
175+
cuddlefishURI = paths[''] + 'sdk/' + cuddlefishPath;
176+
}
177+
136178
cuddlefishSandbox = loadSandbox(cuddlefishURI);
137179
let cuddlefish = cuddlefishSandbox.exports;
138180

0 commit comments

Comments
 (0)