Skip to content

Commit

Permalink
Bug 1139189: Uplift the Add-on SDK to Firefox a=me
Browse files Browse the repository at this point in the history
https://github.com/mozilla/addon-sdk/compare/3fbf5a6bdd6b2bfff3b916d9431fc4deab83f4a2..3394ad5d1d3eaa8e27ceea9b448ae39fa5cba0d9

--HG--
rename : addon-sdk/source/test/addons/l10n/locale/en-GB.properties => addon-sdk/source/test/addons/e10s-l10n/locale/en.properties
rename : addon-sdk/source/test/addons/l10n/locale/en-GB.properties => addon-sdk/source/test/addons/l10n/locale/en.properties
extra : rebase_source : f29b067cf47279b79946d01c510e52780798a64f
  • Loading branch information
Mossop committed Mar 12, 2015
1 parent aa56666 commit cac1321
Show file tree
Hide file tree
Showing 108 changed files with 4,842 additions and 853 deletions.
18 changes: 15 additions & 3 deletions addon-sdk/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ EXTRA_JS_MODULES.commonjs.dev += [
'source/lib/dev/frame-script.js',
'source/lib/dev/panel.js',
'source/lib/dev/ports.js',
'source/lib/dev/theme.js',
'source/lib/dev/toolbox.js',
'source/lib/dev/utils.js',
'source/lib/dev/volcan.js',
Expand All @@ -155,6 +156,10 @@ EXTRA_JS_MODULES.commonjs.dev.panel += [
'source/lib/dev/panel/view.js',
]

EXTRA_JS_MODULES.commonjs.dev.theme += [
'source/lib/dev/theme/hooks.js',
]

EXTRA_JS_MODULES.commonjs.diffpatcher += [
'source/lib/diffpatcher/diff.js',
'source/lib/diffpatcher/index.js',
Expand All @@ -171,12 +176,10 @@ EXTRA_JS_MODULES.commonjs.diffpatcher.test += [
]

EXTRA_JS_MODULES.commonjs.framescript += [
'source/lib/framescript/content.jsm',
'source/lib/framescript/context-menu.js',
'source/lib/framescript/contextmenu-events.js',
'source/lib/framescript/FrameScriptManager.jsm',
'source/lib/framescript/LoaderHelper.jsm',
'source/lib/framescript/manager.js',
'source/lib/framescript/tab-events.js',
'source/lib/framescript/util.js',
]

Expand Down Expand Up @@ -243,9 +246,12 @@ EXTRA_JS_MODULES.commonjs.sdk.content += [
'source/lib/sdk/content/content.js',
'source/lib/sdk/content/context-menu.js',
'source/lib/sdk/content/events.js',
'source/lib/sdk/content/l10n-html.js',
'source/lib/sdk/content/loader.js',
'source/lib/sdk/content/mod.js',
'source/lib/sdk/content/page-mod.js',
'source/lib/sdk/content/sandbox.js',
'source/lib/sdk/content/tab-events.js',
'source/lib/sdk/content/thumbnail.js',
'source/lib/sdk/content/utils.js',
'source/lib/sdk/content/worker-child.js',
Expand Down Expand Up @@ -389,6 +395,12 @@ EXTRA_JS_MODULES.commonjs.sdk['private-browsing'] += [
'source/lib/sdk/private-browsing/utils.js',
]

EXTRA_JS_MODULES.commonjs.sdk.remote += [
'source/lib/sdk/remote/child.js',
'source/lib/sdk/remote/parent.js',
'source/lib/sdk/remote/utils.js',
]

EXTRA_JS_MODULES.commonjs.sdk.stylesheet += [
'source/lib/sdk/stylesheet/style.js',
'source/lib/sdk/stylesheet/utils.js',
Expand Down
39 changes: 20 additions & 19 deletions addon-sdk/source/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
## Overview

- Changes should follow the [design guidelines], as well as [coding style guide] for Jetpack
- Changes should follow the [design guidelines], as well as the [coding style guide]
- All changes must be accompanied by tests
- In order to land, changes must have review from a core Jetpack developer
- In order to land, changes must have been reviewed by one of the Jetpack reviewers
- Changes should have additional API review when needed
- Changes should have additional review from a Mozilla platform domain-expert when needed

If you have questions, ask in [#jetpack on IRC][jetpack irc channel] or on the [Jetpack mailing list].

## How to Make Code Contributions

If you have code that you'd like to contribute the Jetpack project, follow these steps:
If you'd like to contribute the Jetpack project, follow these steps:

1. Look for your issue in the [bugs already filed][open bugs]
2. If no bug exists, [submit one][submit bug]
3. Make your changes, per the Overview
4. Write a test ([intro][test intro], [API][test API])
5. Submit pull request with changes and a title in a form of `Bug XXX - description`
6. Make sure that [Travis CI](https://travis-ci.org/mozilla/addon-sdk/branches) tests are passing for your branch.
7. Copy the pull request link from GitHub and paste it in as an attachment to the bug
8. Each pull request should idealy contain only one commit, so squash the commits if necessary.
9. Flag the attachment for code review from one of the Jetpack reviewers listed below.
This step is optional, but could speed things up.
10. Address any nits (ie style changes), or other issues mentioned in the review.
1. Look for your issue in the list of [bugs already filed][open bugs]. If you want to contribute, but don't already know what you want to do, we keep a list of [good first bugs].
2. If no bug exists, [submit one][submit bug].
3. Get the code: get a [GitHub][GitHub] account, fork the [Add-on SDK repo][Add-on SDK repo], and clone it to your machine.
4. Make your changes. Changes should follow the [design guidelines] as well as the [coding style guide].
5. Write tests: [unit testing introduction][test intro], [unit testing API][test API].
6. Submit a pull request with the changes and a title in the form of `Bug XXX - description`.
7. Make sure that [Travis CI](https://travis-ci.org/mozilla/addon-sdk/branches) tests are passing for your branch.
8. Copy the pull request link from GitHub and paste it in as an attachment to the bug.
9. Each pull request should ideally contain only one commit, so squash the commits if necessary.
10. Flag the attachment for code review from one of the Jetpack reviewers listed below. This step is optional, but could speed things up.
11. Address any issues mentioned in the review.

Finally, once review is approved, a team member will do the merging

## Good First Bugs

There is a list of [good first bugs here](https://bugzilla.mozilla.org/buglist.cgi?list_id=7345714&columnlist=bug_severity%2Cpriority%2Cassigned_to%2Cbug_status%2Ctarget_milestone%2Cresolution%2Cshort_desc%2Cchangeddate&query_based_on=jetpack-good-1st-bugs&status_whiteboard_type=allwordssubstr&query_format=advanced&status_whiteboard=[good%20first%20bug]&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=VERIFIED&product=Add-on%20SDK&known_name=jetpack-good-1st-bugs).
There is a list of [good first bugs here][good first bugs].

## Reviewers

All changes must be reviewed by someone on the Jetpack review crew:

- [@mossop]
- [@gozala]
- [@wbamberg]
- [@ZER0]
- [@erikvold]
- [@jsantell]
Expand All @@ -52,13 +51,15 @@ For API and developer ergonomics review, ask [@gozala].
[Jetpack mailing list]:http://groups.google.com/group/mozilla-labs-jetpack
[open bugs]:https://bugzilla.mozilla.org/buglist.cgi?quicksearch=product%3ASDK
[submit bug]:https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK&component=general
[test intro]:https://jetpack.mozillalabs.com/sdk/latest/docs/#guide/implementing-reusable-module
[test API]:https://jetpack.mozillalabs.com/sdk/latest/docs/#module/api-utils/unit-test
[test intro]:https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Unit_testing
[test API]:https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/test_assert
[coding style guide]:https://github.com/mozilla/addon-sdk/wiki/Coding-style-guide
[Add-on SDK repo]:https://github.com/mozilla/addon-sdk
[GitHub]:https://github.com/
[good first bugs]:https://bugzilla.mozilla.org/buglist.cgi?list_id=7345714&columnlist=bug_severity%2Cpriority%2Cassigned_to%2Cbug_status%2Ctarget_milestone%2Cresolution%2Cshort_desc%2Cchangeddate&query_based_on=jetpack-good-1st-bugs&status_whiteboard_type=allwordssubstr&query_format=advanced&status_whiteboard=[good%20first%20bug]&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=VERIFIED&product=Add-on%20SDK&known_name=jetpack-good-1st-bugs

[@mossop]:https://github.com/mossop/
[@gozala]:https://github.com/Gozala/
[@wbamberg]:https://github.com/wbamberg/
[@ZER0]:https://github.com/ZER0/
[@erikvold]:https://github.com/erikvold/
[@jsantell]:https://github.com/jsantell
Expand Down
2 changes: 1 addition & 1 deletion addon-sdk/source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ These resources should provide some help:

Please read these two guides if you wish to contribute some patches to the addon-sdk:

* [Contribute Guide](https://github.com/mozilla/addon-sdk/wiki/Contribute)
* [Contribute Guide](https://github.com/mozilla/addon-sdk/blob/master/CONTRIBUTING.md)
* [Style Guide](https://github.com/mozilla/addon-sdk/wiki/Coding-style-guide)

## Issues
Expand Down
Empty file.
1 change: 0 additions & 1 deletion addon-sdk/source/bin/jpm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var BLACKLIST = [];
var readParam = require("./node-scripts/utils").readParam;
var path = require("path");
var Mocha = require("mocha");
Expand Down
2 changes: 1 addition & 1 deletion addon-sdk/source/bin/node-scripts/test.addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("jpm test sdk addons", function () {

function fileFilter(root, file) {
var matcher = filterPattern && new RegExp(filterPattern);
if (/^(l10n|simple-prefs|page-mod-debugger)/.test(file)) {
if (/^(l10n-properties|simple-prefs|page-mod-debugger)/.test(file)) {
return false;
}
if (matcher && !matcher.test(file)) {
Expand Down
13 changes: 0 additions & 13 deletions addon-sdk/source/bootstrap.js

This file was deleted.

Empty file modified addon-sdk/source/examples/library-detector/README.md
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified addon-sdk/source/examples/library-detector/data/icons/yui.ico
100755 → 100644
Empty file.
Empty file.
Empty file modified addon-sdk/source/examples/library-detector/data/widget.html
100755 → 100644
Empty file.
Empty file modified addon-sdk/source/examples/library-detector/lib/main.js
100755 → 100644
Empty file.
Binary file added addon-sdk/source/examples/theme/data/icon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions addon-sdk/source/examples/theme/data/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- 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/. -->
<html>
<head>
</head>
<body>
</body>
</html>
7 changes: 7 additions & 0 deletions addon-sdk/source/examples/theme/data/theme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* 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/. */

#devtools-theme-box {
background-color: red !important;
}
37 changes: 37 additions & 0 deletions addon-sdk/source/examples/theme/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* 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 { Tool } = require("dev/toolbox");
const { Class } = require("sdk/core/heritage");
const { onEnable, onDisable } = require("dev/theme/hooks");
const { Theme, LightTheme } = require("dev/theme");

/**
* This object represents a new theme registered within the Toolbox.
* You can activate it by clicking on "My Light Theme" theme option
* in the Options panel.
* Note that the new theme derives styles from built-in Light theme.
*/
const MyTheme = Theme({
name: "mytheme",
label: "My Light Theme",
styles: [LightTheme, "./theme.css"],

onEnable: function(window, oldTheme) {
console.log("myTheme.onEnable; method override " +
window.location.href);
},
onDisable: function(window, newTheme) {
console.log("myTheme.onDisable; method override " +
window.location.href);
},
});

// Registration

const mytheme = new Tool({
name: "My Tool",
themes: { mytheme: MyTheme }
});
10 changes: 10 additions & 0 deletions addon-sdk/source/examples/theme/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "theme",
"title": "theme",
"id": "theme@jetpack",
"description": "How to create new theme for devtools",
"author": "Jan Odvarko",
"license": "MPL 2.0",
"version": "0.1.0",
"main": "lib/main"
}
10 changes: 10 additions & 0 deletions addon-sdk/source/examples/theme/test/test-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* 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.testMain = function(assert) {
assert.pass("TODO: Write some tests.");
};

require("sdk/test").run(exports);
135 changes: 135 additions & 0 deletions addon-sdk/source/lib/dev/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/* 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";

module.metadata = {
"stability": "experimental"
};

const { Class } = require("../sdk/core/heritage");
const { EventTarget } = require("../sdk/event/target");
const { Disposable, setup, dispose } = require("../sdk/core/disposable");
const { contract, validate } = require("../sdk/util/contract");
const { id: addonID } = require("../sdk/self");
const { onEnable, onDisable } = require("dev/theme/hooks");
const { isString, instanceOf, isFunction } = require("sdk/lang/type");
const { add } = require("sdk/util/array");
const { data } = require("../sdk/self");
const { isLocalURL } = require("../sdk/url");

const makeID = name =>
("dev-theme-" + addonID + (name ? "-" + name : "")).
split(/[ . /]/).join("-").
replace(/[^A-Za-z0-9_\-]/g, "");

const Theme = Class({
extends: Disposable,
implements: [EventTarget],

initialize: function(options) {
this.name = options.name;
this.label = options.label;
this.styles = options.styles;

// Event handlers
this.onEnable = options.onEnable;
this.onDisable = options.onDisable;
},
get id() {
return makeID(this.name || this.label);
},
setup: function() {
// Any initialization steps done at the registration time.
},
getStyles: function() {
if (!this.styles) {
return [];
}

if (isString(this.styles)) {
if (isLocalURL(this.styles)) {
return [data.url(this.styles)];
}
}

let result = [];
for (let style of this.styles) {
if (isString(style)) {
if (isLocalURL(style)) {
style = data.url(style);
}
add(result, style);
} else if (instanceOf(style, Theme)) {
result = result.concat(style.getStyles());
}
}
return result;
},
getClassList: function() {
let result = [];
for (let style of this.styles) {
if (instanceOf(style, Theme)) {
result = result.concat(style.getClassList());
}
}

if (this.name) {
add(result, this.name);
}

return result;
}
});

exports.Theme = Theme;

// Initialization & dispose

setup.define(Theme, (theme) => {
theme.classList = [];
theme.setup();
});

dispose.define(Theme, function(theme) {
theme.dispose();
});

// Validation

validate.define(Theme, contract({
label: {
is: ["string"],
msg: "The `option.label` must be a provided"
},
}));

// Support theme events: apply and unapply the theme.

onEnable.define(Theme, (theme, {window, oldTheme}) => {
if (isFunction(theme.onEnable)) {
theme.onEnable(window, oldTheme);
}
});

onDisable.define(Theme, (theme, {window, newTheme}) => {
if (isFunction(theme.onDisable)) {
theme.onDisable(window, newTheme);
}
});

// Support for built-in themes

const LightTheme = Theme({
name: "theme-light",
styles: "chrome://browser/skin/devtools/light-theme.css",
});

const DarkTheme = Theme({
name: "theme-dark",
styles: "chrome://browser/skin/devtools/dark-theme.css",
});

exports.LightTheme = LightTheme;
exports.DarkTheme = DarkTheme;
Loading

0 comments on commit cac1321

Please sign in to comment.