Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into 821774
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bamberg committed Jan 18, 2013
2 parents b1eea82 + b1a80d9 commit adc5bd2
Show file tree
Hide file tree
Showing 77 changed files with 742 additions and 471 deletions.
4 changes: 2 additions & 2 deletions app-extension/install.rdf
Expand Up @@ -17,8 +17,8 @@
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>17.0</em:minVersion>
<em:maxVersion>20.0a1</em:maxVersion>
<em:minVersion>18.0</em:minVersion>
<em:maxVersion>21.0a1</em:maxVersion>
</Description>
</em:targetApplication>

Expand Down
17 changes: 9 additions & 8 deletions doc/dev-guide-source/cfx-tool.md
Expand Up @@ -872,16 +872,17 @@ You can use the cfx `--static-args` option to pass arbitrary data to your
program. This may be especially useful if you run cfx from a script.

The value of `--static-args` must be a JSON string. The object encoded by the
JSON becomes the `staticArgs` member of the `options` object passed as the
first argument to your program's `main` function. The default value of
JSON becomes the `staticArgs` property of the
[`system` module](modules/sdk/system.html).

The default value of
`--static-args` is `"{}"` (an empty object), so you don't have to worry about
checking whether `staticArgs` exists in `options`.
checking whether `staticArgs` exists in `system`.

For example, if your `main.js` looks like this:
For example, if your add-on looks like this:

exports.main = function (options, callbacks) {
console.log(options.staticArgs.foo);
};
var system = require("sdk/system");
console.log(system.staticArgs.foo);

And you run cfx like this:

Expand All @@ -892,7 +893,7 @@ And you run cfx like this:
Then your console should contain this:

<pre>
info: Hello from the command line
info: my-addon: Hello from the command line
</pre>

The `--static-args` option is recognized by two of the package-specific
Expand Down
Expand Up @@ -44,9 +44,9 @@ For example: the page below redefines `window.confirm()` to return
But thanks to the wrapper, a content script which calls
`window.confirm()` will get the native implementation:

var widgets = require("widget");
var tabs = require("tabs");
var data = require("self").data;
var widgets = require("sdk/widget");
var tabs = require("sdk/tabs");
var data = require("sdk/self").data;

var widget = widgets.Widget({
id: "transfer",
Expand Down
Expand Up @@ -75,9 +75,9 @@ In the main add-on code, we have a
[`page-mod`](modules/sdk/page-mod.html) that attaches the content script
"talk.js" to the right page:

var data = require("self").data;
var data = require("sdk/self").data;

var pageMod = require("page-mod");
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "http://my-domain.org/listen.html",
contentScriptFile: data.url("talk.js")
Expand Down Expand Up @@ -117,9 +117,9 @@ the same, but in reverse.
Here "main.js" creates a [`page-mod`](modules/sdk/page-mod.html)
that attaches "listen.js" to the web page:

var data = require("self").data;
var data = require("sdk/self").data;

var pageMod = require("page-mod");
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "http://my-domain.org/talk.html",
contentScriptFile: data.url("listen.js")
Expand Down Expand Up @@ -167,9 +167,9 @@ from a content script to a page script.
First, "main.js" will create a [`page-mod`](modules/sdk/page-mod.html)
that will attach "talk.js" to the target web page:

var data = require("self").data;
var data = require("sdk/self").data;

var pageMod = require("page-mod");
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "http://my-domain.org/listen.html",
contentScriptFile: data.url("talk.js")
Expand Down Expand Up @@ -209,9 +209,9 @@ to the content script is just the same, but in reverse.
Again, "main.js" creates a [`page-mod`](modules/sdk/page-mod.html)
to target the page we are interested in:

var data = require("self").data;
var data = require("sdk/self").data;

var pageMod = require("page-mod");
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "http://my-domain.org/talk.html",
contentScriptFile: data.url("listen.js")
Expand Down
6 changes: 3 additions & 3 deletions doc/dev-guide-source/guides/content-scripts/index.md
Expand Up @@ -61,13 +61,13 @@ uses the [page-mod](modules/sdk/page-mod.html) module to replace the
content of any web page in the `.co.uk` domain by executing a content script
in the context of that page:

var pageMod = require("page-mod");
var pageMod = require("sdk/page-mod");

pageMod.add(new pageMod.PageMod({
pageMod.PageMod({
include: ["*.co.uk"],
contentScript: 'document.body.innerHTML = ' +
'"<h1>this page has been eaten</h1>";'
}));
});

In this example the content script is supplied directly to the page mod via
the `contentScript` option in its constructor, and does not need to be
Expand Down
4 changes: 2 additions & 2 deletions doc/dev-guide-source/guides/content-scripts/loading.md
Expand Up @@ -25,7 +25,7 @@ which the content script will be loaded. To supply the file
root directory, use a line like:

// "data" is supplied by the "self" module
var data = require("self").data;
var data = require("sdk/self").data;
...
contentScriptFile: data.url("my-content-script.js")

Expand All @@ -34,7 +34,7 @@ can load multiple scripts, which can also interact directly with each other in
the content process:

// "data" is supplied by the "self" module
var data = require("self").data;
var data = require("sdk/self").data;
...
contentScriptFile:
[data.url("jquery-1.4.2.min.js"), data.url("my-content-script.js")]
Expand Down
8 changes: 4 additions & 4 deletions doc/dev-guide-source/guides/content-scripts/reddit-example.md
Expand Up @@ -15,9 +15,9 @@ script.

This is the complete add-on script:

var data = require("self").data;
var data = require("sdk/self").data;

var reddit_panel = require("panel").Panel({
var reddit_panel = require("sdk/panel").Panel({
width: 240,
height: 320,
contentURL: "http://www.reddit.com/.mobile?keep_extension=True",
Expand All @@ -26,10 +26,10 @@ This is the complete add-on script:
});

reddit_panel.port.on("click", function(url) {
require("tabs").open(url);
require("sdk/tabs").open(url);
});

require("widget").Widget({
require("sdk/widget").Widget({
id: "open-reddit-btn",
label: "Reddit",
contentURL: "http://www.reddit.com/static/favicon.ico",
Expand Down
8 changes: 4 additions & 4 deletions doc/dev-guide-source/guides/content-scripts/using-port.md
Expand Up @@ -24,7 +24,7 @@ an optional payload. The payload can be any value that is

Here's simple add-on that sends a message to a content script using `port`:

var tabs = require("tabs");
var tabs = require("sdk/tabs");

var alertContentScript = "self.port.on('alert', function(message) {" +
" window.alert(message);" +
Expand Down Expand Up @@ -89,7 +89,7 @@ in all modules. The `panel` and `page-worker` objects integrate the
worker API directly. So to receive events from a content script associated
with a panel you use `panel.port.on()`:

var panel = require("panel").Panel({
var panel = require("sdk/panel").Panel({
contentScript: "self.port.emit('showing', 'panel is showing');"
});

Expand All @@ -102,7 +102,7 @@ with a panel you use `panel.port.on()`:
Conversely, to emit user-defined events from your add-on you can just call
`panel.port.emit()`:

var panel = require("panel").Panel({
var panel = require("sdk/panel").Panel({
contentScript: "self.port.on('alert', function(text) {" +
" console.log(text);" +
"});"
Expand Down Expand Up @@ -133,7 +133,7 @@ emit events to it.
"window.alert(message);" +
"});"

var pageMod = require('page-mod').PageMod({
var pageMod = require('sdk/page-mod').PageMod({
include: ['*'],
contentScript: pageModScript,
onAttach: function(worker) {
Expand Down
20 changes: 10 additions & 10 deletions doc/dev-guide-source/guides/content-scripts/using-postmessage.md
Expand Up @@ -41,7 +41,7 @@ function. Again, `panel` and `page` integrate `worker` directly:
However, for `page-mod` objects you need to listen to the `onAttach` event
and use the worker supplied to that:

var pageMod = require('page-mod').PageMod({
var pageMod = require('sdk/page-mod').PageMod({
include: ['*'],
contentScript: pageModScript,
onAttach: function(worker) {
Expand All @@ -53,7 +53,7 @@ To receive messages from a content script, use the worker's `on` function.
To simplify this most content modules provide an `onMessage` property as an
argument to the constructor:

panel = require("panel").Panel({
panel = require("sdk/panel").Panel({
onMessage: function(contentScriptMessage) {
// Handle message from the content script
}
Expand All @@ -65,7 +65,7 @@ Content scripts are loaded according to the value of the
[`contentScriptWhen`](dev-guide/guides/content-scripts/loading.html)
option: until that point is reached, any attempt to send a message to
the script using `postMessage()` will trigger an exception, probably
the unintuitive message:
this:

<span class="aside">
This is a generic message which is emitted whenever we try to
Expand All @@ -80,9 +80,9 @@ Error: Couldn't find the worker to receive this message. The script may not be i
So code like this, where we create a panel and then
synchronously send it a message using `postMessage()`, will not work:

var data = require("self").data;
var data = require("sdk/self").data;

var panel = require("panel").Panel({
var panel = require("sdk/panel").Panel({
contentURL: "http://www.bbc.co.uk/mobile/index.html",
contentScriptFile: data.url("panel.js")
});
Expand All @@ -93,9 +93,9 @@ synchronously send it a message using `postMessage()`, will not work:
queues messages until the content script is ready to receive them,
so the equivalent code using `port.emit()` will work:

var data = require("self").data;
var data = require("sdk/self").data;

var panel = require("panel").Panel({
var panel = require("sdk/panel").Panel({
contentURL: "http://www.bbc.co.uk/mobile/index.html",
contentScriptFile: data.url("panel.js")
});
Expand All @@ -111,7 +111,7 @@ You can use message events as an alternative to user-defined events:
" self.postMessage(event.target.toString());" +
"}, false);";

var pageMod = require('page-mod').PageMod({
var pageMod = require('sdk/page-mod').PageMod({
include: ['*'],
contentScript: pageModScript,
onAttach: function(worker) {
Expand Down Expand Up @@ -143,7 +143,7 @@ implement a switch function in the receiver to dispatch the message:
" }, false);"


var pageMod = require('page-mod').PageMod({
var pageMod = require('sdk/page-mod').PageMod({
include: ['*'],
contentScript: pageModScript,
onAttach: function(worker) {
Expand All @@ -170,7 +170,7 @@ readable:
" self.port.emit('mouseout', event.target.toString());" +
"}, false);";

var pageMod = require('page-mod').PageMod({
var pageMod = require('sdk/page-mod').PageMod({
include: ['*'],
contentScript: pageModScript,
onAttach: function(worker) {
Expand Down
12 changes: 6 additions & 6 deletions doc/dev-guide-source/guides/events.md
Expand Up @@ -56,7 +56,7 @@ For example, the following add-on registers two listeners with the
listen for the `start` and `stop` events, and logs a string to the console
reporting the change:

var pb = require("private-browsing");
var pb = require("sdk/private-browsing");

pb.on("start", function() {
console.log("Private browsing is on");
Expand Down Expand Up @@ -90,8 +90,8 @@ The following add-on creates a widget and assigns a listener to the
`onClick` property of the `options` object supplied to the widget's
constructor. The listener loads the Google home page:

var widgets = require("widget");
var tabs = require("tabs");
var widgets = require("sdk/widget");
var tabs = require("sdk/tabs");

widgets.Widget({
id: "google-link",
Expand All @@ -105,8 +105,8 @@ constructor. The listener loads the Google home page:
This is exactly equivalent to constructing the widget and then calling the
widget's `on()` method:

var widgets = require("widget");
var tabs = require("tabs");
var widgets = require("sdk/widget");
var tabs = require("sdk/tabs");

var widget = widgets.Widget({
id: "google-link-alternative",
Expand All @@ -130,7 +130,7 @@ In the following add-on, we add two listeners to private-browsing's `start`
event, enter and exit private browsing, then remove the first listener and
enter private browsing again.

var pb = require("private-browsing");
var pb = require("sdk/private-browsing");

function listener1() {
console.log("Listener 1");
Expand Down
2 changes: 1 addition & 1 deletion doc/dev-guide-source/guides/modules.md
Expand Up @@ -211,7 +211,7 @@ It can then load them in the same way it would load a local module.
For example, to load from `main`:

// main.js code
var geo = require("/.dependencies/geolocation");
var geo = require("./dependencies/geolocation");

<div style="clear:both"></div>

Expand Down

0 comments on commit adc5bd2

Please sign in to comment.