Permalink
Browse files

Merge branch 'master' into 821774

  • Loading branch information...
2 parents b1eea82 + b1a80d9 commit adc5bd2dd43b40b38482356ce4b85e0852fc8526 @wbamberg wbamberg committed Jan 18, 2013
Showing with 742 additions and 471 deletions.
  1. +2 −2 app-extension/install.rdf
  2. +9 −8 doc/dev-guide-source/cfx-tool.md
  3. +3 −3 doc/dev-guide-source/guides/content-scripts/accessing-the-dom.md
  4. +8 −8 doc/dev-guide-source/guides/content-scripts/communicating-with-other-scripts.md
  5. +3 −3 doc/dev-guide-source/guides/content-scripts/index.md
  6. +2 −2 doc/dev-guide-source/guides/content-scripts/loading.md
  7. +4 −4 doc/dev-guide-source/guides/content-scripts/reddit-example.md
  8. +4 −4 doc/dev-guide-source/guides/content-scripts/using-port.md
  9. +10 −10 doc/dev-guide-source/guides/content-scripts/using-postmessage.md
  10. +6 −6 doc/dev-guide-source/guides/events.md
  11. +1 −1 doc/dev-guide-source/guides/modules.md
  12. +28 −26 doc/dev-guide-source/guides/xul-migration.md
  13. +1 −1 doc/dev-guide-source/tutorials/add-a-context-menu-item.md
  14. +16 −12 doc/dev-guide-source/tutorials/adding-toolbar-button.md
  15. +2 −2 doc/dev-guide-source/tutorials/annotator/creating.md
  16. +4 −4 doc/dev-guide-source/tutorials/annotator/storing.md
  17. +2 −2 doc/dev-guide-source/tutorials/annotator/widget.md
  18. +3 −3 doc/dev-guide-source/tutorials/display-a-popup.md
  19. +8 −8 doc/dev-guide-source/tutorials/event-targets.md
  20. +4 −4 doc/dev-guide-source/tutorials/getting-started-with-cfx.md
  21. +7 −7 doc/dev-guide-source/tutorials/l10n.md
  22. +4 −4 doc/dev-guide-source/tutorials/list-open-tabs.md
  23. +2 −2 doc/dev-guide-source/tutorials/listen-for-page-load.md
  24. +1 −1 doc/dev-guide-source/tutorials/logging.md
  25. +8 −8 doc/dev-guide-source/tutorials/modifying-web-pages-tab.md
  26. +12 −12 doc/dev-guide-source/tutorials/modifying-web-pages-url.md
  27. +3 −3 doc/dev-guide-source/tutorials/open-a-web-page.md
  28. +7 −7 doc/dev-guide-source/tutorials/reusable-modules.md
  29. +5 −5 doc/dev-guide-source/tutorials/unit-testing.md
  30. +3 −3 doc/module-source/sdk/addon-page.md
  31. +2 −2 doc/module-source/sdk/base64.md
  32. +8 −9 doc/module-source/sdk/clipboard.md
  33. +2 −2 doc/module-source/sdk/content/loader.md
  34. +1 −1 doc/module-source/sdk/content/symbiont.md
  35. +3 −3 doc/module-source/sdk/content/worker.md
  36. +14 −14 doc/module-source/sdk/context-menu.md
  37. +3 −3 doc/module-source/sdk/core/heritage.md
  38. +3 −3 doc/module-source/sdk/core/namespace.md
  39. +5 −5 doc/module-source/sdk/core/promise.md
  40. +1 −1 doc/module-source/sdk/event/core.md
  41. +10 −13 doc/module-source/sdk/event/target.md
  42. +1 −1 doc/module-source/sdk/frame/hidden-frame.md
  43. +4 −4 doc/module-source/sdk/frame/utils.md
  44. +42 −20 doc/module-source/sdk/hotkeys.md
  45. +5 −5 doc/module-source/sdk/l10n.md
  46. +1 −1 doc/module-source/sdk/loader/sandbox.md
  47. +2 −2 doc/module-source/sdk/notifications.md
  48. +32 −32 doc/module-source/sdk/page-mod.md
  49. +2 −2 doc/module-source/sdk/page-mod/match-pattern.md
  50. +5 −5 doc/module-source/sdk/page-worker.md
  51. +13 −13 doc/module-source/sdk/panel.md
  52. +12 −12 doc/module-source/sdk/passwords.md
  53. +28 −28 doc/module-source/sdk/platform/xpcom.md
  54. +7 −7 doc/module-source/sdk/preferences/service.md
  55. +2 −2 doc/module-source/sdk/private-browsing.md
  56. +5 −4 doc/module-source/sdk/request.md
  57. +4 −4 doc/module-source/sdk/selection.md
  58. +2 −2 doc/module-source/sdk/self.md
  59. +5 −5 doc/module-source/sdk/simple-prefs.md
  60. +8 −8 doc/module-source/sdk/simple-storage.md
  61. +244 −0 doc/module-source/sdk/system.md
  62. +1 −1 doc/module-source/sdk/system/environment.md
  63. +1 −1 doc/module-source/sdk/system/events.md
  64. +10 −10 doc/module-source/sdk/tabs.md
  65. +2 −2 doc/module-source/sdk/test/assert.md
  66. +3 −3 doc/module-source/sdk/test/httpd.md
  67. +1 −1 doc/module-source/sdk/util/collection.md
  68. +2 −2 doc/module-source/sdk/util/uuid.md
  69. +40 −47 doc/module-source/sdk/widget.md
  70. +14 −14 doc/module-source/sdk/window/utils.md
  71. +7 −9 doc/module-source/sdk/windows.md
  72. +0 −1 doc/static-files/base.html
  73. +5 −0 python-lib/cuddlefish/__init__.py
  74. +1 −0 python-lib/cuddlefish/property_parser.py
  75. +2 −2 python-lib/cuddlefish/rdf.py
  76. +1 −0 test/test-disposable.js
  77. +4 −0 test/test-private-browsing.js
@@ -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>
@@ -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:
@@ -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
@@ -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",
@@ -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")
@@ -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")
@@ -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")
@@ -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")
@@ -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
@@ -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")
@@ -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")]
@@ -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",
@@ -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",
@@ -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);" +
@@ -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');"
});
@@ -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);" +
"});"
@@ -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) {
@@ -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) {
@@ -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
}
@@ -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
@@ -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")
});
@@ -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")
});
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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");
@@ -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",
@@ -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",
@@ -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");
@@ -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>
Oops, something went wrong.

0 comments on commit adc5bd2

Please sign in to comment.