diff --git a/.gitignore b/.gitignore index 96ab221f0..7829e702a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,6 @@ doc/index.html doc/packages/ doc/status.md5 packages/* -!packages/addon-kit/ -!packages/api-utils/ -!packages/test-harness/ # Python *.pyc diff --git a/packages/addon-kit/data/index.html b/data/index.html similarity index 100% rename from packages/addon-kit/data/index.html rename to data/index.html diff --git a/packages/addon-kit/data/moz_favicon.ico b/data/moz_favicon.ico similarity index 100% rename from packages/addon-kit/data/moz_favicon.ico rename to data/moz_favicon.ico diff --git a/packages/addon-kit/data/pagemod-css-include-file.css b/data/pagemod-css-include-file.css similarity index 100% rename from packages/addon-kit/data/pagemod-css-include-file.css rename to data/pagemod-css-include-file.css diff --git a/packages/api-utils/data/test-content-symbiont.js b/data/test-content-symbiont.js similarity index 100% rename from packages/api-utils/data/test-content-symbiont.js rename to data/test-content-symbiont.js diff --git a/packages/addon-kit/data/test-context-menu.js b/data/test-context-menu.js similarity index 100% rename from packages/addon-kit/data/test-context-menu.js rename to data/test-context-menu.js diff --git a/packages/api-utils/data/test-message-manager.js b/data/test-message-manager.js similarity index 100% rename from packages/api-utils/data/test-message-manager.js rename to data/test-message-manager.js diff --git a/packages/api-utils/data/test-uri-io.txt b/data/test-net-url.txt similarity index 100% rename from packages/api-utils/data/test-uri-io.txt rename to data/test-net-url.txt diff --git a/packages/addon-kit/data/test-page-mod.html b/data/test-page-mod.html similarity index 100% rename from packages/addon-kit/data/test-page-mod.html rename to data/test-page-mod.html diff --git a/packages/addon-kit/data/test-page-worker.html b/data/test-page-worker.html similarity index 100% rename from packages/addon-kit/data/test-page-worker.html rename to data/test-page-worker.html diff --git a/packages/addon-kit/data/test-page-worker.js b/data/test-page-worker.js similarity index 100% rename from packages/addon-kit/data/test-page-worker.js rename to data/test-page-worker.js diff --git a/packages/api-utils/data/test-trusted-document.html b/data/test-trusted-document.html similarity index 100% rename from packages/api-utils/data/test-trusted-document.html rename to data/test-trusted-document.html diff --git a/packages/addon-kit/data/test.html b/data/test.html similarity index 100% rename from packages/addon-kit/data/test.html rename to data/test.html diff --git a/doc/dev-guide-source/cfx-tool.md b/doc/dev-guide-source/cfx-tool.md index 9690322bc..6973097d3 100644 --- a/doc/dev-guide-source/cfx-tool.md +++ b/doc/dev-guide-source/cfx-tool.md @@ -298,7 +298,7 @@ they contain. See the [tutorial on unit testing](dev-guide/tutorials/unit-testing.html) and the -[reference documentation for the `assert` module](packages/api-utils/test/assert.html) +[reference documentation for the `assert` module](modules/sdk/test/assert.html) for details. #### Supported Options ##### @@ -806,7 +806,7 @@ one run of `cfx` will not, by default, be available in the next run. This includes, for example, any extra add-ons you installed, or your history, or any data stored using the -[simple-storage](packages/addon-kit/simple-storage.html) API. +[simple-storage](modules/sdk/simple-storage.html) API. To make `cfx` use a specific profile, pass the `--profiledir` option, specifying the path to the profile you wish to use. diff --git a/doc/dev-guide-source/guides/commonjs.md b/doc/dev-guide-source/guides/commonjs.md index 4684c7a28..f386b2ffd 100644 --- a/doc/dev-guide-source/guides/commonjs.md +++ b/doc/dev-guide-source/guides/commonjs.md @@ -109,27 +109,27 @@ Modules in the `api-utils` package implement low-level APIs. These modules fall roughly into three categories: * fundamental utilities such as -[collection](packages/api-utils/collection.html) and -[url](packages/api-utils/url.html). Many add-ons are likely to +[collection](modules/sdk/platform/xpcom.html) and +[url](modules/sdk/url.html). Many add-ons are likely to want to use modules from this category. * building blocks for higher level modules, such as -[event/core](packages/api-utils/event/core.html), -[event/target](packages/api-utils/event/target.html), -[heritage](packages/api-utils/heritage.html), and -[namespace](packages/api-utils/namespace.html). You're more +[event/core](modules/sdk/event/core.html), +[event/target](modules/sdk/event/target.html), +[heritage](modules/sdk/core/heritage.html), and +[namespace](modules/sdk/core/namespace.html). You're more likely to use these if you are building your own modules that implement new APIs, thus extending the SDK itself. * privileged modules that expose powerful low-level capabilities -such as [xhr](packages/api-utils/xhr.html) and -[xpcom](packages/api-utils/xpcom.html). You can use these +such as [xhr](modules/sdk/net/xhr.html) and +[xpcom](modules/sdk/platform/xpcom.html). You can use these modules in your add-on if you need to, but should be aware that the cost of privileged access is the need to take more elaborate security precautions. In many cases these modules have simpler, more restricted analogs in the high-level addon-kit package (for -example, [tabs](packages/addon-kit/tabs.html) or -[request](packages/addon-kit/request.html)). +example, [tabs](modules/sdk/tabs.html) or +[request](modules/sdk/request.html)).

These modules are still in active development, diff --git a/doc/dev-guide-source/guides/content-scripts/communicating-with-other-scripts.md b/doc/dev-guide-source/guides/content-scripts/communicating-with-other-scripts.md index e445ce259..03d75dc59 100644 --- a/doc/dev-guide-source/guides/content-scripts/communicating-with-other-scripts.md +++ b/doc/dev-guide-source/guides/content-scripts/communicating-with-other-scripts.md @@ -72,7 +72,7 @@ Suppose we have a page called "listen.html" hosted at "my-domain.org", and we wa from the add-on to a script embedded in that page. In the main add-on code, we have a -[`page-mod`](packages/addon-kit/page-mod.html) that attaches the content script +[`page-mod`](modules/sdk/page-mod.html) that attaches the content script "talk.js" to the right page: var data = require("self").data; @@ -114,7 +114,7 @@ messages from the content script: Sending messages from the page script to the content script is just the same, but in reverse. -Here "main.js" creates a [`page-mod`](packages/addon-kit/page-mod.html) +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; @@ -164,7 +164,7 @@ to communicate between page scripts and content scripts. Here's an example showing how to use custom DOM events to send a message from a content script to a page script. -First, "main.js" will create a [`page-mod`](packages/addon-kit/page-mod.html) +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; @@ -206,7 +206,7 @@ Finally "listen.html" listens for the new event and examines its Sending messages using custom DOM events from the page script to the content script is just the same, but in reverse. -Again, "main.js" creates a [`page-mod`](packages/addon-kit/page-mod.html) +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; diff --git a/doc/dev-guide-source/guides/content-scripts/index.md b/doc/dev-guide-source/guides/content-scripts/index.md index af03137c3..021f97e74 100644 --- a/doc/dev-guide-source/guides/content-scripts/index.md +++ b/doc/dev-guide-source/guides/content-scripts/index.md @@ -10,19 +10,19 @@ content of web pages or be notified when the user clicks a link. The SDK provides several core modules to support this: -**[panel](packages/addon-kit/panel.html)**
+**[panel](modules/sdk/panel.html)**
Create a dialog that can host web content. -**[page-worker](packages/addon-kit/page-worker.html)**
+**[page-worker](modules/sdk/page-worker.html)**
Retrieve a page and access its content, without displaying it to the user. -**[page-mod](packages/addon-kit/page-mod.html)**
+**[page-mod](modules/sdk/page-mod.html)**
Execute scripts in the context of selected web pages. -**[widget](packages/addon-kit/widget.html)**
+**[widget](modules/sdk/widget.html)**
Host an add-on's user interface, including web content. -**[context-menu](packages/addon-kit/context-menu.html)**
+**[context-menu](modules/sdk/context-menu.html)**
Add items to the browser's context menu. Firefox is moving towards a model in which it uses separate @@ -57,7 +57,7 @@ relationships. The gray fill represents code written by the add-on developer. alt="Content script events"> This might sound complicated but it doesn't need to be. The following add-on -uses the [page-mod](packages/addon-kit/page-mod.html) module to replace the +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: diff --git a/doc/dev-guide-source/guides/content-scripts/reddit-example.md b/doc/dev-guide-source/guides/content-scripts/reddit-example.md index 438ed1494..1a12ae301 100644 --- a/doc/dev-guide-source/guides/content-scripts/reddit-example.md +++ b/doc/dev-guide-source/guides/content-scripts/reddit-example.md @@ -42,7 +42,7 @@ link clicks. Finally, it registers a listener to the user-defined `click` event which in turn passes the URL into the `open` function of the -[tabs](packages/addon-kit/tabs.html) module. +[tabs](modules/sdk/tabs.html) module. This is the `panel.js` content script that intercepts link clicks: diff --git a/doc/dev-guide-source/guides/content-scripts/using-port.md b/doc/dev-guide-source/guides/content-scripts/using-port.md index 7c5d19cf7..b6501f43a 100644 --- a/doc/dev-guide-source/guides/content-scripts/using-port.md +++ b/doc/dev-guide-source/guides/content-scripts/using-port.md @@ -51,7 +51,7 @@ the recipient but just emits the event and continues processing. ## Accessing `port` in the Content Script ## Note that the global `self` object is completely -different from the [`self` module](packages/addon-kit/self.html), which +different from the [`self` module](modules/sdk/self.html), which provides an API for an add-on to access its data files and ID. In the content script the `port` object is available as a property of the @@ -67,7 +67,7 @@ To receive an event from the add-on code: Compare this to the technique used to receive _built-in_ events in the content script. For example, to receive the `context` event in a content script -associated with a [context menu](packages/addon-kit/context-menu.html) +associated with a [context menu](modules/sdk/context-menu.html) object, you would call the `on` function attached to the global `self` object: self.on("context", function() { diff --git a/doc/dev-guide-source/guides/events.md b/doc/dev-guide-source/guides/events.md index 78082a5a8..b372a2d00 100644 --- a/doc/dev-guide-source/guides/events.md +++ b/doc/dev-guide-source/guides/events.md @@ -5,7 +5,7 @@ # Working with Events # The Add-on SDK supports event-driven programming through its -[`EventEmitter`](packages/api-utils/events.html) framework. +[`EventEmitter`](modules/sdk/deprecated/events.html) framework. Objects emit events on state changes that might be of interest to add-on code, such as browser windows opening, pages loading, network requests completing, @@ -52,7 +52,7 @@ whenever the event occurs. The arguments that will be passed to the listener are specific to an event type and are documented with the event emitter. For example, the following add-on registers two listeners with the -[`private-browsing`](packages/addon-kit/private-browsing.html) module to +[`private-browsing`](modules/sdk/private-browsing.html) module to listen for the `start` and `stop` events, and logs a string to the console reporting the change: @@ -83,7 +83,7 @@ with "on": for example, "onOpen", "onReady" and so on. Then in the constructor you can assign a listener function to this property as an alternative to calling the object's `on()` method. -For example: the [`widget`](packages/addon-kit/widget.html) object emits +For example: the [`widget`](modules/sdk/widget.html) object emits an event when the widget is clicked. The following add-on creates a widget and assigns a listener to the diff --git a/doc/dev-guide-source/guides/firefox-compatibility.md b/doc/dev-guide-source/guides/firefox-compatibility.md index b3b226a70..3af22b5e9 100644 --- a/doc/dev-guide-source/guides/firefox-compatibility.md +++ b/doc/dev-guide-source/guides/firefox-compatibility.md @@ -5,7 +5,7 @@ # Firefox Compatibility # One of the promises the SDK makes is to maintain compatibility for its -["supported" or "high-level" APIs](packages/addon-kit/index.html): +["supported" or "high-level" APIs]FIXME: meaning that code written against them will not need to change as new versions of Firefox are released. diff --git a/doc/dev-guide-source/guides/library-detector.md b/doc/dev-guide-source/guides/library-detector.md index d09e9e863..7258a6dd2 100644 --- a/doc/dev-guide-source/guides/library-detector.md +++ b/doc/dev-guide-source/guides/library-detector.md @@ -72,7 +72,7 @@ access to the un-proxied DOM window, so they can see the objects added by libraries, so we’ll need to use the experimental [unsafeWindow](dev-guide/guides/content-scripts/accessing-the-dom.html#unsafeWindow) The main add-on script, `main.js`, will use a -[`page-mod`](packages/addon-kit/page-mod.html) +[`page-mod`](modules/sdk/page-mod.html) to inject the content script into every new page. The content script, which we'll call `library-detector.js`, will keep most of @@ -101,7 +101,7 @@ the array of library names, and post it back to `main.js`: `main.js` responds to that message by fetching the tab corresponding to that worker using -[`worker.tab`](packages/api-utils/content/worker.html#tab), and adding +[`worker.tab`](modules/sdk/content/worker.html#tab), and adding the array of library names to that tab's `libraries` property: pageMod.PageMod({ @@ -134,11 +134,11 @@ a page contains more than one iframe, and those iframes use the same library. #### Showing the Library Array #### -The [`widget`](packages/addon-kit/widget.html) module is a natural fit +The [`widget`](modules/sdk/widget.html) module is a natural fit for displaying the library list. We'll specify its content using HTML, so we can display an array of icons. The widget must be able to display different content for different windows, so we'll use the -[`WidgetView`](packages/addon-kit/widget.html) object. +[`WidgetView`](modules/sdk/widget.html) object. `main.js` will create an array of icons corresponding to the array of library names, and use that to build the widget's HTML content dynamically: @@ -163,7 +163,7 @@ names, and use that to build the widget's HTML content dynamically: } `main.js` will -use the [`tabs`](packages/addon-kit/tabs.html) module to update the +use the [`tabs`](modules/sdk/tabs.html) module to update the widget's content when necessary (for example, when the user switches between tabs): diff --git a/doc/dev-guide-source/guides/module-search.md b/doc/dev-guide-source/guides/module-search.md index 69d218f4c..bca108e59 100644 --- a/doc/dev-guide-source/guides/module-search.md +++ b/doc/dev-guide-source/guides/module-search.md @@ -21,7 +21,7 @@ The module-search logic needs to provide features like: * support for "packages": groups of related modules that are bundled together for easy distribution * easy and concise use of "stdlib" modules like `panel` and `page-mod` in - `packages/addon-kit/lib`, perhaps searching multiple packages for a module + `FIXMElib`, perhaps searching multiple packages for a module with the right name * "absolute" imports: minimize searching (and ambiguity) by specifying exactly which package contains the module of interest diff --git a/doc/dev-guide-source/guides/program-id.md b/doc/dev-guide-source/guides/program-id.md index 72d66be32..186d35bba 100644 --- a/doc/dev-guide-source/guides/program-id.md +++ b/doc/dev-guide-source/guides/program-id.md @@ -11,7 +11,7 @@ add-on for distribution using `cfx xpi`, it will become the The ID is used for a variety of purposes. For example: [addons.mozilla.org](http://addons.mozilla.org) uses it to distinguish between new add-ons and updates to existing add-ons, and the -[`simple-storage`](packages/addon-kit/simple-storage.html) module uses it +[`simple-storage`](modules/sdk/simple-storage.html) module uses it to figure out which stored data belongs to which add-on. It is read from the `id` key in your add-on's [`package.json`](dev-guide/package-spec.html) file. diff --git a/doc/dev-guide-source/guides/xul-migration.md b/doc/dev-guide-source/guides/xul-migration.md index 548998318..ddd85e6a0 100644 --- a/doc/dev-guide-source/guides/xul-migration.md +++ b/doc/dev-guide-source/guides/xul-migration.md @@ -81,7 +81,7 @@ registers a listener function for messages from the content script * the content script (3) extracts the data from the page and (4) sends it to the main add-on code in a message * the main add-on code (5) receives the message and (6) sends the request, -using the SDK's [`request`](packages/addon-kit/request.html) API +using the SDK's [`request`](modules/sdk/request.html) API Content script organization @@ -101,7 +101,7 @@ There's much more information on content scripts in the The SDK provides a set of high level APIs providing some basic user interface components and functionality commonly required by add-ons. These are collected together in the -[`addon-kit`](packages/addon-kit/index.html) +[`addon-kit`]FIXME package. Because we expect to keep these APIs compatible as new versions of Firefox are released, we call them the "supported" APIs. @@ -111,8 +111,8 @@ If the supported APIs do what you need, they're the best option: you get the benefits of compatibility across Firefox releases and of the SDK's security model. -APIs like [`widget`](packages/addon-kit/widget.html) and -[`panel`](packages/addon-kit/panel.html) are very generic and with the +APIs like [`widget`](modules/sdk/widget.html) and +[`panel`](modules/sdk/panel.html) are very generic and with the right content can be used to replace many specific XUL elements. But there are some notable limitations in the SDK APIs and even a fairly simple UI may need some degree of redesign to work with them. @@ -166,8 +166,8 @@ continue to work as new versions of Firefox are released. In addition to the High-Level APIs, the SDK includes a number of Low-Level APIs some of which, such -as [`tab-browser`](packages/api-utils/tab-browser.html), [`xhr`](packages/api-utils/xhr.html), and -[`window-utils`](packages/api-utils/window-utils.html), expose powerful +as [`tab-browser`](modules/sdk/deprecated/tab-browser.html), [`xhr`](modules/sdk/net/xhr.html), and +[`window-utils`](modules/sdk/deprecated/window-utils.html), expose powerful browser capabilities. In this section we'll use low-level modules how to: @@ -178,7 +178,7 @@ object ### Modifying the Browser Chrome ### -The [`window-utils`](packages/api-utils/window-utils.html) module gives +The [`window-utils`](modules/sdk/deprecated/window-utils.html) module gives you direct access to chrome windows, including the browser's chrome window. Here's a really simple example add-on that modifies the browser chrome using `window-utils`: @@ -206,7 +206,7 @@ collection of [third party modules](https://wiki.mozilla.org/Jetpack/Modules). ### Accessing tabbrowser ### -The [`tab-browser`](packages/api-utils/tab-browser.html) module gives +The [`tab-browser`](modules/sdk/deprecated/tab-browser.html) module gives you direct access to the [tabbrowser](https://developer.mozilla.org/en/XUL/tabbrowser) object. This simple example modifies the selected tab's CSS to enable the user to highlight @@ -241,9 +241,9 @@ APIs it explicitly imports via `require()`. This is useful, because it means that if a malicious web page is able to inject code into your add-on's context, it is only able to use the APIs you have imported. For example, if you have only imported the -[`notifications`](packages/addon-kit/notifications.html) module, then +[`notifications`](modules/sdk/notifications.html) module, then even if a malicious web page manages to inject code into your add-on, it -can't use the SDK's [`file`](packages/api-utils/file.html) module to +can't use the SDK's [`file`](modules/sdk/io/file.html) module to access the user's data. But this means that the more powerful modules you `require()`, the greater diff --git a/doc/dev-guide-source/index.md b/doc/dev-guide-source/index.md index 8259074c3..77f1dadad 100644 --- a/doc/dev-guide-source/index.md +++ b/doc/dev-guide-source/index.md @@ -131,9 +131,9 @@ Learn about common development techniques, such as

API reference

Reference documentation for the high-level SDK APIs found in the - addon-kit + FIXME package, and the low-level APIs found in the - api-utils package. + FIXME. diff --git a/doc/dev-guide-source/low-level-apis.md b/doc/dev-guide-source/low-level-apis.md index 6625617ff..a84cea551 100644 --- a/doc/dev-guide-source/low-level-apis.md +++ b/doc/dev-guide-source/low-level-apis.md @@ -8,27 +8,27 @@ Modules in this section implement low-level APIs. These modules fall roughly into three categories: * fundamental utilities such as -[collection](packages/api-utils/collection.html) and -[url](packages/api-utils/url.html). Many add-ons are likely to +[collection](modules/sdk/platform/xpcom.html) and +[url](modules/sdk/url.html). Many add-ons are likely to want to use modules from this category. * building blocks for higher level modules, such as -[events](packages/api-utils/events.html), -[worker](packages/api-utils/content/worker.html), and -[api-utils](packages/api-utils/api-utils.html). You're more +[events](modules/sdk/deprecated/events.html), +[worker](modules/sdk/content/worker.html), and +[api-utils](modules/sdk/deprecated/api-utils.html). You're more likely to use these if you are building your own modules that implement new APIs, thus extending the SDK itself. * privileged modules that expose powerful low-level capabilities -such as [tab-browser](packages/api-utils/tab-browser.html), -[xhr](packages/api-utils/xhr.html), and -[xpcom](packages/api-utils/xpcom.html). You can use these +such as [tab-browser](modules/sdk/deprecated/tab-browser.html), +[xhr](modules/sdk/net/xhr.html), and +[xpcom](modules/sdk/platform/xpcom.html). You can use these modules in your add-on if you need to, but should be aware that the cost of privileged access is the need to take more elaborate security precautions. In many cases these modules have simpler, more restricted analogs among the "High-Level APIs" (for -example, [tabs](packages/addon-kit/tabs.html) or -[request](packages/addon-kit/request.html)). +example, [tabs](modules/sdk/tabs.html) or +[request](modules/sdk/request.html)). These modules are still in active development, and we expect to -make incompatible changes to them in future releases. \ No newline at end of file +make incompatible changes to them in future releases. diff --git a/doc/dev-guide-source/package-spec.md b/doc/dev-guide-source/package-spec.md index ce41c3561..20aa7818b 100644 --- a/doc/dev-guide-source/package-spec.md +++ b/doc/dev-guide-source/package-spec.md @@ -56,7 +56,7 @@ called `package.json`. This file is also referred to as the An array of JSON objects that use the following keys `name`, `type`, `value`, `title`, and `description`. These JSON objects will be used to automatically create a preferences interface for the addon in the Add-ons Manager. - For more information see the documentation of [simple-prefs](packages/addon-kit/simple-prefs.html). + For more information see the documentation of [simple-prefs](modules/sdk/simple-prefs.html). * `license` - the name of the license as a String, with an optional URL in parentheses. @@ -113,7 +113,7 @@ API documentation. Packages may optionally contain a directory called `data` into which arbitrary files may be placed, such as images or text files. The URL for these resources may be reached using the -[self](packages/addon-kit/self.html) module. +[self](modules/sdk/self.html) module. [Markdown]: http://daringfireball.net/projects/markdown/ [non-bootstrapped XUL extension]: #guide/xul-extensions diff --git a/doc/dev-guide-source/tutorials/add-a-context-menu-item.md b/doc/dev-guide-source/tutorials/add-a-context-menu-item.md index 2138eb19d..3062845e3 100644 --- a/doc/dev-guide-source/tutorials/add-a-context-menu-item.md +++ b/doc/dev-guide-source/tutorials/add-a-context-menu-item.md @@ -12,7 +12,7 @@ and learned the To add items and submenus to the Firefox context menu, use the -[`context-menu`](packages/addon-kit/context-menu.html) module. +[`context-menu`](modules/sdk/context-menu.html) module. Here's an add-on that adds a new context menu item. The item is displayed whenever something in the page is selected. When it's @@ -86,4 +86,4 @@ is passed the selected text, which it logs ## Learning More ## To learn more about the `context-menu` module, see the -[`context-menu` API reference](packages/addon-kit/context-menu.html). \ No newline at end of file +[`context-menu` API reference](modules/sdk/context-menu.html). \ No newline at end of file diff --git a/doc/dev-guide-source/tutorials/adding-menus.md b/doc/dev-guide-source/tutorials/adding-menus.md index 7a8b51bf8..a4817de6d 100644 --- a/doc/dev-guide-source/tutorials/adding-menus.md +++ b/doc/dev-guide-source/tutorials/adding-menus.md @@ -30,8 +30,8 @@ Third-party packages like `menuitems` can be installed in three different places: * in the `packages` directory under the SDK root, alongside built-in -packages like [`addon-kit`](packages/addon-kit/index.html) and -[`api-utils`](packages/api-utils/index.html). If you do this the package is +packages like [`addon-kit`]FIXME and +[`api-utils`]FIXME. If you do this the package is available to any other add-ons you're developing using that SDK instance, and the package's documentation is visible through `cfx docs`. * in a `packages` directory you create under your add-on's root: if you @@ -109,7 +109,7 @@ In your add-on's `package.json` add the line: Note that due to [bug 663480](https://bugzilla.mozilla.org/show_bug.cgi?id=663480), if you add a `dependencies` line to `package.json`, and you use any modules from -built-in packages like [`addon-kit`](packages/addon-kit/index.html), then +built-in packages like [`addon-kit`]FIXME, then you must also declare your dependency on that built-in package, like this:
diff --git a/doc/dev-guide-source/tutorials/adding-toolbar-button.md b/doc/dev-guide-source/tutorials/adding-toolbar-button.md
index 31f08dbae..c5e34d1dc 100644
--- a/doc/dev-guide-source/tutorials/adding-toolbar-button.md
+++ b/doc/dev-guide-source/tutorials/adding-toolbar-button.md
@@ -12,7 +12,7 @@ and learned the
 
 
 To add a button to the toolbar, use the
-[`widget`](packages/addon-kit/widget.html) module.
+[`widget`](modules/sdk/widget.html) module.
 
 Create a new directory, navigate to it, and execute `cfx init`.
 Then open the file called "main.js" in the "lib" directory and
@@ -164,7 +164,7 @@ To learn more about working with panels, see the tutorial on
 ## Learning More ##
 
 To learn more about the widget module, see its
-[API reference documentation](packages/addon-kit/widget.html).
+[API reference documentation](modules/sdk/widget.html).
 
 To learn more about content scripts, see the
 [content scripts guide](dev-guide/guides/content-scripts/index.html).
diff --git a/doc/dev-guide-source/tutorials/annotator/creating.md b/doc/dev-guide-source/tutorials/annotator/creating.md
index 9e8987c2b..f21b7c8d7 100644
--- a/doc/dev-guide-source/tutorials/annotator/creating.md
+++ b/doc/dev-guide-source/tutorials/annotator/creating.md
@@ -119,11 +119,11 @@ version you downloaded.
 The page-mod matches all pages, so each time the user loads a page the page-mod
 emits the `attach` event, which will call the listener function we've assigned
 to `onAttach`. The handler is passed a
-[worker](packages/api-utils/content/worker.html) object. Each worker
+[worker](modules/sdk/content/worker.html) object. Each worker
 represents a channel of communication between the add-on code and any content
 scripts running in that particular page context. For a more detailed discussion
 of the way `page-mod` uses workers, see the
-[page-mod documentation](packages/addon-kit/page-mod.html).
+[page-mod documentation](modules/sdk/page-mod.html).
 
 In the attach handler we do three things:
 
diff --git a/doc/dev-guide-source/tutorials/annotator/storing.md b/doc/dev-guide-source/tutorials/annotator/storing.md
index 27c9f9e3b..c13ce054f 100644
--- a/doc/dev-guide-source/tutorials/annotator/storing.md
+++ b/doc/dev-guide-source/tutorials/annotator/storing.md
@@ -5,7 +5,7 @@
 # Storing Annotations #
 
 Now we are able to create annotations, let's store them using the
-[`simple-storage`](packages/addon-kit/simple-storage.html) module. In
+[`simple-storage`](modules/sdk/simple-storage.html) module. In
 this chapter we will cover three topics relating to persistent storage:
 
 * using `simple-storage` to persist objects
diff --git a/doc/dev-guide-source/tutorials/display-a-popup.md b/doc/dev-guide-source/tutorials/display-a-popup.md
index 7b9e29b7b..1cf0db21b 100644
--- a/doc/dev-guide-source/tutorials/display-a-popup.md
+++ b/doc/dev-guide-source/tutorials/display-a-popup.md
@@ -12,7 +12,7 @@ and learned the
 
 
 To display a popup dialog, use the
-[`panel`](packages/addon-kit/panel.html) module. A panel's content is
+[`panel`](modules/sdk/panel.html) module. A panel's content is
 defined using HTML. You can run content scripts in the panel: although the
 script running in the panel can't directly access your main add-on code,
 you can exchange messages between the panel script and the add-on code.
@@ -145,7 +145,7 @@ in the console.
 ## Learning More ##
 
 To learn more about the `panel` module, see the
-[`panel` API reference](packages/addon-kit/panel.html).
+[`panel` API reference](modules/sdk/panel.html).
 
 To learn more about attaching panels to widgets, see the
-[`widget` API reference](packages/addon-kit/widget.html).
+[`widget` API reference](modules/sdk/widget.html).
diff --git a/doc/dev-guide-source/tutorials/event-targets.md b/doc/dev-guide-source/tutorials/event-targets.md
index f90a8dc57..7ef324878 100644
--- a/doc/dev-guide-source/tutorials/event-targets.md
+++ b/doc/dev-guide-source/tutorials/event-targets.md
@@ -10,8 +10,8 @@ incompatible changes to them in future releases.
 
 The [guide to event-driven programming with the SDK](dev-guide/guides/events.html)
 describes how to consume events: that is, how to listen to events generated
-by event targets. For example, you can listen to [`private-browsing`'s `start` event](packages/addon-kit/private-browsing.html#start) or the
-[`Panel` object's `show` event](packages/addon-kit/panel.html#show).
+by event targets. For example, you can listen to [`private-browsing`'s `start` event](modules/sdk/private-browsing.html#start) or the
+[`Panel` object's `show` event](modules/sdk/panel.html#show).
 
 With the SDK, it's also simple to implement your own event targets.
 This is especially useful if you want to
@@ -65,7 +65,7 @@ the output in the console.
 We can adapt this code into a separate module that exposes the SDK's
 standard event interface.
 
-To do this we'll use the [`event/core`](packages/api-utils/event/core.html)
+To do this we'll use the [`event/core`](modules/sdk/event/core.html)
 module.
 
 Create a new file in "lib" called "bookmarks.js", and add the following code:
@@ -113,7 +113,7 @@ function is implemented by calling the underlying `off()` function.
 
 We can use this module in the same way we use any other module that emits
 module-level events, such as
-[`private-browsing`](packages/addon-kit/private-browsing.html). For example,
+[`private-browsing`](modules/sdk/private-browsing.html). For example,
 we can adapt "main.js" as follows:
 
     var bookmarks = require("./bookmarks");
@@ -142,7 +142,7 @@ Sometimes we want to emit events at the level of individual objects,
 rather than at the level of the module.
 
 To do this, we can inherit from the SDK's
-[`EventTarget`](packages/api-utils/event/target.html) class. `EventTarget`
+[`EventTarget`](modules/sdk/event/target.html) class. `EventTarget`
 provides an implementation of the functions needed to add and remove
 event listeners: `on()`, `once()`, and `removeListener()`.
 
@@ -188,13 +188,13 @@ Open "bookmarks.js" and replace its contents with this code:
 The code to interact with the Places API is the same here. However:
 
 * we're now importing from four modules:
-    * [`event/core`](packages/api-utils/event/core.html) gives us
+    * [`event/core`](modules/sdk/event/core.html) gives us
 `emit()`: note that we don't need `on`, `once`, or `off`,
 since we will use `EventTarget` for adding and removing listeners
-    * [`event/target`](packages/api-utils/event/target.html) gives us
+    * [`event/target`](modules/sdk/event/target.html) gives us
 `EventTarget`, which implements the interface for adding and removing
 listeners
-    * [`heritage`](packages/api-utils/heritage.html) gives us
+    * [`heritage`](modules/sdk/core/heritage.html) gives us
 `Class()`, which we can use to inherit from `EventTarget`
     * `utils/object` gives us `merge()`, which just simplifies setting up the
 `BookmarkManager`'s properties
@@ -236,7 +236,7 @@ To use this event target we can create it and call the `on()`, `once()`, and
 Finally, most event targets accept options of the form "onEvent", where
 "Event" is the capitalized form of the event type. For example, you
 can listen to the
-[`Panel` object's `show` event](packages/addon-kit/panel.html#show)
+[`Panel` object's `show` event](modules/sdk/panel.html#show)
 either by calling:
 
     myPanel.on("show", listenerFunction);
diff --git a/doc/dev-guide-source/tutorials/getting-started-with-cfx.md b/doc/dev-guide-source/tutorials/getting-started-with-cfx.md
index c695835ed..a8aabe3dd 100644
--- a/doc/dev-guide-source/tutorials/getting-started-with-cfx.md
+++ b/doc/dev-guide-source/tutorials/getting-started-with-cfx.md
@@ -101,9 +101,9 @@ logo. Click the icon, and a new tab will open with
 [http://www.mozilla.org/](http://www.mozilla.org/) loaded into it.
 
 This add-on uses two SDK modules: the
-[`widget`](packages/addon-kit/widget.html) module, which enables you
+[`widget`](modules/sdk/widget.html) module, which enables you
 to add buttons to the browser, and the
-[`tabs`](packages/addon-kit/tabs.html) module, which enables you to
+[`tabs`](modules/sdk/tabs.html) module, which enables you to
 perform basic operations with tabs. In this case, we've created a widget
 whose icon is the Mozilla favicon, and added a click handler that loads
 the Mozilla home page in a new tab.
diff --git a/doc/dev-guide-source/tutorials/index.md b/doc/dev-guide-source/tutorials/index.md
index fca5c0072..1e11c69cd 100644
--- a/doc/dev-guide-source/tutorials/index.md
+++ b/doc/dev-guide-source/tutorials/index.md
@@ -93,12 +93,12 @@ on the left for the full list of APIs.
     
       

Open a web page

Open a web page in a new browser tab or window using the - tabs module, and access its content. + tabs module, and access its content.

Get the list of open tabs

- Use the tabs + Use the tabs module to iterate through the currently open tabs, and access their content. @@ -107,7 +107,7 @@ on the left for the full list of APIs.

Listen for page load

- Use the tabs + Use the tabs module to get notified when new web pages are loaded, and access their content. diff --git a/doc/dev-guide-source/tutorials/l10n.md b/doc/dev-guide-source/tutorials/l10n.md index 28930f3ba..d7c403c1d 100644 --- a/doc/dev-guide-source/tutorials/l10n.md +++ b/doc/dev-guide-source/tutorials/l10n.md @@ -307,7 +307,7 @@ info: London is Bob's home town. ## Using Localized Strings in Preferences ## By including a -[`"preferences"` structure in your add-on's "package.json" file](packages/addon-kit/simple-prefs.html ), you can define +[`"preferences"` structure in your add-on's "package.json" file](modules/sdk/simple-prefs.html ), you can define preferences for your add-on that the user can see and edit using Firefox's [Add-ons Manager](https://support.mozilla.org/en-US/kb/Using%20extensions%20with%20Firefox#w_how-to-change-extension-settings). diff --git a/doc/dev-guide-source/tutorials/list-open-tabs.md b/doc/dev-guide-source/tutorials/list-open-tabs.md index 805f95aeb..2c740ab3f 100644 --- a/doc/dev-guide-source/tutorials/list-open-tabs.md +++ b/doc/dev-guide-source/tutorials/list-open-tabs.md @@ -12,10 +12,10 @@ and learned the To list the open tabs, you can iterate over the -[`tabs`](packages/addon-kit/tabs.html) object itself. +[`tabs`](modules/sdk/tabs.html) object itself. The following add-on adds a -[`widget`](packages/addon-kit/widget.html) that logs +[`widget`](modules/sdk/widget.html) that logs the URLs of open tabs when the user clicks it: var widget = require("widget").Widget({ @@ -67,7 +67,7 @@ tabs. The script adds a red border to the tab's document: ## Learning More ## To learn more about working with tabs in the SDK, see the -[`tabs` API reference](packages/addon-kit/tabs.html). +[`tabs` API reference](modules/sdk/tabs.html). To learn more about running scripts in tabs, see the [tutorial on using `tab.attach()`](dev-guide/tutorials/modifying-web-pages-tab.html). diff --git a/doc/dev-guide-source/tutorials/listen-for-page-load.md b/doc/dev-guide-source/tutorials/listen-for-page-load.md index e06953cc9..792c6d419 100644 --- a/doc/dev-guide-source/tutorials/listen-for-page-load.md +++ b/doc/dev-guide-source/tutorials/listen-for-page-load.md @@ -12,7 +12,7 @@ and learned the You can get notifications about new pages loading using the -[`tabs`](packages/addon-kit/tabs.html) module. The following add-on +[`tabs`](modules/sdk/tabs.html) module. The following add-on listens to the tab's built-in `ready` event and just logs the URL of each tab as the user loads it: @@ -48,7 +48,7 @@ and specify "*" as the match-pattern.) ## Learning More ## To learn more about working with tabs in the SDK, see the -[`tabs` API reference](packages/addon-kit/tabs.html). You can listen +[`tabs` API reference](modules/sdk/tabs.html). You can listen for a number of other tab events, including `open`, `close`, and `activate`. To learn more about running scripts in tabs, see the diff --git a/doc/dev-guide-source/tutorials/mobile.md b/doc/dev-guide-source/tutorials/mobile.md index bf413675a..92444b702 100644 --- a/doc/dev-guide-source/tutorials/mobile.md +++ b/doc/dev-guide-source/tutorials/mobile.md @@ -28,16 +28,15 @@ and `cfx xpi` when targeting Firefox Mobile. Right now only the following modules are fully functional: -* [addon-page](packages/addon-kit/addon-page.html) -* [page-mod](packages/addon-kit/page-mod.html) -* [page-worker](packages/addon-kit/page-worker.html) -* [passwords](packages/addon-kit/passwords.html) -* [private-browsing](packages/addon-kit/private-browsing.html) -* [request](packages/addon-kit/request.html) -* [self](packages/addon-kit/self.html) -* [simple-prefs](packages/addon-kit/simple-prefs.html) -* [simple-storage](packages/addon-kit/simple-storage.html) -* [timers](packages/addon-kit/timers.html) +* [page-mod](modules/sdk/page-mod.html) +* [page-worker](modules/sdk/page-worker.html) +* [passwords](modules/sdk/passwords.html) +* [private-browsing](modules/sdk/private-browsing.html) +* [request](modules/sdk/request.html) +* [self](modules/sdk/self.html) +* [simple-prefs](modules/sdk/simple-prefs.html) +* [simple-storage](modules/sdk/simple-storage.html) +* [timers](modules/sdk/timers.html) We're working on adding support for the other modules. diff --git a/doc/dev-guide-source/tutorials/modifying-web-pages-tab.md b/doc/dev-guide-source/tutorials/modifying-web-pages-tab.md index ebeff8f7b..b73997097 100644 --- a/doc/dev-guide-source/tutorials/modifying-web-pages-tab.md +++ b/doc/dev-guide-source/tutorials/modifying-web-pages-tab.md @@ -13,7 +13,7 @@ and learned the To modify the page hosted by a particular tab, load a script into it using the `attach()` method of the -[tab](packages/addon-kit/tabs.html) object. Because their job is +[tab](modules/sdk/tabs.html) object. Because their job is to interact with web content, these scripts are called *content scripts*. Here's a simple example: @@ -147,7 +147,7 @@ To learn more about working with tabs in the SDK, see the [Open a Web Page](dev-guide/tutorials/open-a-web-page.html) tutorial, the [List Open Tabs](dev-guide/tutorials/list-open-tabs.html) -tutorial, and the [`tabs` API reference](packages/addon-kit/tabs.html). +tutorial, and the [`tabs` API reference](modules/sdk/tabs.html). To learn more about content scripts, see the [content scripts guide](dev-guide/guides/content-scripts/index.html). \ No newline at end of file diff --git a/doc/dev-guide-source/tutorials/modifying-web-pages-url.md b/doc/dev-guide-source/tutorials/modifying-web-pages-url.md index 1873887ed..a3341808b 100644 --- a/doc/dev-guide-source/tutorials/modifying-web-pages-url.md +++ b/doc/dev-guide-source/tutorials/modifying-web-pages-url.md @@ -13,7 +13,7 @@ and learned the To modify any pages that match a particular pattern (for example, "http://example.org/") as they are loaded, use the -[`page-mod`](packages/addon-kit/page-mod.html) module. +[`page-mod`](modules/sdk/page-mod.html) module. To create a page-mod you need to specify two things: @@ -52,7 +52,7 @@ alt="ietf.org eaten by page-mod" /> ## Specifying the Match Pattern ## The match pattern uses the -[`match-pattern`](packages/api-utils/match-pattern.html) +[`match-pattern`](modules/sdk/page-mod/match-pattern.html) syntax. You can pass a single match-pattern string, or an array. ## Keeping the Content Script in a Separate File ## @@ -214,14 +214,14 @@ You can't currently use relative URLs in style sheets loaded with by the relative URLs will not be found. To learn more about this, and read about a workaround, see the -[relevant section in the page-mod API documentation](packages/addon-kit/page-mod.html#Working_with_Relative_URLs_in_CSS_Rules). +[relevant section in the page-mod API documentation](modules/sdk/page-mod.html#Working_with_Relative_URLs_in_CSS_Rules).
## Learning More ## To learn more about `page-mod`, see its -[API reference page](packages/addon-kit/page-mod.html). +[API reference page](modules/sdk/page-mod.html). In particular, the `PageMod` constructor takes several additional options to control its behavior: diff --git a/doc/dev-guide-source/tutorials/open-a-web-page.md b/doc/dev-guide-source/tutorials/open-a-web-page.md index 0f725c2a6..d1864dda3 100644 --- a/doc/dev-guide-source/tutorials/open-a-web-page.md +++ b/doc/dev-guide-source/tutorials/open-a-web-page.md @@ -12,13 +12,13 @@ and learned the To open a new web page, you can use the -[`tabs`](packages/addon-kit/tabs.html) module: +[`tabs`](modules/sdk/tabs.html) module: var tabs = require("tabs"); tabs.open("http://www.example.com"); This function is asynchronous, so you don't immediately get back a -[`tab` object](packages/addon-kit/tabs.html#Tab) which you can examine. +[`tab` object](modules/sdk/tabs.html#Tab) which you can examine. To do this, pass a callback function into `open()`. The callback is assigned to the `onReady` property, and will be passed the tab as an argument: @@ -51,7 +51,7 @@ the page which adds a red border to it: ## Learning More ## To learn more about working with tabs in the SDK, see the -[`tabs` API reference](packages/addon-kit/tabs.html). +[`tabs` API reference](modules/sdk/tabs.html). To learn more about running scripts in tabs, see the [tutorial on using `tab.attach()`](dev-guide/tutorials/modifying-web-pages-tab.html). diff --git a/doc/dev-guide-source/tutorials/reusable-modules.md b/doc/dev-guide-source/tutorials/reusable-modules.md index 1731c0763..54c74b871 100644 --- a/doc/dev-guide-source/tutorials/reusable-modules.md +++ b/doc/dev-guide-source/tutorials/reusable-modules.md @@ -16,8 +16,8 @@ file. You can split your code into separate modules with clearly defined interfaces between them. You then import and use these modules from other parts of your add-on using the `require()` statement, in exactly that same way that you import core SDK modules like -[`widget`](packages/addon-kit/widget.html) or -[`panel`](packages/addon-kit/panel.html). +[`widget`](modules/sdk/widget.html) or +[`panel`](modules/sdk/panel.html). It can often make sense to structure a larger or more complex add-on as a collection of modules. This makes the design of the add-on easier to diff --git a/doc/dev-guide-source/tutorials/third-party-apis b/doc/dev-guide-source/tutorials/third-party-apis new file mode 100644 index 000000000..de377532d --- /dev/null +++ b/doc/dev-guide-source/tutorials/third-party-apis @@ -0,0 +1,5 @@ +# Creating Event Emitters # + +The [guide to event-driven programming with the SDK](dev-guide/guides/events.html) describes +how to consume events: that is, how to listen to events generated +by event-emitting objects. \ No newline at end of file diff --git a/doc/dev-guide-source/tutorials/unit-testing.md b/doc/dev-guide-source/tutorials/unit-testing.md index 0a29ffec8..6907f22b8 100644 --- a/doc/dev-guide-source/tutorials/unit-testing.md +++ b/doc/dev-guide-source/tutorials/unit-testing.md @@ -24,7 +24,7 @@ In a web page, you can perform Base64 encoding and decoding using the to the `window` object: since this object is not available in your main add-on code, `atob()` and `btoa()` aren't available either. Using the low-level -[window-utils](packages/api-utils/window-utils.html) module you +[window-utils](modules/sdk/deprecated/window-utils.html) module you can access `window`, enabling you to call these functions. However, it's good practice to encapsulate the code that directly accesses @@ -103,16 +103,16 @@ require("test").run(exports); This file: exports three functions, each of which expects to receive a single argument which is an `assert` object. `assert` is supplied by the -[`test/assert`](packages/api-utils/test/assert.html) module and implements +[`test/assert`](modules/sdk/test/assert.html) module and implements the [CommonJS Unit Testing specification](http://wiki.commonjs.org/wiki/Unit_Testing/1.1). * The first two functions call `atob()` and `btoa()` and use -[`assert.ok()`](packages/api-utils/test/assert.html) +[`assert.ok()`](modules/sdk/test/assert.html) to check that the output is as expected. * The second function tests the module's error-handling code by passing an empty string into `atob()` and using -[`assert.throws()`](packages/api-utils/test/assert.html) +[`assert.throws()`](modules/sdk/test/assert.html) to check that the expected exception is raised. At this point your add-on ought to look like this: @@ -157,7 +157,7 @@ modules called "test_myCode.js" or "testMyCode.js". package * loads any modules whose names start with the word `test-` * calls each exported function whose name starts with "test", passing it -an [`assert`](packages/api-utils/test/assert.html) object as its only argument. +an [`assert`](modules/sdk/test/assert.html) object as its only argument. Obviously, you don't have to pass the `--verbose` option to `cfx` if you don't want to; doing so just makes the output easier to read. diff --git a/packages/addon-kit/docs/addon-page.md b/doc/module-source/sdk/addon-page.md similarity index 100% rename from packages/addon-kit/docs/addon-page.md rename to doc/module-source/sdk/addon-page.md diff --git a/packages/api-utils/docs/base64.md b/doc/module-source/sdk/base64.md similarity index 100% rename from packages/api-utils/docs/base64.md rename to doc/module-source/sdk/base64.md diff --git a/packages/addon-kit/docs/clipboard.md b/doc/module-source/sdk/clipboard.md similarity index 100% rename from packages/addon-kit/docs/clipboard.md rename to doc/module-source/sdk/clipboard.md diff --git a/packages/api-utils/docs/plain-text-console.md b/doc/module-source/sdk/console/plain-text.md similarity index 100% rename from packages/api-utils/docs/plain-text-console.md rename to doc/module-source/sdk/console/plain-text.md diff --git a/packages/api-utils/docs/traceback.md b/doc/module-source/sdk/console/traceback.md similarity index 100% rename from packages/api-utils/docs/traceback.md rename to doc/module-source/sdk/console/traceback.md diff --git a/packages/api-utils/docs/content.md b/doc/module-source/sdk/content/content.md similarity index 78% rename from packages/api-utils/docs/content.md rename to doc/module-source/sdk/content/content.md index 1c25eb449..efe60afcd 100644 --- a/packages/api-utils/docs/content.md +++ b/doc/module-source/sdk/content/content.md @@ -9,7 +9,7 @@ The `content` module exports three different traits [Loader][], [Worker][] and Rather, they are intended to be used by other modules that provide high level APIs to programs or libraries. -[Loader]:packages/api-utils/content/loader.html -[Worker]:packages/api-utils/content/worker.html -[Symbiont]:packages/api-utils/content/symbiont.html +[Loader]:modules/sdk/content/loader.html +[Worker]:modules/sdk/content/worker.html +[Symbiont]:modules/sdk/content/symbiont.html diff --git a/packages/api-utils/docs/content/loader.md b/doc/module-source/sdk/content/loader.md similarity index 98% rename from packages/api-utils/docs/content/loader.md rename to doc/module-source/sdk/content/loader.md index 4d7551696..52c0f1d32 100644 --- a/packages/api-utils/docs/content/loader.md +++ b/doc/module-source/sdk/content/loader.md @@ -9,7 +9,7 @@ validations. Trait is useful for all the compositions providing high level APIs for creating JavaScript contexts that can access web content. Loader is composed from the -[EventEmitter](packages/api-utils/events.html) trait, therefore +[EventEmitter](modules/sdk/deprecated/events.html) trait, therefore instances of Loader and their descendants expose all the public properties exposed by EventEmitter along with additional public properties: diff --git a/packages/api-utils/docs/content/proxy.md b/doc/module-source/sdk/content/proxy.md similarity index 100% rename from packages/api-utils/docs/content/proxy.md rename to doc/module-source/sdk/content/proxy.md diff --git a/packages/api-utils/docs/content/symbiont.md b/doc/module-source/sdk/content/symbiont.md similarity index 97% rename from packages/api-utils/docs/content/symbiont.md rename to doc/module-source/sdk/content/symbiont.md index 5a3d21b2a..d8919b784 100644 --- a/packages/api-utils/docs/content/symbiont.md +++ b/doc/module-source/sdk/content/symbiont.md @@ -40,7 +40,7 @@ Examples See the [panel][] module for a real-world example of usage of this module. -[panel]:packages/addon-kit/panel.html +[panel]:modules/sdk/panel.html Reference --------- @@ -52,14 +52,14 @@ of Symbiont and their descendants expose all the public properties exposed by [Worker][] along with additional public properties that are listed below: -[Worker]:packages/api-utils/content/worker.html +[Worker]:modules/sdk/content/worker.html @constructor Creates a content symbiont. @param options {object} Options for the constructor. Includes all the keys that -the [Worker](packages/api-utils/content/worker.html) +the [Worker](modules/sdk/content/worker.html) constructor accepts and a few more: @prop [frame] {object} diff --git a/packages/api-utils/docs/content/worker.md b/doc/module-source/sdk/content/worker.md similarity index 96% rename from packages/api-utils/docs/content/worker.md rename to doc/module-source/sdk/content/worker.md index b3e17ea7a..c9100695d 100644 --- a/packages/api-utils/docs/content/worker.md +++ b/doc/module-source/sdk/content/worker.md @@ -40,7 +40,7 @@ are listed below. console.log(location); }); -[EventEmitter]:packages/api-utils/events.html +[EventEmitter]:modules/sdk/deprecated/events.html @constructor @@ -65,7 +65,7 @@ Options for the constructor, with the following keys: @property {EventEmitter} -[EventEmitter](packages/api-utils/events.html) object that allows you to: +[EventEmitter](modules/sdk/deprecated/events.html) object that allows you to: * send customized messages to the worker using the `port.emit` function * receive events from the worker using the `port.on` function @@ -94,7 +94,7 @@ The URL of the content. @property {object} If this worker is attached to a content document, returns the related -[tab](packages/addon-kit/tabs.html). +[tab](modules/sdk/tabs.html). diff --git a/packages/addon-kit/docs/context-menu.md b/doc/module-source/sdk/context-menu.md similarity index 99% rename from packages/addon-kit/docs/context-menu.md rename to doc/module-source/sdk/context-menu.md index b7bc3e857..a07b40a9e 100644 --- a/packages/addon-kit/docs/context-menu.md +++ b/doc/module-source/sdk/context-menu.md @@ -122,9 +122,9 @@ exported by the `context-menu` module. match pattern strings. When matchPattern is an array, the context occurs when the menu is invoked on a page whose URL matches any of the patterns. These are the same match pattern strings that you use with - the page-mod + the page-mod include property. - Read more about patterns. + Read more about patterns. @@ -718,7 +718,7 @@ top-level context menu. Creates a context that matches pages with particular URLs. See Specifying Contexts above. @param matchPattern {string,array} - A [match pattern](packages/api-utils/match-pattern.html) string or an array of + A [match pattern](modules/sdk/page-mod/match-pattern.html) string or an array of match pattern strings. diff --git a/packages/api-utils/docs/heritage.md b/doc/module-source/sdk/core/heritage.md similarity index 100% rename from packages/api-utils/docs/heritage.md rename to doc/module-source/sdk/core/heritage.md diff --git a/packages/api-utils/docs/namespace.md b/doc/module-source/sdk/core/namespace.md similarity index 100% rename from packages/api-utils/docs/namespace.md rename to doc/module-source/sdk/core/namespace.md diff --git a/packages/api-utils/docs/promise.md b/doc/module-source/sdk/core/promise.md similarity index 100% rename from packages/api-utils/docs/promise.md rename to doc/module-source/sdk/core/promise.md diff --git a/packages/api-utils/docs/api-utils.md b/doc/module-source/sdk/deprecated/api-utils.md similarity index 100% rename from packages/api-utils/docs/api-utils.md rename to doc/module-source/sdk/deprecated/api-utils.md diff --git a/packages/api-utils/docs/app-strings.md b/doc/module-source/sdk/deprecated/app-strings.md similarity index 100% rename from packages/api-utils/docs/app-strings.md rename to doc/module-source/sdk/deprecated/app-strings.md diff --git a/packages/api-utils/docs/cortex.md b/doc/module-source/sdk/deprecated/cortex.md similarity index 100% rename from packages/api-utils/docs/cortex.md rename to doc/module-source/sdk/deprecated/cortex.md diff --git a/packages/api-utils/docs/errors.md b/doc/module-source/sdk/deprecated/errors.md similarity index 100% rename from packages/api-utils/docs/errors.md rename to doc/module-source/sdk/deprecated/errors.md diff --git a/packages/api-utils/docs/events.md b/doc/module-source/sdk/deprecated/events.md similarity index 100% rename from packages/api-utils/docs/events.md rename to doc/module-source/sdk/deprecated/events.md diff --git a/packages/api-utils/docs/light-traits.md b/doc/module-source/sdk/deprecated/light-traits.md similarity index 100% rename from packages/api-utils/docs/light-traits.md rename to doc/module-source/sdk/deprecated/light-traits.md diff --git a/packages/api-utils/docs/observer-service.md b/doc/module-source/sdk/deprecated/observer-service.md similarity index 100% rename from packages/api-utils/docs/observer-service.md rename to doc/module-source/sdk/deprecated/observer-service.md diff --git a/packages/api-utils/docs/tab-browser.md b/doc/module-source/sdk/deprecated/tab-browser.md similarity index 100% rename from packages/api-utils/docs/tab-browser.md rename to doc/module-source/sdk/deprecated/tab-browser.md diff --git a/packages/api-utils/docs/traits.md b/doc/module-source/sdk/deprecated/traits.md similarity index 100% rename from packages/api-utils/docs/traits.md rename to doc/module-source/sdk/deprecated/traits.md diff --git a/packages/api-utils/docs/window-utils.md b/doc/module-source/sdk/deprecated/window-utils.md similarity index 100% rename from packages/api-utils/docs/window-utils.md rename to doc/module-source/sdk/deprecated/window-utils.md diff --git a/packages/api-utils/docs/event/core.md b/doc/module-source/sdk/event/core.md similarity index 100% rename from packages/api-utils/docs/event/core.md rename to doc/module-source/sdk/event/core.md diff --git a/packages/api-utils/docs/event/target.md b/doc/module-source/sdk/event/target.md similarity index 100% rename from packages/api-utils/docs/event/target.md rename to doc/module-source/sdk/event/target.md diff --git a/packages/api-utils/docs/hidden-frame.md b/doc/module-source/sdk/frame/hidden-frame.md similarity index 100% rename from packages/api-utils/docs/hidden-frame.md rename to doc/module-source/sdk/frame/hidden-frame.md diff --git a/packages/api-utils/docs/frame/utils.md b/doc/module-source/sdk/frame/utils.md similarity index 100% rename from packages/api-utils/docs/frame/utils.md rename to doc/module-source/sdk/frame/utils.md diff --git a/packages/addon-kit/docs/hotkeys.md b/doc/module-source/sdk/hotkeys.md similarity index 100% rename from packages/addon-kit/docs/hotkeys.md rename to doc/module-source/sdk/hotkeys.md diff --git a/packages/api-utils/docs/byte-streams.md b/doc/module-source/sdk/io/byte-streams.md similarity index 100% rename from packages/api-utils/docs/byte-streams.md rename to doc/module-source/sdk/io/byte-streams.md diff --git a/packages/api-utils/docs/file.md b/doc/module-source/sdk/io/file.md similarity index 96% rename from packages/api-utils/docs/file.md rename to doc/module-source/sdk/io/file.md index 9587353ba..5fb2ae053 100644 --- a/packages/api-utils/docs/file.md +++ b/doc/module-source/sdk/io/file.md @@ -23,7 +23,7 @@ if your add-on uses literal Unix-style path specifications, it won't work for users on Windows. To ensure your add-on works for everyone, generate paths using the -[`join`](packages/api-utils/file.html#join(...)) function. Unfortunately +[`join`](modules/sdk/io/file.html#join(...)) function. Unfortunately this API does not currently provide a way to obtain an absolute base path which you could then use with `join`. For now, you need to [`require("chrome")`](dev-guide/tutorials/chrome.html) and use the @@ -112,11 +112,11 @@ more about escaping characters in strings at @returns {stream} If the file is opened in text read-only `mode`, a `TextReader` is returned, and if text write-only mode, a `TextWriter` is returned. See - [`text-streams`](packages/api-utils/text-streams.html) for information on + [`text-streams`](modules/sdk/io/text-streams.html) for information on these text stream objects. If the file is opened in binary read-only `mode`, a `ByteReader` is returned, and if binary write-only mode, a `ByteWriter` is returned. See - [`byte-streams`](packages/api-utils/byte-streams.html) for more + [`byte-streams`](modules/sdk/io/byte-streams.html) for more information on these byte stream objects. Opened files should always be closed after use by calling `close` on the returned stream. diff --git a/packages/api-utils/docs/text-streams.md b/doc/module-source/sdk/io/text-streams.md similarity index 100% rename from packages/api-utils/docs/text-streams.md rename to doc/module-source/sdk/io/text-streams.md diff --git a/packages/addon-kit/docs/l10n.md b/doc/module-source/sdk/l10n.md similarity index 100% rename from packages/addon-kit/docs/l10n.md rename to doc/module-source/sdk/l10n.md diff --git a/packages/api-utils/docs/cuddlefish.md b/doc/module-source/sdk/loader/cuddlefish.md similarity index 100% rename from packages/api-utils/docs/cuddlefish.md rename to doc/module-source/sdk/loader/cuddlefish.md diff --git a/packages/api-utils/docs/sandbox.md b/doc/module-source/sdk/loader/sandbox.md similarity index 100% rename from packages/api-utils/docs/sandbox.md rename to doc/module-source/sdk/loader/sandbox.md diff --git a/packages/api-utils/docs/url/io.md b/doc/module-source/sdk/net/url.md similarity index 85% rename from packages/api-utils/docs/url/io.md rename to doc/module-source/sdk/net/url.md index 0f5ae20fe..3c0e95032 100644 --- a/packages/api-utils/docs/url/io.md +++ b/doc/module-source/sdk/net/url.md @@ -2,11 +2,11 @@ - 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/. --> -The `url/io` module provides functionality for read URLs' content. +The `net/url` module provides functionality for read URLs' content. @function - Reads a URI and returns a [promise](packages/api-utils/promise.html). + Reads a URI and returns a [promise](modules/sdk/core/promise.html). @param uri {string} The URL, as a string, to load. diff --git a/packages/api-utils/docs/xhr.md b/doc/module-source/sdk/net/xhr.md similarity index 100% rename from packages/api-utils/docs/xhr.md rename to doc/module-source/sdk/net/xhr.md diff --git a/packages/addon-kit/docs/notifications.md b/doc/module-source/sdk/notifications.md similarity index 92% rename from packages/addon-kit/docs/notifications.md rename to doc/module-source/sdk/notifications.md index ca120ab29..64cbd4da4 100644 --- a/packages/addon-kit/docs/notifications.md +++ b/doc/module-source/sdk/notifications.md @@ -32,7 +32,7 @@ the console. }); This one displays an icon that's stored in the add-on's `data` directory. (See -the [`self`](packages/addon-kit/self.html) module documentation for more information.) +the [`self`](modules/sdk/self.html) module documentation for more information.) var notifications = require("notifications"); var self = require("self"); @@ -54,7 +54,7 @@ the [`self`](packages/addon-kit/self.html) module documentation for more informa A string to display as the body of the message. @prop [iconURL] {string} The URL of an icon to display inside the message. It may be a remote URL, - a data URI, or a URL returned by the [`self`](packages/addon-kit/self.html) + a data URI, or a URL returned by the [`self`](modules/sdk/self.html) module. @prop [onClick] {function} A function to be called when the user clicks the message. It will be passed diff --git a/packages/addon-kit/docs/page-mod.md b/doc/module-source/sdk/page-mod.md similarity index 94% rename from packages/addon-kit/docs/page-mod.md rename to doc/module-source/sdk/page-mod.md index 0c1cc3df4..3f6a26576 100644 --- a/packages/addon-kit/docs/page-mod.md +++ b/doc/module-source/sdk/page-mod.md @@ -31,7 +31,7 @@ You can modify the document in your script: pageMod.PageMod({ include: "*.mozilla.org", contentScript: 'document.body.innerHTML = ' + - ' "

Page matches ruleset

";' + ' "

Page mpackages_diratches ruleset

";' }); You can supply the content script(s) in one of two ways: @@ -40,7 +40,7 @@ You can supply the content script(s) in one of two ways: * as separate files supplied in your add-on's "data" directory. In this case files are specified by a URL typically constructed using the `url()` method of the -[`self` module's `data` object](packages/addon-kit/self.html#data): +[`self` module's `data` object](modules/sdk/self.html#data): @@ -80,7 +80,7 @@ method. The `PageMod` constructor takes a number of other options to control its behavior, all documented in detail in the -[API Reference](packages/addon-kit/page-mod.html#API Reference) section below: +[API Reference](modules/sdk/page-mod.html#API Reference) section below: * `contentStyle` or `contentStyleFile` list stylesheets to attach. * `contentScriptOptions` defines read-only values accessible to content @@ -103,7 +103,7 @@ by exchanging messages. To do this, you'll need to listen to the page-mod's `attach` event. This event is triggered every time the page-mod's content script is attached to a document. The listener is passed a -[`worker`](packages/api-utils/content/worker.html) object that your add-on +[`worker`](modules/sdk/content/worker.html) object that your add-on can use to send and receive messages. For example, the following add-on retrieves the HTML content of specific @@ -167,7 +167,7 @@ particular the chapter on The `worker` has a `tab` property which returns the tab associated with this worker. You can use this to access -the [`tabs API`](packages/addon-kit/tabs.html) for the tab associated +the [`tabs API`](modules/sdk/tabs.html) for the tab associated with a specific document: var pageMod = require("page-mod"); @@ -234,7 +234,7 @@ For example, we might want to run a script in the context of the currently active tab when the user clicks a widget: to block certain content, to change the font style, or to display the document's DOM structure. -Using the `attach` method of the [`tab`](packages/addon-kit/tabs.html) +Using the `attach` method of the [`tab`](modules/sdk/tabs.html) object, you can attach a set of content scripts to a particular tab. The scripts are executed immediately. @@ -294,7 +294,7 @@ Creates a page-mod. }); You can specify a set of URLs using a - [regular expression](packages/api-utils/match-pattern.html#Regular Expressions). + [regular expression](modules/sdk/page-mod/match-pattern.html#Regular Expressions). The pattern must match the entire URL, not just a subset, and has `global`, `ignoreCase`, and `multiline` disabled. @@ -312,7 +312,7 @@ Creates a page-mod. contentScript: 'window.alert("Page matches ruleset");' }); - See the [match-pattern](packages/api-utils/match-pattern.html) module for + See the [match-pattern](modules/sdk/page-mod/match-pattern.html) module for a detailed description of match pattern syntax. @prop [contentScriptFile] {string,array} @@ -322,7 +322,7 @@ Creates a page-mod. Each script is supplied as a separate file under your add-on's "data" directory, and is specified by a URL typically constructed using the `url()` method of the - [`self` module's `data` object](packages/addon-kit/self.html#data). + [`self` module's `data` object](modules/sdk/self.html#data). var data = require("self").data; var pageMod = require("page-mod"); @@ -445,7 +445,7 @@ secure, debug and review.

Each stylesheet is supplied as a separate file under your add-on's "data" directory, and is specified by a URL typically constructed using the `url()` method of the - [`self` module's `data` object](packages/addon-kit/self.html#data). + [`self` module's `data` object](modules/sdk/self.html#data). To add multiple stylesheet files, pass an array of URLs. var data = require("self").data; @@ -556,14 +556,14 @@ secure, debug and review.

@prop [onAttach] {function} Assign a listener function to this option to listen to the page-mod's `attach` event. See the - [documentation for `attach`](packages/addon-kit/page-mod.html#attach) and - [Communicating With Content Scripts](packages/addon-kit/page-mod.html#Communicating With Content Scripts). + [documentation for `attach`](modules/sdk/page-mod.html#attach) and + [Communicating With Content Scripts](modules/sdk/page-mod.html#Communicating With Content Scripts).
@property {List} - A [list](packages/api-utils/list.html) of match pattern strings. These + A [list](modules/sdk/util/list.html) of match pattern strings. These define the documents to which the page-mod applies. See the documentation of the `include` option above for details of `include` syntax. Rules can be added to the list by calling its @@ -587,9 +587,9 @@ secure, debug and review.

attached to a document whose URL matches the page-mod's `include` pattern. The listener function is passed a - [`worker`](packages/api-utils/content/worker.html) object that you + [`worker`](modules/sdk/content/worker.html) object that you can use to - [communicate with the content scripts](packages/addon-kit/page-mod.html#Communicating With Content Scripts) your page-mod has + [communicate with the content scripts](modules/sdk/page-mod.html#Communicating With Content Scripts) your page-mod has loaded into this particular document. The `attach` event is triggered every time this page-mod's content @@ -602,7 +602,7 @@ secure, debug and review.

particular document. @argument {Worker} - The listener function is passed a [`Worker`](packages/api-utils/content/worker.html) + The listener function is passed a [`Worker`](modules/sdk/content/worker.html) object that can be used to communicate with any content scripts attached to this document.
diff --git a/packages/api-utils/docs/match-pattern.md b/doc/module-source/sdk/page-mod/match-pattern.md similarity index 100% rename from packages/api-utils/docs/match-pattern.md rename to doc/module-source/sdk/page-mod/match-pattern.md diff --git a/packages/addon-kit/docs/page-worker.md b/doc/module-source/sdk/page-worker.md similarity index 97% rename from packages/addon-kit/docs/page-worker.md rename to doc/module-source/sdk/page-worker.md index fefb7db18..5a59feaf5 100644 --- a/packages/addon-kit/docs/page-worker.md +++ b/doc/module-source/sdk/page-worker.md @@ -12,7 +12,7 @@ worker. A page worker may be destroyed, after which its memory is freed, and you must create a new instance to load another page. You specify the page to load using the `contentURL` option to the -[`Page()` constructor](packages/addon-kit/page-worker.html#Page(options)). +[`Page()` constructor](modules/sdk/page-worker.html#Page(options)). This can point to a remote file: pageWorker = require("page-worker").Page({ @@ -23,7 +23,7 @@ This can point to a remote file: It can also point to an HTML file which you've packaged with your add-on. To do this, save the file in your add-on's `data` directory and create the URL using the `data.url()` method of the -[`self`](packages/addon-kit/self.html) module: +[`self`](modules/sdk/self.html) module: pageWorker = require("page-worker").Page({ contentScript: "console.log(document.body.innerHTML);", @@ -55,12 +55,12 @@ interacting with web content. You can specify one or more content scripts to load into the page using the `contentScript` or `contentScriptFile` options to the -[`Page()` constructor](packages/addon-kit/page-worker.html#Page(options)). +[`Page()` constructor](modules/sdk/page-worker.html#Page(options)). With `contentScript` you pass the script as a string, as in the examples above. With `contentScriptFile` you pass a URL which points to a script saved under your add-on's `data` directory. You construct the URL using the `data.url()` method of the -[`self`](packages/addon-kit/self.html) module. +[`self`](modules/sdk/self.html) module. While content scripts can access DOM content, they can't access any of the SDK APIs, so in many cases you'll need to exchange messages between the content @@ -68,7 +68,7 @@ script and your main add-on code for a complete solution. For example, the content script might read some content and send it back to the main add-on, which could store it using the -[`simple-storage`](packages/addon-kit/simple-storage.html) API. You can +[`simple-storage`](modules/sdk/simple-storage.html) API. You can communicate with the script using either the [`postMessage()`](dev-guide/guides/content-scripts/using-postmessage.html) API or (preferably, usually) the @@ -216,7 +216,7 @@ loaded until its `destroy` method is called or the add-on is unloaded. @property {EventEmitter} -[EventEmitter](packages/api-utils/events.html) object that allows you to: +[EventEmitter](modules/sdk/deprecated/events.html) object that allows you to: * send events to the content script using the `port.emit` function * receive events from the content script using the `port.on` function diff --git a/packages/addon-kit/docs/panel.md b/doc/module-source/sdk/panel.md similarity index 99% rename from packages/addon-kit/docs/panel.md rename to doc/module-source/sdk/panel.md index 27a5cac94..72e407a32 100644 --- a/packages/addon-kit/docs/panel.md +++ b/doc/module-source/sdk/panel.md @@ -53,7 +53,7 @@ You can also load HTML that's been packaged with your add-on, and this is most probably how you will create dialogs. To do this, save the HTML in your add-on's `data` directory and load it using the `data.url()` method exported by the -[`self`](packages/addon-kit/self.html) module, like this: +[`self`](modules/sdk/self.html) module, like this: var panel = require("panel").Panel({ contentURL: require("self").data.url("myFile.html") @@ -111,7 +111,7 @@ have to send messages between the content script and the main add-on code. * You can specify one or more content scripts to load into a panel using the `contentScript` or `contentScriptFile` options to the -[`Panel()` constructor](packages/addon-kit/panel.html#Panel%28options%29). +[`Panel()` constructor](modules/sdk/panel.html#Panel%28options%29). * You can communicate with the script using either the [`postMessage()`](dev-guide/guides/content-scripts/using-postmessage.html) @@ -452,7 +452,7 @@ Creates a panel. @property {EventEmitter} -[EventEmitter](packages/api-utils/events.html) object that allows you to: +[EventEmitter](modules/sdk/deprecated/events.html) object that allows you to: * send events to the content script using the `port.emit` function * receive events from the content script using the `port.on` function diff --git a/packages/addon-kit/docs/passwords.md b/doc/module-source/sdk/passwords.md similarity index 99% rename from packages/addon-kit/docs/passwords.md rename to doc/module-source/sdk/passwords.md index 8ee610982..d8febb012 100644 --- a/packages/addon-kit/docs/passwords.md +++ b/doc/module-source/sdk/passwords.md @@ -83,7 +83,7 @@ They contain the following properties: automatically generated for you. However, you can use it to work out which stored credentials belong to your add-on by comparing it with the uri property of the - self + self module.

diff --git a/packages/api-utils/docs/xpcom.md b/doc/module-source/sdk/platform/xpcom.md similarity index 95% rename from packages/api-utils/docs/xpcom.md rename to doc/module-source/sdk/platform/xpcom.md index a7e018378..9f567fa42 100644 --- a/packages/api-utils/docs/xpcom.md +++ b/doc/module-source/sdk/platform/xpcom.md @@ -13,9 +13,9 @@ object, and The `xpcom` module makes it simpler to perform three main tasks: -* [Implement XPCOM object interfaces](packages/api-utils/xpcom.html#Implementing XPCOM Interfaces) -* [Implement and register XPCOM factories](packages/api-utils/xpcom.html#Implementing XPCOM Factories) -* [Implement and register XPCOM services](packages/api-utils/xpcom.html#Implementing XPCOM Services) +* [Implement XPCOM object interfaces](modules/sdk/platform/xpcom.html#Implementing XPCOM Interfaces) +* [Implement and register XPCOM factories](modules/sdk/platform/xpcom.html#Implementing XPCOM Factories) +* [Implement and register XPCOM services](modules/sdk/platform/xpcom.html#Implementing XPCOM Services) ## Implementing XPCOM Interfaces ## @@ -27,7 +27,7 @@ XPCOM interface [`nsISupports`](https://developer.mozilla.org/docs/XPCOM_Interface_Reference/nsISupports). By subclassing `Unknown`, either using [standard JavaScript inheritance](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Inheritance_Revisited) -or using the SDK's [`heritage`](packages/api-utils/heritage.html) +or using the SDK's [`heritage`](modules/sdk/core/heritage.html) module, you can provide your own implementations of XPCOM interfaces. For example, the add-on below implements the @@ -159,7 +159,7 @@ technique: By default, factories are registered and unregistered automatically. To learn more about this, see -[Registering and Unregistering](packages/api-utils/xpcom.html#Registering and Unregistering). +[Registering and Unregistering](modules/sdk/platform/xpcom.html#Registering and Unregistering). ## Implementing XPCOM Services ## @@ -203,7 +203,7 @@ After this, XPCOM users can access the service using the `getService()` API: By default, services are registered and unregistered automatically. To learn more about this, see -[Registering and Unregistering](packages/api-utils/xpcom.html#Registering and Unregistering). +[Registering and Unregistering](modules/sdk/platform/xpcom.html#Registering and Unregistering). ## Registering and Unregistering ## @@ -246,7 +246,7 @@ This is the base class for all XPCOM objects. It is not intended to be used directly but you can subclass it, either using [standard JavaScript inheritance](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Inheritance_Revisited) -or using the SDK's [`heritage`](packages/api-utils/heritage.html) +or using the SDK's [`heritage`](modules/sdk/core/heritage.html) module, to create new implementations of XPCOM interfaces. For example, this subclass implements the [`nsIRequest`](https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/NsIRequest) @@ -306,7 +306,7 @@ searches for the identifier in the `interfaces` property of: * any of this object's ancestors * any classes in the `implements` array property of the instance (for example, any classes added to this object via the `implements` -option defined in [`heritage`](packages/api-utils/heritage.html)). +option defined in [`heritage`](modules/sdk/core/heritage.html)). If it finds a match, it returns `this`, otherwise it throws [`Components.results.NS_ERROR_NO_INTERFACE`](https://developer.mozilla.org/en-US/docs/Table_Of_Errors). @@ -357,8 +357,8 @@ contract ID and class ID are accessible as the values of the `contract` and unregistered when the add-on that created it is unloaded. To override this behavior, you can pass `register` and/or `unregister` options, set to `false`. If you do this, you can use the -[`register()`](packages/api-utils/xpcom.html#register(factory)) and -[`unregister()`](packages/api-utils/xpcom.html#unregister(factory)) functions +[`register()`](modules/sdk/platform/xpcom.html#register(factory)) and +[`unregister()`](modules/sdk/platform/xpcom.html#unregister(factory)) functions to register and unregister. @@ -447,7 +447,7 @@ implementations it does nothing interesting. @method See the documentation for -[`Unknown.QueryInterface()`](packages/api-utils/xpcom.html#QueryInterface(interface)). +[`Unknown.QueryInterface()`](modules/sdk/platform/xpcom.html#QueryInterface(interface)). @@ -495,7 +495,7 @@ supplying the contract ID: The `Service` interface is identical to the `Factory` interface, so refer to the -[`Factory` interface documentation](packages/api-utils/xpcom.html#Factory) +[`Factory` interface documentation](modules/sdk/platform/xpcom.html#Factory) for details. diff --git a/packages/api-utils/docs/preferences-service.md b/doc/module-source/sdk/preferences/service.md similarity index 100% rename from packages/api-utils/docs/preferences-service.md rename to doc/module-source/sdk/preferences/service.md diff --git a/packages/addon-kit/docs/private-browsing.md b/doc/module-source/sdk/private-browsing.md similarity index 100% rename from packages/addon-kit/docs/private-browsing.md rename to doc/module-source/sdk/private-browsing.md diff --git a/packages/api-utils/docs/querystring.md b/doc/module-source/sdk/querystring.md similarity index 100% rename from packages/api-utils/docs/querystring.md rename to doc/module-source/sdk/querystring.md diff --git a/packages/addon-kit/docs/request.md b/doc/module-source/sdk/request.md similarity index 100% rename from packages/addon-kit/docs/request.md rename to doc/module-source/sdk/request.md diff --git a/packages/addon-kit/docs/selection.md b/doc/module-source/sdk/selection.md similarity index 100% rename from packages/addon-kit/docs/selection.md rename to doc/module-source/sdk/selection.md diff --git a/packages/addon-kit/docs/self.md b/doc/module-source/sdk/self.md similarity index 100% rename from packages/addon-kit/docs/self.md rename to doc/module-source/sdk/self.md diff --git a/packages/addon-kit/docs/simple-prefs.md b/doc/module-source/sdk/simple-prefs.md similarity index 97% rename from packages/addon-kit/docs/simple-prefs.md rename to doc/module-source/sdk/simple-prefs.md index 209b08617..13973ea39 100644 --- a/packages/addon-kit/docs/simple-prefs.md +++ b/doc/module-source/sdk/simple-prefs.md @@ -64,7 +64,7 @@ These are attributes that all settings *must* have. type The type of setting, as defined in the - "Setting Types" + "Setting Types" section below. @@ -116,7 +116,7 @@ These are attributes that all settings *may* have: These are settings that are only applicable to certain setting types. They are documented along with the -[setting types themselves](packages/addon-kit/simple-prefs.html#Setting_Types). +[setting types themselves](modules/sdk/simple-prefs.html#Setting_Types). ## Setting Types ## diff --git a/packages/addon-kit/docs/simple-storage.md b/doc/module-source/sdk/simple-storage.md similarity index 99% rename from packages/addon-kit/docs/simple-storage.md rename to doc/module-source/sdk/simple-storage.md index bbe9cbe32..ab95fa10e 100644 --- a/packages/addon-kit/docs/simple-storage.md +++ b/doc/module-source/sdk/simple-storage.md @@ -177,7 +177,7 @@ While private browsing mode is active, you should not store any sensitive data. Because any kind of data can be placed into simple storage, support for private browsing is not built into the module. Instead, use the -[`private-browsing`](packages/addon-kit/private-browsing.html) module to +[`private-browsing`](modules/sdk/private-browsing.html) module to check private browsing status and respond accordingly. For example, the URLs your users visit should not be stored during private diff --git a/packages/api-utils/docs/environment.md b/doc/module-source/sdk/system/environment.md similarity index 100% rename from packages/api-utils/docs/environment.md rename to doc/module-source/sdk/system/environment.md diff --git a/packages/api-utils/docs/runtime.md b/doc/module-source/sdk/system/runtime.md similarity index 100% rename from packages/api-utils/docs/runtime.md rename to doc/module-source/sdk/system/runtime.md diff --git a/packages/api-utils/docs/unload.md b/doc/module-source/sdk/system/unload.md similarity index 100% rename from packages/api-utils/docs/unload.md rename to doc/module-source/sdk/system/unload.md diff --git a/packages/api-utils/docs/xul-app.md b/doc/module-source/sdk/system/xul-app.md similarity index 100% rename from packages/api-utils/docs/xul-app.md rename to doc/module-source/sdk/system/xul-app.md diff --git a/packages/addon-kit/docs/tabs.md b/doc/module-source/sdk/tabs.md similarity index 100% rename from packages/addon-kit/docs/tabs.md rename to doc/module-source/sdk/tabs.md diff --git a/packages/api-utils/docs/test/assert.md b/doc/module-source/sdk/test/assert.md similarity index 100% rename from packages/api-utils/docs/test/assert.md rename to doc/module-source/sdk/test/assert.md diff --git a/packages/test-harness/docs/harness.md b/doc/module-source/sdk/test/harness.md similarity index 100% rename from packages/test-harness/docs/harness.md rename to doc/module-source/sdk/test/harness.md diff --git a/packages/api-utils/docs/httpd.md b/doc/module-source/sdk/test/httpd.md similarity index 100% rename from packages/api-utils/docs/httpd.md rename to doc/module-source/sdk/test/httpd.md diff --git a/packages/test-harness/docs/run-tests.md b/doc/module-source/sdk/test/runner.md similarity index 100% rename from packages/test-harness/docs/run-tests.md rename to doc/module-source/sdk/test/runner.md diff --git a/packages/addon-kit/docs/timers.md b/doc/module-source/sdk/timers.md similarity index 100% rename from packages/addon-kit/docs/timers.md rename to doc/module-source/sdk/timers.md diff --git a/packages/api-utils/docs/url.md b/doc/module-source/sdk/url.md similarity index 100% rename from packages/api-utils/docs/url.md rename to doc/module-source/sdk/url.md diff --git a/packages/api-utils/docs/collection.md b/doc/module-source/sdk/util/collection.md similarity index 100% rename from packages/api-utils/docs/collection.md rename to doc/module-source/sdk/util/collection.md diff --git a/packages/api-utils/docs/deprecate.md b/doc/module-source/sdk/util/deprecate.md similarity index 100% rename from packages/api-utils/docs/deprecate.md rename to doc/module-source/sdk/util/deprecate.md diff --git a/packages/api-utils/docs/list.md b/doc/module-source/sdk/util/list.md similarity index 100% rename from packages/api-utils/docs/list.md rename to doc/module-source/sdk/util/list.md diff --git a/packages/api-utils/docs/uuid.md b/doc/module-source/sdk/util/uuid.md similarity index 100% rename from packages/api-utils/docs/uuid.md rename to doc/module-source/sdk/util/uuid.md diff --git a/packages/addon-kit/docs/widget.md b/doc/module-source/sdk/widget.md similarity index 97% rename from packages/addon-kit/docs/widget.md rename to doc/module-source/sdk/widget.md index 6c7741351..e3b6219a7 100644 --- a/packages/addon-kit/docs/widget.md +++ b/doc/module-source/sdk/widget.md @@ -12,7 +12,7 @@ consistent with other add-ons and blends in well with Firefox. "Widgets" are small pieces of content that live in the Firefox 4 [add-on bar](https://developer.mozilla.org/en/The_add-on_bar). They can be simple icons or complex web pages. You can attach -[panels](packages/addon-kit/panel.html) to them that open when they're +[panels](modules/sdk/panel.html) to them that open when they're clicked, or you can define a custom click handler to perform some other action, like opening a web page in a tab. @@ -48,7 +48,7 @@ alt="Widget displaying an icon"> You can make `contentURL` point to an HTML or icon file which you have packaged inside your add-on. Just save the file in your add-on's `data` directory, and reference it using the `data.url()` method of the -[`self`](packages/addon-kit/self.html) module: +[`self`](modules/sdk/self.html) module: var data = require("self").data; @@ -85,7 +85,7 @@ have to send messages between the content script and the main add-on code. * You can specify one or more content scripts to load into the widget using the `contentScript` or `contentScriptFile` options to the -[`Widget()` constructor](packages/addon-kit/widget.html#Widget(options)). +[`Widget()` constructor](modules/sdk/widget.html#Widget(options)). * You can communicate with the script using either the [`postMessage()`](dev-guide/guides/content-scripts/using-postmessage.html) @@ -276,7 +276,7 @@ Finally, remove the line attaching the content script from "main.js": ## Attaching Panels to Widgets ## -You can supply a [panel](packages/addon-kit/panel.html) to the widget's +You can supply a [panel](modules/sdk/panel.html) to the widget's constructor: if you do this, the panel is automatically displayed when the user clicks the widget. @@ -483,7 +483,7 @@ Represents a widget object. If the content is an image, it is automatically scaled to be 16x16 pixels. @prop [panel] {Panel} - An optional [panel](packages/addon-kit/panel.html) to open when the + An optional [panel](modules/sdk/panel.html) to open when the user clicks on the widget. Note: If you also register a "click" listener, it will be called instead of the panel being opened. However, you can show the panel from the listener by calling `this.panel.show()`. @@ -587,7 +587,7 @@ Represents a widget object. @method Retrieve a `WidgetView` instance of this widget relative to a browser window. @param window {BrowserWindow} - The [BrowserWindow](packages/addon-kit/windows.html) instance to match. + The [BrowserWindow](modules/sdk/windows.html) instance to match. @returns {WidgetView} A `WidgetView` instance associated with the browser window. Any changes subsequently applied to this object will only be applied to the widget @@ -618,7 +618,7 @@ Represents a widget object. @property {Panel} - A [panel](packages/addon-kit/panel.html) to open when the user clicks on + A [panel](modules/sdk/panel.html) to open when the user clicks on the widget. @@ -680,7 +680,7 @@ Optional. @property {EventEmitter} -[EventEmitter](packages/api-utils/events.html) object that allows you to: +[EventEmitter](modules/sdk/deprecated/events.html) object that allows you to: * send events to the content script using the `port.emit` function * receive events from the content script using the `port.on` function @@ -823,7 +823,7 @@ In this example `WidgetView` is used to display different content for @property {Panel} - A [panel](packages/addon-kit/panel.html) to open when the user clicks on + A [panel](modules/sdk/panel.html) to open when the user clicks on the widget view. @@ -886,7 +886,7 @@ Optional. @property {EventEmitter} -[EventEmitter](packages/api-utils/events.html) object that allows you to: +[EventEmitter](modules/sdk/deprecated/events.html) object that allows you to: * send events to the content script using the `port.emit` function * receive events from the content script using the `port.on` diff --git a/packages/api-utils/docs/window/utils.md b/doc/module-source/sdk/window/utils.md similarity index 100% rename from packages/api-utils/docs/window/utils.md rename to doc/module-source/sdk/window/utils.md diff --git a/packages/addon-kit/docs/windows.md b/doc/module-source/sdk/windows.md similarity index 97% rename from packages/addon-kit/docs/windows.md rename to doc/module-source/sdk/windows.md index 8067cd836..899f623c8 100644 --- a/packages/addon-kit/docs/windows.md +++ b/doc/module-source/sdk/windows.md @@ -172,7 +172,7 @@ This property is read-only. @property {TabList} A live list of tabs in this window. This object has the same interface as the -[`tabs` API](packages/addon-kit/tabs.html), except it contains only the +[`tabs` API](modules/sdk/tabs.html), except it contains only the tabs in this window, not all tabs in all windows. This property is read-only. @@ -232,7 +232,7 @@ Listeners are passed the `window` object that has become inactive. @event Event emitted when a window's private-browsing mode changes. -Check the window's [`isPrivateBrowsing`](packages/addon-kit/windows.html#isPrivateBrowsing) +Check the window's [`isPrivateBrowsing`](modules/sdk/windows.html#isPrivateBrowsing) property to determine the window is in private browsing mode or not. @argument {Window} diff --git a/packages/api-utils/docs/loader.md b/doc/module-source/toolkit/loader.md similarity index 97% rename from packages/api-utils/docs/loader.md rename to doc/module-source/toolkit/loader.md index e19471fa0..ea31124ae 100644 --- a/packages/api-utils/docs/loader.md +++ b/doc/module-source/toolkit/loader.md @@ -51,12 +51,12 @@ to instantiate new loader instances: `Loader()` may be provided with a set of configuration options: -* [`paths`](packages/api-utils/loader.html#paths): describes where the loader should +* [`paths`](modules/toolkit/loader.html#paths): describes where the loader should find the modules it is asked to load. **Mandatory**. -* [`modules`](packages/api-utils/loader.html#modules): provides a set of module exports. **Optional**. -* [`globals`](packages/api-utils/loader.html#globals): provides a set of globals shared across modules loaded +* [`modules`](modules/toolkit/loader.html#modules): provides a set of module exports. **Optional**. +* [`globals`](modules/toolkit/loader.html#globals): provides a set of globals shared across modules loaded via this loader. **Optional**. -* [`resolve`](packages/api-utils/loader.html#resolve): provide customized module resolution logic. **Optional**. +* [`resolve`](modules/toolkit/loader.html#resolve): provide customized module resolution logic. **Optional**. ### paths @@ -127,7 +127,7 @@ This feature may be used in a few different ways: } }); Each loader instance comes with a set of built-in pseudo modules - that are described in detail in the [Built-in Modules](packages/api-utils/loader.html#Built-in_Modules) section. + that are described in detail in the [Built-in Modules](modules/toolkit/loader.html#Built-in_Modules) section. 2. To reuse module instances that are already loaded. For example in the SDK, the loader is loaded at bootstrap as a JSM module @@ -466,7 +466,7 @@ Optionally more options may be specified: ### Require() As already mentioned in -[Loading Modules](packages/api-utils/loader.html#Loading_Modules) +[Loading Modules](modules/toolkit/loader.html#Loading_Modules) it's common to start execution by loading a main module. But sometimes you may want to prepare the environment using existing modules before doing that. In such cases you can create a diff --git a/doc/static-files/base.html b/doc/static-files/base.html index c6d269631..ed2b325c5 100644 --- a/doc/static-files/base.html +++ b/doc/static-files/base.html @@ -93,24 +93,17 @@

- - diff --git a/doc/static-files/css/sdk-docs.css b/doc/static-files/css/sdk-docs.css index 639150e6c..a4a892c94 100644 --- a/doc/static-files/css/sdk-docs.css +++ b/doc/static-files/css/sdk-docs.css @@ -338,7 +338,7 @@ hr { .sidebar-subsection-contents a { display: block; text-decoration: none; - padding: 1px 15px; + padding: 1px 10px; } .modules a { @@ -349,7 +349,7 @@ hr { background-color: white; border-color: #a0d0fb; border: solid 1px; - padding: 0px 14px; + padding: 0px 9px; border-color: #a0d0fb; } diff --git a/doc/static-files/js/main.js b/doc/static-files/js/main.js index 1c8f34c65..122a5b97e 100644 --- a/doc/static-files/js/main.js +++ b/doc/static-files/js/main.js @@ -4,12 +4,6 @@ function run(jQuery) { - function showThirdPartyModules() { - if ($("#third-party-package-summaries").html() != "") { - $("#third-party-packages-subsection").show(); - } - } - function highlightCode() { $("code").parent("pre").addClass("brush: js"); //remove the inner tags @@ -101,7 +95,6 @@ function run(jQuery) { searchBox.blur(); } - showThirdPartyModules(); highlightCode(); $(".syntaxhighlighter").width("auto"); generateAnchors(); diff --git a/packages/addon-kit/lib/addon-page.js b/lib/sdk/addon-page.js similarity index 77% rename from packages/addon-kit/lib/addon-page.js rename to lib/sdk/addon-page.js index 569665f15..6440b2515 100644 --- a/packages/addon-kit/lib/addon-page.js +++ b/lib/sdk/addon-page.js @@ -7,11 +7,11 @@ module.metadata = { 'stability': 'experimental' }; -const { WindowTracker } = require('api-utils/window-utils'); -const { isXULBrowser } = require('api-utils/window/utils'); -const { add, remove } = require('api-utils/array'); -const { getTabs, closeTab, getURI } = require('api-utils/tabs/utils'); -const { data } = require('self'); +const { WindowTracker } = require('./deprecated/window-utils'); +const { isXULBrowser } = require('./window/utils'); +const { add, remove } = require('./util/array'); +const { getTabs, closeTab, getURI } = require('./tabs/utils'); +const { data } = require('./self'); const addonURL = data.url('index.html'); diff --git a/packages/api-utils/lib/addon/installer.js b/lib/sdk/addon/installer.js similarity index 96% rename from packages/api-utils/lib/addon/installer.js rename to lib/sdk/addon/installer.js index ff03d95df..f72b21e0a 100644 --- a/packages/api-utils/lib/addon/installer.js +++ b/lib/sdk/addon/installer.js @@ -8,8 +8,8 @@ module.metadata = { const { Cc, Ci, Cu } = require("chrome"); const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm"); -const { defer } = require("api-utils/promise"); -const { setTimeout } = require("api-utils/timer"); +const { defer } = require("../core/promise"); +const { setTimeout } = require("../timers"); /** * `install` method error codes: diff --git a/packages/api-utils/lib/addon/runner.js b/lib/sdk/addon/runner.js similarity index 94% rename from packages/api-utils/lib/addon/runner.js rename to lib/sdk/addon/runner.js index 0ca52d1b4..0552de28d 100644 --- a/packages/api-utils/lib/addon/runner.js +++ b/lib/sdk/addon/runner.js @@ -9,13 +9,13 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'); -const { descriptor, Sandbox, evaluate, main, resolveURI } = require('api-utils/loader'); +const { descriptor, Sandbox, evaluate, main, resolveURI } = require('toolkit/loader'); const { once } = require('../system/events'); const { exit, env, staticArgs, name } = require('../system'); -const { when: unload } = require('../unload'); -const { loadReason } = require('self'); +const { when: unload } = require('../system/unload'); +const { loadReason } = require('../self'); const { rootURI } = require("@loader/options"); -const globals = require('../globals'); +const globals = require('../system/globals'); const NAME2TOPIC = { 'Firefox': 'sessionstore-windows-restored', @@ -78,7 +78,7 @@ function startup(reason, options) { // Load localization manifest and .properties files. // Run the addon even in case of error (best effort approach) - require('api-utils/l10n/loader'). + require('../l10n/loader'). load(rootURI). then(null, function failure(error) { console.info("Error while loading localization: " + error.message); @@ -101,7 +101,7 @@ function run(options) { // disable. Because unit tests are evaluated in a another Loader who // doesn't have access to this current loader. if (options.main !== 'test-harness/run-tests') - require('api-utils/l10n/html').enable(); + require('../l10n/html').enable(); } catch(error) { console.exception(error); @@ -109,7 +109,7 @@ function run(options) { // Initialize inline options localization, without preventing addon to be // run in case of error try { - require('api-utils/l10n/prefs'); + require('../l10n/prefs'); } catch(error) { console.exception(error); diff --git a/packages/api-utils/lib/base64.js b/lib/sdk/base64.js similarity index 100% rename from packages/api-utils/lib/base64.js rename to lib/sdk/base64.js diff --git a/packages/addon-kit/lib/clipboard.js b/lib/sdk/clipboard.js similarity index 98% rename from packages/addon-kit/lib/clipboard.js rename to lib/sdk/clipboard.js index 21405313f..58a3d7e45 100644 --- a/packages/addon-kit/lib/clipboard.js +++ b/lib/sdk/clipboard.js @@ -11,9 +11,9 @@ module.metadata = { }; const { Cc, Ci } = require("chrome"); -const { DataURL } = require("api-utils/url"); -const errors = require("api-utils/errors"); -const apiUtils = require("api-utils/api-utils"); +const { DataURL } = require("./url"); +const errors = require("./deprecated/errors"); +const apiUtils = require("./deprecated/api-utils"); /* While these data flavors resemble Internet media types, they do no directly map to them. diff --git a/packages/api-utils/lib/plain-text-console.js b/lib/sdk/console/plain-text.js similarity index 98% rename from packages/api-utils/lib/plain-text-console.js rename to lib/sdk/console/plain-text.js index 6df52f517..9e3b74817 100644 --- a/packages/api-utils/lib/plain-text-console.js +++ b/lib/sdk/console/plain-text.js @@ -9,7 +9,7 @@ module.metadata = { }; const {Cc,Ci} = require("chrome"); -const self = require("self"); +const self = require("../self"); function stringify(arg) { try { diff --git a/packages/api-utils/lib/traceback.js b/lib/sdk/console/traceback.js similarity index 97% rename from packages/api-utils/lib/traceback.js rename to lib/sdk/console/traceback.js index 74d700db1..6b23be1ee 100644 --- a/packages/api-utils/lib/traceback.js +++ b/lib/sdk/console/traceback.js @@ -9,7 +9,7 @@ module.metadata = { }; const { Cc, Ci, components } = require("chrome"); -const { readURISync } = require("./url/io"); +const { readURISync } = require("../net/url"); // Undo the auto-parentification of URLs done in bug 418356. function deParentifyURL(url) { @@ -18,7 +18,7 @@ function deParentifyURL(url) { function safeGetFileLine(path, line) { try { - var scheme = require("./url").URL(path).scheme; + var scheme = require("../url").URL(path).scheme; // TODO: There should be an easier, more accurate way to figure out // what's the case here. if (!(scheme == "http" || scheme == "https")) diff --git a/packages/api-utils/lib/content/content-proxy.js b/lib/sdk/content/content-proxy.js similarity index 100% rename from packages/api-utils/lib/content/content-proxy.js rename to lib/sdk/content/content-proxy.js diff --git a/packages/api-utils/lib/content/content-worker.js b/lib/sdk/content/content-worker.js similarity index 100% rename from packages/api-utils/lib/content/content-worker.js rename to lib/sdk/content/content-worker.js diff --git a/packages/api-utils/lib/content.js b/lib/sdk/content/content.js similarity index 70% rename from packages/api-utils/lib/content.js rename to lib/sdk/content/content.js index 8bdfddf64..4bffd4526 100644 --- a/packages/api-utils/lib/content.js +++ b/lib/sdk/content/content.js @@ -9,7 +9,7 @@ module.metadata = { "stability": "unstable" }; -exports.Loader = require('./content/loader').Loader; -exports.Symbiont = require('./content/symbiont').Symbiont; -exports.Worker = require('./content/worker').Worker; +exports.Loader = require('./loader').Loader; +exports.Symbiont = require('./symbiont').Symbiont; +exports.Worker = require('./worker').Worker; diff --git a/packages/api-utils/lib/content/loader.js b/lib/sdk/content/loader.js similarity index 97% rename from packages/api-utils/lib/content/loader.js rename to lib/sdk/content/loader.js index 2557f179d..b01675c3e 100644 --- a/packages/api-utils/lib/content/loader.js +++ b/lib/sdk/content/loader.js @@ -10,10 +10,10 @@ module.metadata = { "stability": "unstable" }; -const { EventEmitter } = require('../events'); -const { validateOptions } = require('../api-utils'); +const { EventEmitter } = require('../deprecated/events'); +const { validateOptions } = require('../deprecated/api-utils'); const { URL } = require('../url'); -const file = require('../file'); +const file = require('../io/file'); const LOCAL_URI_SCHEMES = ['resource', 'data']; diff --git a/packages/api-utils/lib/content/symbiont.js b/lib/sdk/content/symbiont.js similarity index 96% rename from packages/api-utils/lib/content/symbiont.js rename to lib/sdk/content/symbiont.js index f33f05143..186e9d352 100644 --- a/packages/api-utils/lib/content/symbiont.js +++ b/lib/sdk/content/symbiont.js @@ -11,11 +11,11 @@ module.metadata = { const { Worker } = require('./worker'); const { Loader } = require('./loader'); -const hiddenFrames = require('../hidden-frame'); -const observers = require('../observer-service'); -const unload = require('../unload'); +const hiddenFrames = require('../frame/hidden-frame'); +const observers = require('../deprecated/observer-service'); +const unload = require('../system/unload'); -const assetsURI = require('self').data.url(); +const assetsURI = require('../self').data.url(); /** * This trait is layered on top of `Worker` and in contrast to symbiont diff --git a/packages/api-utils/lib/utils/thumbnail.js b/lib/sdk/content/thumbnail.js similarity index 100% rename from packages/api-utils/lib/utils/thumbnail.js rename to lib/sdk/content/thumbnail.js diff --git a/packages/api-utils/lib/content/worker.js b/lib/sdk/content/worker.js similarity index 97% rename from packages/api-utils/lib/content/worker.js rename to lib/sdk/content/worker.js index e9320dfda..b2f204c29 100644 --- a/packages/api-utils/lib/content/worker.js +++ b/lib/sdk/content/worker.js @@ -9,17 +9,17 @@ module.metadata = { "stability": "unstable" }; -const { Trait } = require('../traits'); -const { EventEmitter, EventEmitterTrait } = require('../events'); +const { Trait } = require('../deprecated/traits'); +const { EventEmitter, EventEmitterTrait } = require('../deprecated/events'); const { Ci, Cu, Cc } = require('chrome'); -const timer = require('../timer'); +const timer = require('../timers'); const { URL } = require('../url'); -const unload = require('../unload'); -const observers = require('../observer-service'); -const { Cortex } = require('../cortex'); -const { sandbox, evaluate, load } = require("../sandbox"); -const { merge } = require('../utils/object'); -const xulApp = require("api-utils/xul-app"); +const unload = require('../system/unload'); +const observers = require('../deprecated/observer-service'); +const { Cortex } = require('../deprecated/cortex'); +const { sandbox, evaluate, load } = require("../loader/sandbox"); +const { merge } = require('../util/object'); +const xulApp = require("../system/xul-app"); const USE_JS_PROXIES = !xulApp.versionInRange(xulApp.platformVersion, "17.0a2", "*"); const { getTabForWindow } = require('../tabs/helpers'); diff --git a/packages/addon-kit/lib/context-menu.js b/lib/sdk/context-menu.js similarity index 98% rename from packages/addon-kit/lib/context-menu.js rename to lib/sdk/context-menu.js index 2a7baa39f..9d20f0b8a 100644 --- a/packages/addon-kit/lib/context-menu.js +++ b/lib/sdk/context-menu.js @@ -12,7 +12,7 @@ module.metadata = { const {Ci} = require("chrome"); -if (!require("api-utils/xul-app").is("Firefox")) { +if (!require("./system/xul-app").is("Firefox")) { throw new Error([ "The context-menu module currently supports only Firefox. In the future ", "we would like it to support other applications, however. Please see ", @@ -20,19 +20,19 @@ if (!require("api-utils/xul-app").is("Firefox")) { ].join("")); } -const apiUtils = require("api-utils/api-utils"); -const collection = require("api-utils/collection"); -const { Worker } = require("api-utils/content"); -const { URL } = require("api-utils/url"); -const { MatchPattern } = require("api-utils/match-pattern"); -const { EventEmitterTrait: EventEmitter } = require("api-utils/events"); -const observerServ = require("api-utils/observer-service"); -const jpSelf = require("self"); -const { WindowTracker } = require("api-utils/window-utils"); -const { getInnerId, isBrowser } = require("api-utils/window/utils"); -const { Trait } = require("api-utils/light-traits"); -const { Cortex } = require("api-utils/cortex"); -const timer = require("timers"); +const apiUtils = require("./deprecated/api-utils"); +const collection = require("./util/collection"); +const { Worker } = require("./content/worker"); +const { URL } = require("./url"); +const { MatchPattern } = require("./page-mod/match-pattern"); +const { EventEmitterTrait: EventEmitter } = require("./deprecated/events"); +const observerServ = require("./deprecated/observer-service"); +const jpSelf = require("./self"); +const { WindowTracker } = require("./deprecated/window-utils"); +const { getInnerId, isBrowser } = require("./window/utils"); +const { Trait } = require("./deprecated/light-traits"); +const { Cortex } = require("./deprecated/cortex"); +const timer = require("./timers"); // All user items we add have this class name. const ITEM_CLASS = "jetpack-context-menu-item"; @@ -842,7 +842,7 @@ let browserManager = { // Note that calling this method will cause onTrack to be called immediately // for each currently open browser window. init: function BM_init() { - require("api-utils/unload").ensure(this); + require("./system/unload").ensure(this); let windowTracker = WindowTracker(this); // Register content windows on content-document-global-created and @@ -1472,7 +1472,7 @@ ContextMenuPopup.prototype = { // Returns the OVERFLOW_THRESH_PREF pref value if it exists or // OVERFLOW_THRESH_DEFAULT if it doesn't. get _overflowThreshold() { - let prefs = require("api-utils/preferences-service"); + let prefs = require("./preferences/service"); return prefs.get(OVERFLOW_THRESH_PREF, OVERFLOW_THRESH_DEFAULT); }, diff --git a/packages/api-utils/lib/heritage.js b/lib/sdk/core/heritage.js similarity index 100% rename from packages/api-utils/lib/heritage.js rename to lib/sdk/core/heritage.js diff --git a/packages/api-utils/lib/namespace.js b/lib/sdk/core/namespace.js similarity index 100% rename from packages/api-utils/lib/namespace.js rename to lib/sdk/core/namespace.js diff --git a/packages/api-utils/lib/promise.js b/lib/sdk/core/promise.js similarity index 100% rename from packages/api-utils/lib/promise.js rename to lib/sdk/core/promise.js diff --git a/packages/api-utils/lib/api-utils.js b/lib/sdk/deprecated/api-utils.js similarity index 99% rename from packages/api-utils/lib/api-utils.js rename to lib/sdk/deprecated/api-utils.js index da217ed37..521ad6ea5 100644 --- a/packages/api-utils/lib/api-utils.js +++ b/lib/sdk/deprecated/api-utils.js @@ -10,7 +10,7 @@ module.metadata = { "stability": "deprecated" }; -const memory = require("api-utils/memory"); +const memory = require("./memory"); // The possible return values of getTypeOf. const VALID_TYPES = [ "array", diff --git a/packages/api-utils/lib/app-strings.js b/lib/sdk/deprecated/app-strings.js similarity index 100% rename from packages/api-utils/lib/app-strings.js rename to lib/sdk/deprecated/app-strings.js diff --git a/packages/api-utils/lib/cortex.js b/lib/sdk/deprecated/cortex.js similarity index 100% rename from packages/api-utils/lib/cortex.js rename to lib/sdk/deprecated/cortex.js diff --git a/packages/api-utils/lib/errors.js b/lib/sdk/deprecated/errors.js similarity index 100% rename from packages/api-utils/lib/errors.js rename to lib/sdk/deprecated/errors.js diff --git a/packages/api-utils/lib/events.js b/lib/sdk/deprecated/events.js similarity index 100% rename from packages/api-utils/lib/events.js rename to lib/sdk/deprecated/events.js diff --git a/packages/api-utils/lib/events/assembler.js b/lib/sdk/deprecated/events/assembler.js similarity index 96% rename from packages/api-utils/lib/events/assembler.js rename to lib/sdk/deprecated/events/assembler.js index 5d11be278..fcde1e312 100644 --- a/packages/api-utils/lib/events/assembler.js +++ b/lib/sdk/deprecated/events/assembler.js @@ -6,7 +6,7 @@ "use strict"; const { Trait } = require("../light-traits"); -const { removeListener, on } = require("../dom/events"); +const { removeListener, on } = require("../../dom/events"); /** * Trait may be used for building objects / composing traits that wish to handle diff --git a/packages/api-utils/lib/light-traits.js b/lib/sdk/deprecated/light-traits.js similarity index 100% rename from packages/api-utils/lib/light-traits.js rename to lib/sdk/deprecated/light-traits.js diff --git a/packages/api-utils/lib/list.js b/lib/sdk/deprecated/list.js similarity index 98% rename from packages/api-utils/lib/list.js rename to lib/sdk/deprecated/list.js index 5c728bcaf..5de69e78c 100644 --- a/packages/api-utils/lib/list.js +++ b/lib/sdk/deprecated/list.js @@ -7,7 +7,7 @@ module.metadata = { "stability": "experimental" }; -const { Trait } = require('./traits'); +const { Trait } = require('../deprecated/traits'); /** * @see https://jetpack.mozillalabs.com/sdk/latest/docs/#module/api-utils/list diff --git a/packages/api-utils/lib/memory.js b/lib/sdk/deprecated/memory.js similarity index 98% rename from packages/api-utils/lib/memory.js rename to lib/sdk/deprecated/memory.js index 9d30cc92d..70bcffc71 100644 --- a/packages/api-utils/lib/memory.js +++ b/lib/sdk/deprecated/memory.js @@ -108,7 +108,7 @@ var gc = exports.gc = function gc() { test_utils.garbageCollect(); }; -require("./unload").when( +require("../system/unload").when( function() { trackedObjects = {}; if (timer) { diff --git a/packages/api-utils/lib/observer-service.js b/lib/sdk/deprecated/observer-service.js similarity index 95% rename from packages/api-utils/lib/observer-service.js rename to lib/sdk/deprecated/observer-service.js index d9373c188..6a25109c0 100644 --- a/packages/api-utils/lib/observer-service.js +++ b/lib/sdk/deprecated/observer-service.js @@ -9,10 +9,10 @@ module.metadata = { }; const { Cc, Ci } = require("chrome"); -const { when: unload } = require("./unload"); -const { ns } = require("./namespace"); -const { on, off, emit, once } = require("./system/events"); -const { id } = require("self"); +const { when: unload } = require("../system/unload"); +const { ns } = require("../core/namespace"); +const { on, off, emit, once } = require("../system/events"); +const { id } = require("../self"); const subscribers = ns(); const cache = []; diff --git a/packages/api-utils/lib/tab-browser.js b/lib/sdk/deprecated/tab-browser.js similarity index 97% rename from packages/api-utils/lib/tab-browser.js rename to lib/sdk/deprecated/tab-browser.js index 431a8cee6..068471c06 100644 --- a/packages/api-utils/lib/tab-browser.js +++ b/lib/sdk/deprecated/tab-browser.js @@ -14,9 +14,9 @@ NetUtil = NetUtil.NetUtil; const errors = require('./errors'); const windowUtils = require('./window-utils'); const apiUtils = require('./api-utils'); -const collection = require('./collection'); -const { getMostRecentBrowserWindow } = require('./window/utils'); -const { getSelectedTab } = require('./tabs/utils'); +const collection = require('../util/collection'); +const { getMostRecentBrowserWindow } = require('../window/utils'); +const { getSelectedTab } = require('../tabs/utils'); // TODO: The hard-coding of app-specific info here isn't very nice; // ideally such app-specific info should be more decoupled, and the @@ -24,7 +24,7 @@ const { getSelectedTab } = require('./tabs/utils'); // runtime, perhaps by inspecting supported packages (e.g. via // dynamically-named modules or package-defined extension points). -if (!require("./xul-app").is("Firefox")) { +if (!require("../system/xul-app").is("Firefox")) { throw new Error([ "The tab-browser module currently supports only Firefox. In the future ", "it will support other applications. Please see ", @@ -36,7 +36,7 @@ function onBrowserLoad(callback, event) { if (event.target && event.target.defaultView == this) { this.removeEventListener("load", onBrowserLoad, true); try { - require("timer").setTimeout(function () { + require("../timers").setTimeout(function () { callback(event); }, 10); } catch (e) { console.exception(e); } @@ -137,7 +137,7 @@ function Tracker(delegate, window) { this._window = window; this._windowTracker = windowUtils.WindowTracker(this); - require("./unload").ensure(this); + require("../system/unload").ensure(this); } Tracker.prototype = { __iterator__: function __iterator__() { @@ -187,7 +187,7 @@ function TabTracker(delegate, window) { this._delegate = delegate; this._tabs = []; this._tracker = new Tracker(this, window); - require("./unload").ensure(this); + require("../system/unload").ensure(this); } TabTracker.prototype = { _TAB_EVENTS: ["TabOpen", "TabClose"], @@ -422,7 +422,7 @@ let TabModule = exports.TabModule = function TabModule(window) { this.tabs.splice(0); } }; - require("./unload").ensure(eventsTabDelegate); + require("../system/unload").ensure(eventsTabDelegate); let eventsTabTracker = new ModuleTabTracker({ onTrack: function TETT_onTrack(tab) { @@ -449,7 +449,7 @@ let TabModule = exports.TabModule = function TabModule(window) { eventsTabDelegate.pushTabEvent("onPaint", tab); } }, window); - require("./unload").ensure(eventsTabTracker); + require("../system/unload").ensure(eventsTabTracker); // Iterator for all tabs this.__iterator__ = function tabsIterator() { @@ -464,7 +464,7 @@ let TabModule = exports.TabModule = function TabModule(window) { // Unregister tabs event listeners events.forEach(function(e) self[e] = []); } - require("./unload").ensure(this); + require("../system/unload").ensure(this); } // End of TabModule constructor @@ -540,7 +540,7 @@ function openURLInNewTab(options, window, tabConstructor) { // for subsequent loads in same tab. tabBrowser.removeEventListener("load", onLoad, true); let tab = tabConstructor(tabEl); - require("./timer").setTimeout(function() { + require("../timers").setTimeout(function() { require("./errors").catchAndLog(function(tab) options.onOpen(tab))(tab); }, 10); }, true); @@ -569,7 +569,7 @@ function ModuleTabTracker(delegate, window) { this._delegate = delegate; this._tabs = []; this._tracker = new Tracker(this, window); - require("./unload").ensure(this); + require("../system/unload").ensure(this); } ModuleTabTracker.prototype = { _TAB_EVENTS: ["TabOpen", "TabClose", "TabSelect", "DOMContentLoaded", diff --git a/packages/api-utils/lib/traits.js b/lib/sdk/deprecated/traits.js similarity index 100% rename from packages/api-utils/lib/traits.js rename to lib/sdk/deprecated/traits.js diff --git a/packages/api-utils/lib/traits/core.js b/lib/sdk/deprecated/traits/core.js similarity index 100% rename from packages/api-utils/lib/traits/core.js rename to lib/sdk/deprecated/traits/core.js diff --git a/packages/api-utils/lib/unit-test-finder.js b/lib/sdk/deprecated/unit-test-finder.js similarity index 96% rename from packages/api-utils/lib/unit-test-finder.js rename to lib/sdk/deprecated/unit-test-finder.js index 5cc655344..880f5544d 100644 --- a/packages/api-utils/lib/unit-test-finder.js +++ b/lib/sdk/deprecated/unit-test-finder.js @@ -8,8 +8,8 @@ module.metadata = { "stability": "deprecated" }; -const file = require("./file"); -const memory = require('api-utils/memory'); +const file = require("../io/file"); +const memory = require('./memory'); const suites = require('@test/options').allTestModules; diff --git a/packages/api-utils/lib/unit-test.js b/lib/sdk/deprecated/unit-test.js similarity index 99% rename from packages/api-utils/lib/unit-test.js rename to lib/sdk/deprecated/unit-test.js index 1e0a10122..6a8ac1b4e 100644 --- a/packages/api-utils/lib/unit-test.js +++ b/lib/sdk/deprecated/unit-test.js @@ -9,8 +9,8 @@ module.metadata = { "stability": "deprecated" }; -const memory = require('api-utils/memory'); -var timer = require("./timer"); +const memory = require('./memory'); +var timer = require("../timers"); exports.findAndRunTests = function findAndRunTests(options) { var TestFinder = require("./unit-test-finder").TestFinder; @@ -311,7 +311,7 @@ TestRunner.prototype = { let test = this; // capture a traceback before we go async. - let traceback = require("./traceback"); + let traceback = require("../console/traceback"); let stack = traceback.get(); stack.splice(-2, 2); let currentWaitStack = traceback.format(stack); diff --git a/packages/api-utils/lib/window-utils.js b/lib/sdk/deprecated/window-utils.js similarity index 93% rename from packages/api-utils/lib/window-utils.js rename to lib/sdk/deprecated/window-utils.js index ca68abe9a..66fcfbab2 100644 --- a/packages/api-utils/lib/window-utils.js +++ b/lib/sdk/deprecated/window-utils.js @@ -8,13 +8,13 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'); -const { EventEmitter } = require('./events'); -const { Trait } = require('./traits'); -const { when } = require('./unload'); +const { EventEmitter } = require('../deprecated/events'); +const { Trait } = require('../deprecated/traits'); +const { when } = require('../system/unload'); const { getInnerId, getOuterId, windows, isDocumentLoaded, isBrowser, - getMostRecentBrowserWindow } = require('./window/utils'); -const errors = require('./errors'); -const { deprecateFunction } = require('./deprecate'); + getMostRecentBrowserWindow } = require('../window/utils'); +const errors = require('../deprecated/errors'); +const { deprecateFunction } = require('../util/deprecate'); const windowWatcher = Cc['@mozilla.org/embedcomp/window-watcher;1']. getService(Ci.nsIWindowWatcher); @@ -64,7 +64,7 @@ function WindowTracker(delegate) { this._regWindow(window); windowWatcher.registerNotification(this); - require('./unload').ensure(this); + require('../system/unload').ensure(this); return this; }; diff --git a/packages/api-utils/lib/dom/events.js b/lib/sdk/dom/events.js similarity index 100% rename from packages/api-utils/lib/dom/events.js rename to lib/sdk/dom/events.js diff --git a/packages/api-utils/lib/dom/events/keys.js b/lib/sdk/dom/events/keys.js similarity index 94% rename from packages/api-utils/lib/dom/events/keys.js rename to lib/sdk/dom/events/keys.js index ce17565a7..01e4a0d0d 100644 --- a/packages/api-utils/lib/dom/events/keys.js +++ b/lib/sdk/dom/events/keys.js @@ -11,8 +11,8 @@ module.metadata = { const { emit } = require("../events"); const { getCodeForKey, toJSON } = require("../../keyboard/utils"); -const { has } = require("../../array"); -const { isString } = require("../../type"); +const { has } = require("../../util/array"); +const { isString } = require("../../lang/type"); const INITIALIZER = "initKeyEvent"; const CATEGORY = "KeyboardEvent"; diff --git a/packages/api-utils/lib/event/core.js b/lib/sdk/event/core.js similarity index 99% rename from packages/api-utils/lib/event/core.js rename to lib/sdk/event/core.js index d23e9ac1a..e63e3b98d 100644 --- a/packages/api-utils/lib/event/core.js +++ b/lib/sdk/event/core.js @@ -13,7 +13,7 @@ module.metadata = { const UNCAUGHT_ERROR = 'An error event was emitted for which there was no listener.'; const BAD_LISTENER = 'The event listener must be a function.'; -const { ns } = require('../namespace'); +const { ns } = require('../core/namespace'); const event = ns(); diff --git a/packages/api-utils/lib/event/target.js b/lib/sdk/event/target.js similarity index 96% rename from packages/api-utils/lib/event/target.js rename to lib/sdk/event/target.js index 497240e66..b8906c0c7 100644 --- a/packages/api-utils/lib/event/target.js +++ b/lib/sdk/event/target.js @@ -11,8 +11,8 @@ module.metadata = { }; const { on, once, off } = require('./core'); -const { method } = require('../functional'); -const { Class } = require('../heritage'); +const { method } = require('../lang/functional'); +const { Class } = require('../core/heritage'); const EVENT_TYPE_PATTERN = /^on([A-Z]\w+$)/; diff --git a/packages/api-utils/lib/hidden-frame.js b/lib/sdk/frame/hidden-frame.js similarity index 94% rename from packages/api-utils/lib/hidden-frame.js rename to lib/sdk/frame/hidden-frame.js index a39ccd39e..1bf51de2c 100644 --- a/packages/api-utils/lib/hidden-frame.js +++ b/lib/sdk/frame/hidden-frame.js @@ -11,15 +11,15 @@ module.metadata = { }; const {Cc, Ci} = require("chrome"); -const errors = require("./errors"); -const apiUtils = require("./api-utils"); -const timer = require("./timer"); +const errors = require("../deprecated/errors"); +const apiUtils = require("../deprecated/api-utils"); +const timer = require("../timers"); const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; let hostFrame, hostDocument, hiddenWindow, isHostFrameReady = false; -if (!require("./xul-app").isOneOf(["Firefox", "Fennec", "Thunderbird"])) { +if (!require("../system/xul-app").isOneOf(["Firefox", "Fennec", "Thunderbird"])) { throw new Error([ "The hidden-frame module currently supports only Firefox and Thunderbird. ", "In the future, we would like it to support other applications, however. ", @@ -88,7 +88,7 @@ function HiddenFrame(options) { options[key] = val; } - require("./collection").addCollectionProperty(this, "onReady"); + require("../util/collection").addCollectionProperty(this, "onReady"); if (options.onReady) this.onReady.add(options.onReady); if (options.onUnload) @@ -172,7 +172,7 @@ exports.remove = function remove(frame) { entry.unload(); } -require("./unload").when(function () { +require("../system/unload").when(function () { for each (let entry in cache.slice()) exports.remove(entry.frame); diff --git a/packages/api-utils/lib/frame/utils.js b/lib/sdk/frame/utils.js similarity index 100% rename from packages/api-utils/lib/frame/utils.js rename to lib/sdk/frame/utils.js diff --git a/packages/addon-kit/lib/hotkeys.js b/lib/sdk/hotkeys.js similarity index 90% rename from packages/addon-kit/lib/hotkeys.js rename to lib/sdk/hotkeys.js index 790a8928a..3491d2c58 100644 --- a/packages/addon-kit/lib/hotkeys.js +++ b/lib/sdk/hotkeys.js @@ -12,8 +12,8 @@ module.metadata = { const INVALID_HOTKEY = "Hotkey must have at least one modifier."; const { toJSON: jsonify, toString: stringify, - isFunctionKey } = require("api-utils/keyboard/utils"); -const { register, unregister } = require("api-utils/keyboard/hotkeys"); + isFunctionKey } = require("./keyboard/utils"); +const { register, unregister } = require("./keyboard/hotkeys"); const Hotkey = exports.Hotkey = function Hotkey(options) { if (!(this instanceof Hotkey)) diff --git a/packages/api-utils/lib/byte-streams.js b/lib/sdk/io/byte-streams.js similarity index 98% rename from packages/api-utils/lib/byte-streams.js rename to lib/sdk/io/byte-streams.js index cd523ef6d..27b180258 100644 --- a/packages/api-utils/lib/byte-streams.js +++ b/lib/sdk/io/byte-streams.js @@ -91,7 +91,7 @@ function StreamManager(stream, rawStream) { self.unload(); }; - require("./unload").ensure(this); + require("../system/unload").ensure(this); } StreamManager.prototype = { diff --git a/packages/api-utils/lib/utils/data.js b/lib/sdk/io/data.js similarity index 83% rename from packages/api-utils/lib/utils/data.js rename to lib/sdk/io/data.js index d1362aa32..9dd724684 100644 --- a/packages/api-utils/lib/utils/data.js +++ b/lib/sdk/io/data.js @@ -17,7 +17,7 @@ const IOService = Cc["@mozilla.org/network/io-service;1"]. const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm"); const FaviconService = Cc["@mozilla.org/browser/favicon-service;1"]. getService(Ci.nsIFaviconService); -const { deprecateFunction, deprecatedUsage } = require("api-utils/deprecate"); +const { deprecateFunction, deprecatedUsage } = require("../util/deprecate"); const PNG_B64 = "data:image/png;base64,"; const DEF_FAVICON_URI = "chrome://mozapps/skin/places/defaultFavicon.png"; @@ -63,8 +63,8 @@ function getChromeURIContent(chromeURI) { } exports.getChromeURIContent = function deprecated_getChromeURIContent() { deprecatedUsage( - 'require("api-utils/utils/data").getChromeURIContent is deprecated, ' + - 'please use require("api-utils/url/io").readURI instead.' + 'getChromeURIContent is deprecated, ' + + 'please use require("sdk/net/url").readURI instead.' ); }; @@ -72,13 +72,13 @@ exports.getChromeURIContent = function deprecated_getChromeURIContent() { * Creates a base-64 encoded ASCII string from a string of binary data. */ exports.base64Encode = deprecateFunction(base64.encode, - 'require("api-utils/utils/data").base64Encode is deprecated, ' + - 'please use require("api-utils/base64").encode instead.' + 'base64Encode is deprecated, ' + + 'please use require("sdk/base64").encode instead.' ); /** * Decodes a string of data which has been encoded using base-64 encoding. */ exports.base64Decode = deprecateFunction(base64.decode, - 'require("api-utils/utils/data").base64Dencode is deprecated, ' + - 'please use require("api-utils/base64").decode instead.' + 'base64Dencode is deprecated, ' + + 'please use require("sdk/base64").decode instead.' ); diff --git a/packages/api-utils/lib/file.js b/lib/sdk/io/file.js similarity index 100% rename from packages/api-utils/lib/file.js rename to lib/sdk/io/file.js diff --git a/packages/api-utils/lib/text-streams.js b/lib/sdk/io/text-streams.js similarity index 99% rename from packages/api-utils/lib/text-streams.js rename to lib/sdk/io/text-streams.js index 7b5d7306b..0aa469d61 100644 --- a/packages/api-utils/lib/text-streams.js +++ b/lib/sdk/io/text-streams.js @@ -218,7 +218,7 @@ function StreamManager(stream, rawStream) { self.unload(); }; - require("./unload").ensure(this); + require("../system/unload").ensure(this); } StreamManager.prototype = { diff --git a/packages/api-utils/lib/keyboard/hotkeys.js b/lib/sdk/keyboard/hotkeys.js similarity index 100% rename from packages/api-utils/lib/keyboard/hotkeys.js rename to lib/sdk/keyboard/hotkeys.js diff --git a/packages/api-utils/lib/keyboard/observer.js b/lib/sdk/keyboard/observer.js similarity index 86% rename from packages/api-utils/lib/keyboard/observer.js rename to lib/sdk/keyboard/observer.js index 8f208f71d..26c0a838e 100644 --- a/packages/api-utils/lib/keyboard/observer.js +++ b/lib/sdk/keyboard/observer.js @@ -9,10 +9,10 @@ module.metadata = { "stability": "unstable" }; -const { Trait } = require("../light-traits"); -const { EventEmitterTrait: EventEmitter } = require("../events"); -const { DOMEventAssembler } = require("../events/assembler"); -const { browserWindowIterator } = require('../window-utils'); +const { Trait } = require("../deprecated/light-traits"); +const { EventEmitterTrait: EventEmitter } = require("../deprecated/events"); +const { DOMEventAssembler } = require("../deprecated/events/assembler"); +const { browserWindowIterator } = require('../deprecated/window-utils'); const { isBrowser } = require('../window/utils'); const { observer: windowObserver } = require("../windows/observer"); diff --git a/packages/api-utils/lib/keyboard/utils.js b/lib/sdk/keyboard/utils.js similarity index 97% rename from packages/api-utils/lib/keyboard/utils.js rename to lib/sdk/keyboard/utils.js index e36f34481..a4a8f765c 100644 --- a/packages/api-utils/lib/keyboard/utils.js +++ b/lib/sdk/keyboard/utils.js @@ -10,9 +10,9 @@ module.metadata = { }; const { Cc, Ci } = require("chrome"); -const runtime = require("../runtime"); -const { isString } = require("../type"); -const array = require("../array"); +const runtime = require("../system/runtime"); +const { isString } = require("../lang/type"); +const array = require("../util/array"); const SWP = "{{SEPARATOR}}"; diff --git a/packages/addon-kit/lib/l10n.js b/lib/sdk/l10n.js similarity index 95% rename from packages/addon-kit/lib/l10n.js rename to lib/sdk/l10n.js index 356c484b4..40f219cdc 100644 --- a/packages/addon-kit/lib/l10n.js +++ b/lib/sdk/l10n.js @@ -7,8 +7,8 @@ module.metadata = { "stability": "stable" }; -const core = require("api-utils/l10n/core"); -const { getRulesForLocale } = require("api-utils/l10n/plural-rules"); +const core = require("./l10n/core"); +const { getRulesForLocale } = require("./l10n/plural-rules"); // Retrieve the plural mapping function let pluralMappingFunction = getRulesForLocale(core.language()) || diff --git a/packages/api-utils/lib/l10n/core.js b/lib/sdk/l10n/core.js similarity index 100% rename from packages/api-utils/lib/l10n/core.js rename to lib/sdk/l10n/core.js diff --git a/packages/api-utils/lib/l10n/html.js b/lib/sdk/l10n/html.js similarity index 94% rename from packages/api-utils/lib/l10n/html.js rename to lib/sdk/l10n/html.js index cc6b5234e..1a36415cc 100644 --- a/packages/api-utils/lib/l10n/html.js +++ b/lib/sdk/l10n/html.js @@ -7,10 +7,10 @@ module.metadata = { }; const { Ci } = require("chrome"); -const events = require("api-utils/system/events"); -const core = require("api-utils/l10n/core"); +const events = require("../system/events"); +const core = require("./core"); -const assetsURI = require('self').data.url(); +const assetsURI = require('../self').data.url(); // Taken from Gaia: // https://github.com/andreasgal/gaia/blob/04fde2640a7f40314643016a5a6c98bf3755f5fd/webapi.js#L1470 diff --git a/packages/api-utils/lib/l10n/loader.js b/lib/sdk/l10n/loader.js similarity index 92% rename from packages/api-utils/lib/l10n/loader.js rename to lib/sdk/l10n/loader.js index 51d24c798..9af6c5c71 100644 --- a/packages/api-utils/lib/l10n/loader.js +++ b/lib/sdk/l10n/loader.js @@ -9,9 +9,9 @@ module.metadata = { }; const { Cc, Ci } = require("chrome"); -const { getPreferedLocales, findClosestLocale } = require("api-utils/l10n/locale"); -const { readURI } = require("api-utils/url/io"); -const { resolve } = require("api-utils/promise"); +const { getPreferedLocales, findClosestLocale } = require("./locale"); +const { readURI } = require("../net/url"); +const { resolve } = require("../core/promise"); function parseJsonURI(uri) { return readURI(uri). diff --git a/packages/api-utils/lib/l10n/locale.js b/lib/sdk/l10n/locale.js similarity index 98% rename from packages/api-utils/lib/l10n/locale.js rename to lib/sdk/l10n/locale.js index 05b2c47cb..0e59a6418 100644 --- a/packages/api-utils/lib/l10n/locale.js +++ b/lib/sdk/l10n/locale.js @@ -7,7 +7,7 @@ module.metadata = { "stability": "unstable" }; -const prefs = require("preferences-service"); +const prefs = require("../preferences/service"); const { Cu, Cc, Ci } = require("chrome"); const { Services } = Cu.import("resource://gre/modules/Services.jsm"); diff --git a/packages/api-utils/lib/l10n/plural-rules.js b/lib/sdk/l10n/plural-rules.js similarity index 100% rename from packages/api-utils/lib/l10n/plural-rules.js rename to lib/sdk/l10n/plural-rules.js diff --git a/packages/api-utils/lib/l10n/prefs.js b/lib/sdk/l10n/prefs.js similarity index 88% rename from packages/api-utils/lib/l10n/prefs.js rename to lib/sdk/l10n/prefs.js index 7b8f31089..5bcff039a 100644 --- a/packages/api-utils/lib/l10n/prefs.js +++ b/lib/sdk/l10n/prefs.js @@ -4,9 +4,9 @@ "use strict"; -const observers = require("api-utils/observer-service"); -const core = require("api-utils/l10n/core"); -const { id: jetpackId} = require('self'); +const observers = require("../deprecated/observer-service"); +const core = require("./core"); +const { id: jetpackId} = require('../self'); const OPTIONS_DISPLAYED = "addon-options-displayed"; diff --git a/packages/api-utils/lib/functional.js b/lib/sdk/lang/functional.js similarity index 99% rename from packages/api-utils/lib/functional.js rename to lib/sdk/lang/functional.js index bf9656f81..3595a2704 100644 --- a/packages/api-utils/lib/functional.js +++ b/lib/sdk/lang/functional.js @@ -12,7 +12,7 @@ module.metadata = { "stability": "unstable" }; -const { setTimeout } = require("./timer"); +const { setTimeout } = require("../timers"); /** * Takes `lambda` function and returns a method. When returned method is diff --git a/packages/api-utils/lib/type.js b/lib/sdk/lang/type.js similarity index 100% rename from packages/api-utils/lib/type.js rename to lib/sdk/lang/type.js diff --git a/packages/api-utils/lib/cuddlefish.js b/lib/sdk/loader/cuddlefish.js similarity index 78% rename from packages/api-utils/lib/cuddlefish.js rename to lib/sdk/loader/cuddlefish.js index 86706d51d..cac05a984 100644 --- a/packages/api-utils/lib/cuddlefish.js +++ b/lib/sdk/loader/cuddlefish.js @@ -14,15 +14,16 @@ module.metadata = { // put in module cache so that it is never loaded in any other way. /* Workarounds to include dependencies in the manifest -require('chrome') // Otherwise CFX will complain about Components -require('api-utils/loader') // Otherwise CFX will stip out loader.js -require('api-utils/addon/runner') // Otherwise CFX will stip out addon/runner.js +require('chrome') // Otherwise CFX will complain about Components +require('toolkit/loader') // Otherwise CFX will stip out loader.js +require('sdk/addon/runner') // Otherwise CFX will stip out addon/runner.js */ const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components; // `loadSandbox` is exposed by bootstrap.js -const loaderURI = module.uri.replace(/\/[^\/]*$/, '/loader.js'); +const loaderURI = module.uri.replace("sdk/loader/cuddlefish.js", + "toolkit/loader.js"); // We need to keep a reference to the sandbox in order to unload it in // bootstrap.js const loaderSandbox = loadSandbox(loaderURI); @@ -37,8 +38,8 @@ function CuddlefishLoader(options) { // Put `api-utils/loader` and `api-utils/cuddlefish` loaded as JSM to module // cache to avoid subsequent loads via `require`. modules: override({ - 'api-utils/loader': loaderModule, - 'api-utils/cuddlefish': exports + 'toolkit/loader': loaderModule, + 'addon-sdk/sdk/loader/cuddlefish': exports }, options.modules), resolve: function resolve(id, requirer) { let entry = requirer && requirer in manifest && manifest[requirer]; @@ -66,7 +67,10 @@ function CuddlefishLoader(options) { } }); - return loaderModule.Loader(options); + let loader = loaderModule.Loader(options); + // Hack to allow loading from `toolkit/loader`. + loader.modules[loaderURI] = loaderSandbox; + return loader; } exports = override(loaderModule, { diff --git a/packages/api-utils/lib/sandbox.js b/lib/sdk/loader/sandbox.js similarity index 100% rename from packages/api-utils/lib/sandbox.js rename to lib/sdk/loader/sandbox.js diff --git a/packages/api-utils/lib/url/io.js b/lib/sdk/net/url.js similarity index 97% rename from packages/api-utils/lib/url/io.js rename to lib/sdk/net/url.js index cf5517b99..5992e0de4 100644 --- a/packages/api-utils/lib/url/io.js +++ b/lib/sdk/net/url.js @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const { Cu, components } = require("chrome"); -const { defer } = require("../promise"); -const { merge } = require("../utils/object"); +const { defer } = require("../core/promise"); +const { merge } = require("../util/object"); const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {}); diff --git a/packages/api-utils/lib/xhr.js b/lib/sdk/net/xhr.js similarity index 95% rename from packages/api-utils/lib/xhr.js rename to lib/sdk/net/xhr.js index 3792ea669..b4fc1ef90 100644 --- a/packages/api-utils/lib/xhr.js +++ b/lib/sdk/net/xhr.js @@ -8,8 +8,9 @@ module.metadata = { "stability": "unstable" }; -const {Cc,Ci} = require("chrome"); -const memory = require('api-utils/memory'); +const { Cc, Ci } = require("chrome"); +const memory = require('../deprecated/memory'); +const { when: unload } = require("../system/unload"); // ## Implementation Notes ## // @@ -148,7 +149,6 @@ DELEGATED_METHODS.forEach( }; }); -require("./unload").when( - function() { - requests.slice().forEach(function(request) { request._unload(); }); - }); +unload(function() { + requests.slice().forEach(function(request) { request._unload(); }); +}); diff --git a/packages/addon-kit/lib/notifications.js b/lib/sdk/notifications.js similarity index 96% rename from packages/addon-kit/lib/notifications.js rename to lib/sdk/notifications.js index e2d990660..909552ff0 100644 --- a/packages/addon-kit/lib/notifications.js +++ b/lib/sdk/notifications.js @@ -11,8 +11,8 @@ module.metadata = { }; const { Cc, Ci, Cr } = require("chrome"); -const apiUtils = require("api-utils/api-utils"); -const errors = require("api-utils/errors"); +const apiUtils = require("./deprecated/api-utils"); +const errors = require("./deprecated/errors"); try { let alertServ = Cc["@mozilla.org/alerts-service;1"]. diff --git a/packages/addon-kit/lib/page-mod.js b/lib/sdk/page-mod.js similarity index 93% rename from packages/addon-kit/lib/page-mod.js rename to lib/sdk/page-mod.js index b9888abd2..747afd820 100644 --- a/packages/addon-kit/lib/page-mod.js +++ b/lib/sdk/page-mod.js @@ -9,21 +9,21 @@ module.metadata = { "stability": "stable" }; -const observers = require("api-utils/observer-service"); -const { Worker, Loader } = require('api-utils/content'); -const { EventEmitter } = require('api-utils/events'); -const { List } = require('api-utils/list'); -const { Registry } = require('api-utils/utils/registry'); -const { MatchPattern } = require('api-utils/match-pattern'); -const { validateOptions : validate } = require('api-utils/api-utils'); -const { validationAttributes } = require('api-utils/content/loader'); +const observers = require('./deprecated/observer-service'); +const { Loader, validationAttributes } = require('./content/loader'); +const { Worker } = require('./content/worker'); +const { EventEmitter } = require('./deprecated/events'); +const { List } = require('./deprecated/list'); +const { Registry } = require('./util/registry'); +const { MatchPattern } = require('./page-mod/match-pattern'); +const { validateOptions : validate } = require('./deprecated/api-utils'); const { Cc, Ci } = require('chrome'); -const { merge } = require('api-utils/utils/object'); -const { readURISync } = require('api-utils/url/io'); -const { windowIterator } = require("window-utils"); -const { isBrowser } = require('api-utils/window/utils'); +const { merge } = require('./util/object'); +const { readURISync } = require('./net/url'); +const { windowIterator } = require('./deprecated/window-utils'); +const { isBrowser } = require('./window/utils'); const { getTabs, getTabContentWindow, getTabForContentWindow, - getURI: getTabURI } = require("api-utils/tabs/utils"); + getURI: getTabURI } = require('./tabs/utils'); const styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"]. getService(Ci.nsIStyleSheetService); diff --git a/packages/api-utils/lib/match-pattern.js b/lib/sdk/page-mod/match-pattern.js similarity index 99% rename from packages/api-utils/lib/match-pattern.js rename to lib/sdk/page-mod/match-pattern.js index 419e0300c..5c42e66fd 100644 --- a/packages/api-utils/lib/match-pattern.js +++ b/lib/sdk/page-mod/match-pattern.js @@ -10,7 +10,7 @@ module.metadata = { "stability": "unstable" }; -const { URL } = require("./url"); +const { URL } = require("../url"); exports.MatchPattern = MatchPattern; diff --git a/packages/addon-kit/lib/page-worker.js b/lib/sdk/page-worker.js similarity index 92% rename from packages/addon-kit/lib/page-worker.js rename to lib/sdk/page-worker.js index 083b43a69..f667e4d2b 100644 --- a/packages/addon-kit/lib/page-worker.js +++ b/lib/sdk/page-worker.js @@ -9,10 +9,10 @@ module.metadata = { "stability": "stable" }; -const { Symbiont } = require("api-utils/content"); -const { Trait } = require("api-utils/traits"); +const { Symbiont } = require("./content/symbiont"); +const { Trait } = require("./deprecated/traits"); -if (!require("api-utils/xul-app").isOneOf(["Firefox", "Thunderbird"])) { +if (!require("./system/xul-app").isOneOf(["Firefox", "Thunderbird"])) { throw new Error([ "The page-worker module currently supports only Firefox and Thunderbird. ", "In the future, we would like it to support other applications, however. ", diff --git a/packages/addon-kit/lib/panel.js b/lib/sdk/panel.js similarity index 97% rename from packages/addon-kit/lib/panel.js rename to lib/sdk/panel.js index 73a65c9bb..3ce6284d4 100644 --- a/packages/addon-kit/lib/panel.js +++ b/lib/sdk/panel.js @@ -8,7 +8,7 @@ module.metadata = { "stability": "stable" }; -if (!require("api-utils/xul-app").is("Firefox")) { +if (!require("./system/xul-app").is("Firefox")) { throw new Error([ "The panel module currently supports only Firefox. In the future ", "we would like it to support other applications, however. Please see ", @@ -19,12 +19,12 @@ if (!require("api-utils/xul-app").is("Firefox")) { const { Cc, Ci } = require("chrome"); -const { validateOptions: valid } = require("api-utils/api-utils"); -const { Symbiont } = require("api-utils/content"); -const { EventEmitter } = require('api-utils/events'); -const timer = require("api-utils/timer"); -const runtime = require("api-utils/runtime"); -const { getMostRecentBrowserWindow } = require('api-utils/window/utils'); +const { validateOptions: valid } = require('./deprecated/api-utils'); +const { Symbiont } = require('./content/content'); +const { EventEmitter } = require('./deprecated/events'); +const timer = require('./timers'); +const runtime = require('./system/runtime'); +const { getMostRecentBrowserWindow } = require('./window/utils'); const windowMediator = Cc['@mozilla.org/appshell/window-mediator;1']. getService(Ci.nsIWindowMediator); diff --git a/packages/addon-kit/lib/passwords.js b/lib/sdk/passwords.js similarity index 92% rename from packages/addon-kit/lib/passwords.js rename to lib/sdk/passwords.js index 61aa665d0..7aeb22aa4 100644 --- a/packages/addon-kit/lib/passwords.js +++ b/lib/sdk/passwords.js @@ -8,8 +8,8 @@ module.metadata = { "stability": "stable" }; -const { search, remove, store } = require("api-utils/passwords/utils"); -const { defer, delay } = require("api-utils/functional"); +const { search, remove, store } = require("./passwords/utils"); +const { defer, delay } = require("./lang/functional"); /** * Utility function that returns `onComplete` and `onError` callbacks form the diff --git a/packages/api-utils/lib/passwords/utils.js b/lib/sdk/passwords/utils.js similarity index 98% rename from packages/api-utils/lib/passwords/utils.js rename to lib/sdk/passwords/utils.js index 43b28d3ff..8cc22308e 100644 --- a/packages/api-utils/lib/passwords/utils.js +++ b/lib/sdk/passwords/utils.js @@ -10,7 +10,7 @@ module.metadata = { }; const { Cc, Ci, CC } = require("chrome"); -const { uri: ADDON_URI } = require("self"); +const { uri: ADDON_URI } = require("../self"); const loginManager = Cc["@mozilla.org/login-manager;1"]. getService(Ci.nsILoginManager); const { URL: parseURL } = require("../url"); diff --git a/packages/api-utils/lib/xpcom.js b/lib/sdk/platform/xpcom.js similarity index 96% rename from packages/api-utils/lib/xpcom.js rename to lib/sdk/platform/xpcom.js index 4ab6d72b6..279d234fa 100644 --- a/packages/api-utils/lib/xpcom.js +++ b/lib/sdk/platform/xpcom.js @@ -12,9 +12,9 @@ const { Cc, Ci, Cr, Cm, components: { classesByID } } = require('chrome'); const { registerFactory, unregisterFactory, isCIDRegistered } = Cm.QueryInterface(Ci.nsIComponentRegistrar); -const { merge } = require('./utils/object'); -const { Class, extend, mix } = require('./heritage'); -const { uuid } = require('./uuid'); +const { merge } = require('../util/object'); +const { Class, extend, mix } = require('../core/heritage'); +const { uuid } = require('../util/uuid'); // This is a base prototype, that provides bare bones of XPCOM. JS based // components can be easily implement by extending it. @@ -171,7 +171,7 @@ function register(factory) { registerFactory(factory.id, factory.description, factory.contract, factory); if (factory.unregister) - require('./unload').when(unregister.bind(null, factory)); + require('../system/unload').when(unregister.bind(null, factory)); } exports.register = register; @@ -194,9 +194,9 @@ function autoRegister(path) { // Gecko-specific binaries for a component (which will be the case // if only frozen interfaces are used). - var runtime = require("./runtime"); + var runtime = require("../system/runtime"); var osDirName = runtime.OS + "_" + runtime.XPCOMABI; - var platformVersion = require("./xul-app").platformVersion.substring(0, 5); + var platformVersion = require("../system/xul-app").platformVersion.substring(0, 5); var file = Cc['@mozilla.org/file/local;1'] .createInstance(Ci.nsILocalFile); diff --git a/packages/api-utils/lib/prefs/target.js b/lib/sdk/preferences/event-target.js similarity index 81% rename from packages/api-utils/lib/prefs/target.js rename to lib/sdk/preferences/event-target.js index 8b626b80c..79d1d51d8 100644 --- a/packages/api-utils/lib/prefs/target.js +++ b/lib/sdk/preferences/event-target.js @@ -8,13 +8,13 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'); -const { Class } = require('api-utils/heritage'); -const { EventTarget } = require('api-utils/event/target'); -const { Branch } = require('api-utils/preferences-service'); -const { emit, off } = require('api-utils/event/core'); -const { when: unload } = require('api-utils/unload'); +const { Class } = require('../core/heritage'); +const { EventTarget } = require('../event/target'); +const { Branch } = require('./service'); +const { emit, off } = require('../event/core'); +const { when: unload } = require('../system/unload'); -const prefTargetNS = require('namespace').ns(); +const prefTargetNS = require('../core/namespace').ns(); const PrefsTarget = Class({ extends: EventTarget, diff --git a/packages/api-utils/lib/preferences-service.js b/lib/sdk/preferences/service.js similarity index 100% rename from packages/api-utils/lib/preferences-service.js rename to lib/sdk/preferences/service.js diff --git a/packages/addon-kit/lib/private-browsing.js b/lib/sdk/private-browsing.js similarity index 80% rename from packages/addon-kit/lib/private-browsing.js rename to lib/sdk/private-browsing.js index fb4f072db..6d2a709ad 100644 --- a/packages/addon-kit/lib/private-browsing.js +++ b/lib/sdk/private-browsing.js @@ -7,10 +7,10 @@ module.metadata = { "stability": "stable" }; -const { setMode, getMode, on: onStateChange } = require('api-utils/private-browsing/utils'); -const { emit, on, once, off } = require('api-utils/event/core'); -const { when: unload } = require('api-utils/unload'); -const observers = require('api-utils/observer-service'); +const { setMode, getMode, on: onStateChange } = require('./private-browsing/utils'); +const { emit, on, once, off } = require('./event/core'); +const { when: unload } = require('./system/unload'); +const observers = require('./deprecated/observer-service'); onStateChange('start', function onStart() { emit(exports, 'start'); diff --git a/packages/api-utils/lib/private-browsing/utils.js b/lib/sdk/private-browsing/utils.js similarity index 86% rename from packages/api-utils/lib/private-browsing/utils.js rename to lib/sdk/private-browsing/utils.js index d7cd71c99..7621f9208 100644 --- a/packages/api-utils/lib/private-browsing/utils.js +++ b/lib/sdk/private-browsing/utils.js @@ -9,18 +9,18 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'); -const { defer } = require('api-utils/functional'); -const observers = require('api-utils/observer-service'); -const { emit, on, once, off } = require('api-utils/event/core'); -const { when: unload } = require('api-utils/unload'); -const { getWindowLoadingContext } = require('api-utils/window/utils'); +const { defer } = require('../lang/functional'); +const observers = require('../deprecated/observer-service'); +const { emit, on, once, off } = require('../event/core'); +const { when: unload } = require('../system/unload'); +const { getWindowLoadingContext } = require('../window/utils'); let deferredEmit = defer(emit); let pbService; // Currently, only Firefox implements the private browsing service. -if (require("api-utils/xul-app").is("Firefox")) { +if (require("../system/xul-app").is("Firefox")) { pbService = Cc["@mozilla.org/privatebrowsing;1"]. getService(Ci.nsIPrivateBrowsingService); diff --git a/packages/api-utils/lib/querystring.js b/lib/sdk/querystring.js similarity index 100% rename from packages/api-utils/lib/querystring.js rename to lib/sdk/querystring.js diff --git a/packages/addon-kit/lib/request.js b/lib/sdk/request.js similarity index 93% rename from packages/addon-kit/lib/request.js rename to lib/sdk/request.js index cc32c1b53..da5be7fc9 100644 --- a/packages/addon-kit/lib/request.js +++ b/lib/sdk/request.js @@ -8,14 +8,14 @@ module.metadata = { "stability": "stable" }; -const { ns } = require("api-utils/namespace"); -const { emit } = require("api-utils/event/core"); -const { merge } = require("api-utils/utils/object"); -const { stringify } = require("api-utils/querystring"); -const { EventTarget } = require("api-utils/event/target"); -const { Class } = require("api-utils/heritage"); -const { XMLHttpRequest } = require("api-utils/xhr"); -const apiUtils = require("api-utils/api-utils"); +const { ns } = require("./core/namespace"); +const { emit } = require("./event/core"); +const { merge } = require("./util/object"); +const { stringify } = require("./querystring"); +const { EventTarget } = require("./event/target"); +const { Class } = require("./core/heritage"); +const { XMLHttpRequest } = require("./net/xhr"); +const apiUtils = require("./deprecated/api-utils"); const response = ns(); const request = ns(); diff --git a/packages/addon-kit/lib/selection.js b/lib/sdk/selection.js similarity index 96% rename from packages/addon-kit/lib/selection.js rename to lib/sdk/selection.js index cddf2d8a3..da94efe4c 100644 --- a/packages/addon-kit/lib/selection.js +++ b/lib/sdk/selection.js @@ -8,7 +8,7 @@ module.metadata = { "stability": "stable" }; -if (!require("api-utils/xul-app").is("Firefox")) { +if (!require("./system/xul-app").is("Firefox")) { throw new Error([ "The selection module currently supports only Firefox. In the future ", "we would like it to support other applications, however. Please see ", @@ -17,13 +17,13 @@ if (!require("api-utils/xul-app").is("Firefox")) { } let { Ci, Cc } = require("chrome"), - { setTimeout } = require("api-utils/timer"), - { emit, off } = require("api-utils/event/core"), - { Unknown } = require("api-utils/xpcom"), - { Class, obscure } = require("api-utils/heritage"), - { EventTarget } = require("api-utils/event/target"), - observers = require("api-utils/observer-service"), - { ns } = require("api-utils/namespace"); + { setTimeout } = require("./timers"), + { emit, off } = require("./event/core"), + { Unknown } = require("./platform/xpcom"), + { Class, obscure } = require("./core/heritage"), + { EventTarget } = require("./event/target"), + observers = require("./deprecated/observer-service"), + { ns } = require("./core/namespace"); // When a document is not visible anymore the selection object is detached, and // a new selection object is created when it becomes visible again. @@ -454,7 +454,7 @@ let SelectionListenerManager = Class({ * Install |SelectionListenerManager| as tab tracker in order to watch * tab opening/closing */ -require("api-utils/tab-browser").Tracker(SelectionListenerManager); +require("./deprecated/tab-browser").Tracker(SelectionListenerManager); var SelectionIterator = Class(obscure({ /** diff --git a/packages/api-utils/lib/self.js b/lib/sdk/self.js similarity index 95% rename from packages/api-utils/lib/self.js rename to lib/sdk/self.js index c27cba405..f9fca1eaf 100644 --- a/packages/api-utils/lib/self.js +++ b/lib/sdk/self.js @@ -9,7 +9,7 @@ const { CC } = require('chrome'); const { id, name, prefixURI, rootURI, version, loadReason } = require('@loader/options'); -const { readURISync } = require("api-utils/url/io"); +const { readURISync } = require('./net/url'); const addonDataURI = prefixURI + name + '/data/'; diff --git a/packages/addon-kit/lib/simple-prefs.js b/lib/sdk/simple-prefs.js similarity index 73% rename from packages/addon-kit/lib/simple-prefs.js rename to lib/sdk/simple-prefs.js index 4db696d89..5cbde4925 100644 --- a/packages/addon-kit/lib/simple-prefs.js +++ b/lib/sdk/simple-prefs.js @@ -7,11 +7,11 @@ module.metadata = { "stability": "experimental" }; -const { emit, off } = require("api-utils/event/core"); -const { when: unload } = require("api-utils/unload"); -const { PrefsTarget } = require("api-utils/prefs/target"); -const { id } = require("self"); -const observers = require("api-utils/observer-service"); +const { emit, off } = require("./event/core"); +const { when: unload } = require("./system/unload"); +const { PrefsTarget } = require("./preferences/event-target"); +const { id } = require("./self"); +const observers = require("./deprecated/observer-service"); const ADDON_BRANCH = "extensions." + id + "."; const BUTTON_PRESSED = id + "-cmdPressed"; diff --git a/packages/addon-kit/lib/simple-storage.js b/lib/sdk/simple-storage.js similarity index 96% rename from packages/addon-kit/lib/simple-storage.js rename to lib/sdk/simple-storage.js index 7d10b226d..2b88cc120 100644 --- a/packages/addon-kit/lib/simple-storage.js +++ b/lib/sdk/simple-storage.js @@ -11,12 +11,12 @@ module.metadata = { }; const { Cc, Ci } = require("chrome"); -const file = require("api-utils/file"); -const prefs = require("api-utils/preferences-service"); -const jpSelf = require("self"); -const timer = require("api-utils/timer"); -const unload = require("api-utils/unload"); -const { emit, on, off } = require("api-utils/event/core"); +const file = require("./io/file"); +const prefs = require("./preferences/service"); +const jpSelf = require("./self"); +const timer = require("./timers"); +const unload = require("./system/unload"); +const { emit, on, off } = require("./event/core"); const WRITE_PERIOD_PREF = "extensions.addon-sdk.simple-storage.writePeriod"; const WRITE_PERIOD_DEFAULT = 300000; // 5 minutes diff --git a/packages/api-utils/lib/system.js b/lib/sdk/system.js similarity index 97% rename from packages/api-utils/lib/system.js rename to lib/sdk/system.js index b281ebb93..1e374d31f 100644 --- a/packages/api-utils/lib/system.js +++ b/lib/sdk/system.js @@ -11,8 +11,8 @@ module.metadata = { const { Cc, Ci, CC } = require('chrome'); const options = require('@loader/options'); -const file = require('./file'); -const runtime = require("./runtime.js"); +const file = require('./io/file'); +const runtime = require("./system/runtime"); const appStartup = Cc['@mozilla.org/toolkit/app-startup;1']. getService(Ci.nsIAppStartup); @@ -47,7 +47,7 @@ exports.staticArgs = options.staticArgs; * Environment variables. Environment variables are non-enumerable properties * of this object (key is name and value is value). */ -exports.env = require('./environment').env; +exports.env = require('./system/environment').env; /** * Ends the process with the specified `code`. If omitted, exit uses the diff --git a/packages/api-utils/lib/environment.js b/lib/sdk/system/environment.js similarity index 100% rename from packages/api-utils/lib/environment.js rename to lib/sdk/system/environment.js diff --git a/packages/api-utils/lib/system/events.js b/lib/sdk/system/events.js similarity index 96% rename from packages/api-utils/lib/system/events.js rename to lib/sdk/system/events.js index bfe058098..a75dddc11 100644 --- a/packages/api-utils/lib/system/events.js +++ b/lib/sdk/system/events.js @@ -9,9 +9,9 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'); -const { Unknown } = require('../xpcom'); -const { Class } = require('../heritage'); -const { ns } = require('../namespace'); +const { Unknown } = require('../platform/xpcom'); +const { Class } = require('../core/heritage'); +const { ns } = require('../core/namespace'); const { addObserver, removeObserver, notifyObservers } = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); diff --git a/packages/api-utils/lib/globals.js b/lib/sdk/system/globals.js similarity index 94% rename from packages/api-utils/lib/globals.js rename to lib/sdk/system/globals.js index 83f27e497..df772951f 100644 --- a/packages/api-utils/lib/globals.js +++ b/lib/sdk/system/globals.js @@ -10,8 +10,8 @@ module.metadata = { }; let { Cc, Ci, CC } = require('chrome'); -let { PlainTextConsole } = require('./plain-text-console'); -let { stdout } = require('api-utils/system'); +let { PlainTextConsole } = require('../console/plain-text'); +let { stdout } = require('../system'); let ScriptError = CC('@mozilla.org/scripterror;1', 'nsIScriptError'); let consoleService = Cc['@mozilla.org/consoleservice;1'].getService(). QueryInterface(Ci.nsIConsoleService); diff --git a/packages/api-utils/lib/runtime.js b/lib/sdk/system/runtime.js similarity index 100% rename from packages/api-utils/lib/runtime.js rename to lib/sdk/system/runtime.js diff --git a/packages/api-utils/lib/unload.js b/lib/sdk/system/unload.js similarity index 97% rename from packages/api-utils/lib/unload.js rename to lib/sdk/system/unload.js index 7d502fa87..4d2575bdc 100644 --- a/packages/api-utils/lib/unload.js +++ b/lib/sdk/system/unload.js @@ -10,7 +10,7 @@ module.metadata = { "stability": "experimental" }; -const { on, off } = require('./system/events'); +const { on, off } = require('./events'); const unloadSubject = require('@loader/unload'); const observers = []; diff --git a/packages/api-utils/lib/xul-app.js b/lib/sdk/system/xul-app.js similarity index 100% rename from packages/api-utils/lib/xul-app.js rename to lib/sdk/system/xul-app.js diff --git a/packages/addon-kit/lib/tabs.js b/lib/sdk/tabs.js similarity index 84% rename from packages/addon-kit/lib/tabs.js rename to lib/sdk/tabs.js index 69995ad1f..f0060736c 100644 --- a/packages/addon-kit/lib/tabs.js +++ b/lib/sdk/tabs.js @@ -7,4 +7,4 @@ module.metadata = { 'stability': 'stable' }; -module.exports = require('api-utils/tabs/tabs'); +module.exports = require('./tabs/tabs'); diff --git a/packages/api-utils/lib/tabs/common.js b/lib/sdk/tabs/common.js similarity index 92% rename from packages/api-utils/lib/tabs/common.js rename to lib/sdk/tabs/common.js index 78b118959..dd5bb220b 100644 --- a/packages/api-utils/lib/tabs/common.js +++ b/lib/sdk/tabs/common.js @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { validateOptions } = require('../api-utils'); +const { validateOptions } = require('../deprecated/api-utils'); function Options(options) { if ('string' === typeof options) diff --git a/packages/api-utils/lib/tabs/events.js b/lib/sdk/tabs/events.js similarity index 100% rename from packages/api-utils/lib/tabs/events.js rename to lib/sdk/tabs/events.js diff --git a/packages/api-utils/lib/tabs/helpers.js b/lib/sdk/tabs/helpers.js similarity index 100% rename from packages/api-utils/lib/tabs/helpers.js rename to lib/sdk/tabs/helpers.js diff --git a/packages/api-utils/lib/tabs/namespace.js b/lib/sdk/tabs/namespace.js similarity index 86% rename from packages/api-utils/lib/tabs/namespace.js rename to lib/sdk/tabs/namespace.js index 964cef460..d359cee87 100644 --- a/packages/api-utils/lib/tabs/namespace.js +++ b/lib/sdk/tabs/namespace.js @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -let { ns } = require('../namespace'); +let { ns } = require('../core/namespace'); exports.tabsNS = ns(); exports.tabNS = ns(); diff --git a/packages/api-utils/lib/tabs/observer.js b/lib/sdk/tabs/observer.js similarity index 92% rename from packages/api-utils/lib/tabs/observer.js rename to lib/sdk/tabs/observer.js index 9c78f2adb..19a048c8a 100644 --- a/packages/api-utils/lib/tabs/observer.js +++ b/lib/sdk/tabs/observer.js @@ -8,11 +8,11 @@ module.metadata = { "stability": "unstable" }; -const { EventEmitterTrait: EventEmitter } = require("../events"); -const { DOMEventAssembler } = require("../events/assembler"); -const { Trait } = require("../light-traits"); +const { EventEmitterTrait: EventEmitter } = require("../deprecated/events"); +const { DOMEventAssembler } = require("../deprecated/events/assembler"); +const { Trait } = require("../deprecated/light-traits"); const { getActiveTab, getTabs, getTabContainer } = require("./utils"); -const { browserWindowIterator } = require("../window-utils"); +const { browserWindowIterator } = require("../deprecated/window-utils"); const { isBrowser } = require('../window/utils'); const { observer: windowObserver } = require("../windows/observer"); diff --git a/packages/api-utils/lib/tabs/tab-fennec.js b/lib/sdk/tabs/tab-fennec.js similarity index 96% rename from packages/api-utils/lib/tabs/tab-fennec.js rename to lib/sdk/tabs/tab-fennec.js index dd4e9788e..a9e287ef1 100644 --- a/packages/api-utils/lib/tabs/tab-fennec.js +++ b/lib/sdk/tabs/tab-fennec.js @@ -4,13 +4,13 @@ 'use strict'; const { Cc, Ci } = require('chrome'); -const { Class } = require('../heritage'); -const { tabNS } = require('./namespace'); +const { Class } = require('../core/heritage'); +const { tabNS } = require('../core/namespace'); const { EventTarget } = require('../event/target'); const { activateTab, getTabTitle, setTabTitle, closeTab, getTabURL, setTabURL, getOwnerWindow } = require('./utils'); const { emit } = require('../event/core'); -const { when: unload } = require('../unload'); +const { when: unload } = require('../system/unload'); const { EVENTS } = require('./events'); const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec'; diff --git a/packages/api-utils/lib/tabs/tab-firefox.js b/lib/sdk/tabs/tab-firefox.js similarity index 95% rename from packages/api-utils/lib/tabs/tab-firefox.js rename to lib/sdk/tabs/tab-firefox.js index d8bdcbd9e..bf675007f 100644 --- a/packages/api-utils/lib/tabs/tab-firefox.js +++ b/lib/sdk/tabs/tab-firefox.js @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { Trait } = require("../traits"); -const { EventEmitter } = require("../events"); -const { defer } = require("../functional"); +const { Trait } = require("../deprecated/traits"); +const { EventEmitter } = require("../deprecated/events"); +const { defer } = require("../lang/functional"); const { EVENTS } = require("./events"); -const { getThumbnailURIForWindow } = require("../utils/thumbnail"); -const { getFaviconURIForLocation } = require("../utils/data"); +const { getThumbnailURIForWindow } = require("../content/thumbnail"); +const { getFaviconURIForLocation } = require("../io/data"); const { activateTab, getOwnerWindow, getBrowserForTab, getTabTitle, setTabTitle, getTabURL, setTabURL } = require('./utils'); diff --git a/packages/api-utils/lib/tabs/tab.js b/lib/sdk/tabs/tab.js similarity index 84% rename from packages/api-utils/lib/tabs/tab.js rename to lib/sdk/tabs/tab.js index 7d6e227c7..420baeecd 100644 --- a/packages/api-utils/lib/tabs/tab.js +++ b/lib/sdk/tabs/tab.js @@ -7,10 +7,10 @@ module.metadata = { 'stability': 'unstable' }; -if (require('../xul-app').is('Firefox')) { +if (require('../system/xul-app').is('Firefox')) { module.exports = require('./tab-firefox'); } -else if (require('../xul-app').is('Fennec')) { +else if (require('../system/xul-app').is('Fennec')) { module.exports = require('./tab-fennec'); } else { diff --git a/packages/api-utils/lib/tabs/firefox-tabs.js b/lib/sdk/tabs/tabs-firefox.js similarity index 94% rename from packages/api-utils/lib/tabs/firefox-tabs.js rename to lib/sdk/tabs/tabs-firefox.js index f3a8755ee..92834c2e5 100644 --- a/packages/api-utils/lib/tabs/firefox-tabs.js +++ b/lib/sdk/tabs/tabs-firefox.js @@ -4,7 +4,7 @@ 'use strict'; // TODO: BUG 792670 - remove dependency below -const { browserWindows } = require('addon-kit/windows'); +const { browserWindows } = require('../windows'); const { tabs } = require('../windows/tabs-firefox'); Object.defineProperties(tabs, { diff --git a/packages/api-utils/lib/tabs/tabs.js b/lib/sdk/tabs/tabs.js similarity index 77% rename from packages/api-utils/lib/tabs/tabs.js rename to lib/sdk/tabs/tabs.js index c0f3d8eeb..fcb3868a9 100644 --- a/packages/api-utils/lib/tabs/tabs.js +++ b/lib/sdk/tabs/tabs.js @@ -7,10 +7,10 @@ module.metadata = { 'stability': 'unstable' }; -if (require('../xul-app').is('Firefox')) { - module.exports = require('./firefox-tabs'); +if (require('../system/xul-app').is('Firefox')) { + module.exports = require('./tabs-firefox'); } -else if (require('../xul-app').is('Fennec')) { +else if (require('../system/xul-app').is('Fennec')) { module.exports = require('../windows/tabs-fennec').tabs; } else { diff --git a/packages/api-utils/lib/tabs/utils.js b/lib/sdk/tabs/utils.js similarity index 99% rename from packages/api-utils/lib/tabs/utils.js rename to lib/sdk/tabs/utils.js index 5092b9b08..5d658f6ff 100644 --- a/packages/api-utils/lib/tabs/utils.js +++ b/lib/sdk/tabs/utils.js @@ -8,7 +8,7 @@ module.metadata = { 'stability': 'unstable' }; -const { defer } = require("../functional"); +const { defer } = require("../lang/functional"); const { windows } = require('../window/utils'); const { Ci } = require('chrome'); diff --git a/packages/api-utils/lib/tabs/worker.js b/lib/sdk/tabs/worker.js similarity index 100% rename from packages/api-utils/lib/tabs/worker.js rename to lib/sdk/tabs/worker.js diff --git a/packages/api-utils/lib/test.js b/lib/sdk/test.js similarity index 98% rename from packages/api-utils/lib/test.js rename to lib/sdk/test.js index 537c5dccc..0a322d699 100644 --- a/packages/api-utils/lib/test.js +++ b/lib/sdk/test.js @@ -10,7 +10,7 @@ module.metadata = { }; const BaseAssert = require("./test/assert").Assert; -const { isFunction, isObject } = require("./type"); +const { isFunction, isObject } = require("./lang/type"); function extend(target) { let descriptor = {} diff --git a/packages/api-utils/lib/test/assert.js b/lib/sdk/test/assert.js similarity index 98% rename from packages/api-utils/lib/test/assert.js rename to lib/sdk/test/assert.js index 1f962ae86..5eca7d43c 100644 --- a/packages/api-utils/lib/test/assert.js +++ b/lib/sdk/test/assert.js @@ -8,8 +8,9 @@ module.metadata = { "stability": "unstable" }; -const { isFunction, isNull, isObject, isString, isRegExp, isArray, isDate, - isPrimitive, isUndefined, instanceOf, source } = require("../type"); +const { isFunction, isNull, isObject, isString, + isRegExp, isArray, isDate, isPrimitive, + isUndefined, instanceOf, source } = require("../lang/type"); /** * The `AssertionError` is defined in assert. diff --git a/packages/test-harness/lib/harness.js b/lib/sdk/test/harness.js similarity index 92% rename from packages/test-harness/lib/harness.js rename to lib/sdk/test/harness.js index 127966d10..ced7c70b1 100644 --- a/packages/test-harness/lib/harness.js +++ b/lib/sdk/test/harness.js @@ -6,7 +6,17 @@ const { Cc,Ci } = require("chrome"); const { Loader } = require('./loader'); -const memory = require('api-utils/memory'); +const { setTimeout } = require('../timers'); +const memory = require('../deprecated/memory'); +const { PlainTextConsole } = require("../console/plain-text"); +const { when: unload } = require("../system/unload"); +const { format } = require("../console/traceback"); +const system = require("../system"); + +// Trick manifest builder to make it think we need these modules ? +const unit = require("../deprecated/unit-test"); +const test = require("../test"); +const url = require("../url"); var cService = Cc['@mozilla.org/consoleservice;1'].getService() .QueryInterface(Ci.nsIConsoleService); @@ -203,7 +213,7 @@ function cleanup() { console.exception(e); }; - require("api-utils/timer").setTimeout(showResults, 1); + setTimeout(showResults, 1); } function nextIteration(tests) { @@ -234,7 +244,7 @@ function nextIteration(tests) { findAndRunTests(loader, nextIteration); } else { - require("api-utils/timer").setTimeout(cleanup, 0); + setTimeout(cleanup, 0); } } @@ -289,12 +299,6 @@ var runTests = exports.runTests = function runTests(options) { try { cService.registerListener(consoleListener); - - var ptc = require("api-utils/plain-text-console"); - var url = require("api-utils/url"); - var system = require("api-utils/system"); - require("api-utils/unit-test"); - require("api-utils/test"); print("Running tests on " + system.name + " " + system.version + "/Gecko " + system.platformVersion + " (" + system.id + ") under " + @@ -302,16 +306,17 @@ var runTests = exports.runTests = function runTests(options) { loader = Loader(module, { - console: new TestRunnerConsole(new ptc.PlainTextConsole(print), options) + console: new TestRunnerConsole(new PlainTextConsole(print), options) }); nextIteration(); } catch (e) { - print(require("api-utils/traceback").format(e) + "\n" + e + "\n"); + print(format(e) + "\n" + e + "\n"); onDone({passed: 0, failed: 1}); } }; -require("api-utils/unload").when(function() { +unload(function() { cService.unregisterListener(consoleListener); }); + diff --git a/packages/api-utils/lib/httpd.js b/lib/sdk/test/httpd.js similarity index 100% rename from packages/api-utils/lib/httpd.js rename to lib/sdk/test/httpd.js diff --git a/packages/test-harness/lib/loader.js b/lib/sdk/test/loader.js similarity index 86% rename from packages/test-harness/lib/loader.js rename to lib/sdk/test/loader.js index b35d95c0e..282cf5ed8 100644 --- a/packages/test-harness/lib/loader.js +++ b/lib/sdk/test/loader.js @@ -5,12 +5,12 @@ "use strict"; const { Loader, resolveURI, Require, - unload, override, descriptor } = require('api-utils/cuddlefish'); + unload, override, descriptor } = require('../loader/cuddlefish'); exports.Loader = function(module, globals, packaging) { let options = packaging || require("@loader/options"); options = override(options, { - globals: override(require('api-utils/globals'), globals || {}) + globals: override(require('../system/globals'), globals || {}) }); let loader = Loader(options); diff --git a/packages/test-harness/lib/run-tests.js b/lib/sdk/test/runner.js similarity index 92% rename from packages/test-harness/lib/run-tests.js rename to lib/sdk/test/runner.js index ae6d775db..4db9acae3 100644 --- a/packages/test-harness/lib/run-tests.js +++ b/lib/sdk/test/runner.js @@ -4,8 +4,8 @@ "use strict"; -var obsvc = require("api-utils/observer-service"); -var { exit, stdout } = require("api-utils/system"); +var obsvc = require("../deprecated/observer-service"); +var { exit, stdout } = require("../system"); var cfxArgs = require("@test/options"); var { Cc, Ci} = require("chrome"); @@ -53,7 +53,7 @@ function runTests(findAndRunTests) { // are not correctly updated. // For ex: nsIFocusManager.getFocusedElementForWindow may throw // NS_ERROR_ILLEGAL_VALUE exception. - require("timer").setTimeout(function () { + require("../timers").setTimeout(function () { harness.runTests({ findAndRunTests: findAndRunTests, iterations: cfxArgs.iterations || 1, @@ -101,7 +101,7 @@ function main() { if (!testsStarted) { testsStarted = true; runTests(function findAndRunTests(loader, nextIteration) { - loader.require("api-utils/unit-test").findAndRunTests({ + loader.require("../deprecated/unit-test").findAndRunTests({ testOutOfProcess: false, testInProcess: true, stopOnError: cfxArgs.stopOnError, @@ -125,7 +125,7 @@ exports.runTestsFromModule = function runTestsFromModule(module) { runTests(function findAndRunTests(loader, nextIteration) { // Consider that all these tests are CommonJS ones - loader.require('api-utils/test').run(exports); + loader.require('../test').run(exports); // Reproduce what is done in unit-test-finder.findTests() let tests = []; @@ -139,7 +139,7 @@ exports.runTestsFromModule = function runTestsFromModule(module) { } // Reproduce what is done by unit-test.findAndRunTests() - var { TestRunner } = loader.require("api-utils/unit-test"); + var { TestRunner } = loader.require("../deprecated/unit-test"); var runner = new TestRunner(); runner.startMany({ tests: tests, diff --git a/packages/test-harness/lib/tmp-file.js b/lib/sdk/test/tmp-file.js similarity index 91% rename from packages/test-harness/lib/tmp-file.js rename to lib/sdk/test/tmp-file.js index 52a841397..634d2f1bf 100644 --- a/packages/test-harness/lib/tmp-file.js +++ b/lib/sdk/test/tmp-file.js @@ -5,12 +5,12 @@ const { Cc, Ci } = require("chrome"); -const system = require("api-utils/system"); -const file = require("api-utils/file"); -const unload = require("api-utils/unload"); +const system = require("sdk/system"); +const file = require("sdk/io/file"); +const unload = require("sdk/system/unload"); // Retrieve the path to the OS temporary directory: -const tmpDir = require("system").pathFor("TmpD"); +const tmpDir = require("sdk/system").pathFor("TmpD"); // List of all tmp file created let files = []; @@ -70,3 +70,4 @@ exports.createFromURL = function createFromURL(url, tmpName) { let data = readBinaryURI(url); return exports.createFromString(data, tmpName); } + diff --git a/packages/api-utils/lib/timer.js b/lib/sdk/timers.js similarity index 96% rename from packages/api-utils/lib/timer.js rename to lib/sdk/timers.js index 744f28f34..bc7271759 100644 --- a/packages/api-utils/lib/timer.js +++ b/lib/sdk/timers.js @@ -8,7 +8,7 @@ module.metadata = { }; const { CC, Ci } = require('chrome'); -const { when: unload } = require('./unload'); +const { when: unload } = require('./system/unload'); const { TYPE_ONE_SHOT, TYPE_REPEATING_SLACK } = Ci.nsITimer; const Timer = CC('@mozilla.org/timer;1', 'nsITimer'); diff --git a/packages/api-utils/lib/url.js b/lib/sdk/url.js similarity index 99% rename from packages/api-utils/lib/url.js rename to lib/sdk/url.js index e252e4e78..35813988f 100644 --- a/packages/api-utils/lib/url.js +++ b/lib/sdk/url.js @@ -10,7 +10,7 @@ module.metadata = { const { Cc, Ci, Cr } = require("chrome"); -const { Class } = require("./heritage"); +const { Class } = require("./core/heritage"); const base64 = require("./base64"); var ios = Cc['@mozilla.org/network/io-service;1'] diff --git a/packages/api-utils/lib/array.js b/lib/sdk/util/array.js similarity index 100% rename from packages/api-utils/lib/array.js rename to lib/sdk/util/array.js diff --git a/packages/api-utils/lib/collection.js b/lib/sdk/util/collection.js similarity index 100% rename from packages/api-utils/lib/collection.js rename to lib/sdk/util/collection.js diff --git a/packages/api-utils/lib/deprecate.js b/lib/sdk/util/deprecate.js similarity index 93% rename from packages/api-utils/lib/deprecate.js rename to lib/sdk/util/deprecate.js index bed1747ee..b38606aa7 100644 --- a/packages/api-utils/lib/deprecate.js +++ b/lib/sdk/util/deprecate.js @@ -8,7 +8,7 @@ module.metadata = { "stability": "experimental" }; -const traceback = require("./traceback"); +const traceback = require("../console/traceback"); function deprecateUsage(msg) { // Print caller stacktrace in order to help figuring out which code diff --git a/packages/api-utils/lib/list/new.js b/lib/sdk/util/list.js similarity index 95% rename from packages/api-utils/lib/list/new.js rename to lib/sdk/util/list.js index e369fbced..0a143d9ed 100644 --- a/packages/api-utils/lib/list/new.js +++ b/lib/sdk/util/list.js @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { Class } = require('../heritage'); -const listNS = require('../namespace').ns(); +const { Class } = require('../core/heritage'); +const listNS = require('../core/namespace').ns(); const List = Class({ /** diff --git a/packages/api-utils/lib/utils/object.js b/lib/sdk/util/object.js similarity index 100% rename from packages/api-utils/lib/utils/object.js rename to lib/sdk/util/object.js diff --git a/packages/api-utils/lib/utils/registry.js b/lib/sdk/util/registry.js similarity index 94% rename from packages/api-utils/lib/utils/registry.js rename to lib/sdk/util/registry.js index b1a526288..7d385f0b8 100644 --- a/packages/api-utils/lib/utils/registry.js +++ b/lib/sdk/util/registry.js @@ -9,8 +9,8 @@ module.metadata = { "stability": "unstable" }; -const { EventEmitter } = require('../events'); -const unload = require('../unload'); +const { EventEmitter } = require('../deprecated/events'); +const unload = require('../system/unload'); const Registry = EventEmitter.compose({ _registry: null, diff --git a/packages/api-utils/lib/uuid.js b/lib/sdk/util/uuid.js similarity index 100% rename from packages/api-utils/lib/uuid.js rename to lib/sdk/util/uuid.js diff --git a/packages/addon-kit/lib/widget.js b/lib/sdk/widget.js similarity index 97% rename from packages/addon-kit/lib/widget.js rename to lib/sdk/widget.js index 73a35b3c9..f1236aa54 100644 --- a/packages/addon-kit/lib/widget.js +++ b/lib/sdk/widget.js @@ -30,7 +30,7 @@ const EVENTS = { "mouseout": "mouseout", }; -if (!require("api-utils/xul-app").is("Firefox")) { +if (!require("./system/xul-app").is("Firefox")) { throw new Error([ "The widget module currently supports only Firefox. In the future ", "it will support other applications. Please see ", @@ -38,19 +38,19 @@ if (!require("api-utils/xul-app").is("Firefox")) { ].join("")); } -const { validateOptions } = require("api-utils/api-utils"); +const { validateOptions } = require("./deprecated/api-utils"); const panels = require("./panel"); -const { EventEmitter, EventEmitterTrait } = require("api-utils/events"); -const { Trait } = require("api-utils/traits"); -const LightTrait = require('api-utils/light-traits').Trait; -const { Loader, Symbiont } = require("api-utils/content"); -const { Cortex } = require('api-utils/cortex'); +const { EventEmitter, EventEmitterTrait } = require("./deprecated/events"); +const { Trait } = require("./deprecated/traits"); +const LightTrait = require('./deprecated/light-traits').Trait; +const { Loader, Symbiont } = require("./content/content"); +const { Cortex } = require('./deprecated/cortex'); const windowsAPI = require("./windows"); -const { WindowTracker } = require("api-utils/window-utils"); -const { isBrowser } = require("api-utils/window/utils"); -const { setTimeout } = require("api-utils/timer"); -const unload = require("api-utils/unload"); -const { uuid } = require("api-utils/uuid"); +const { WindowTracker } = require("./deprecated/window-utils"); +const { isBrowser } = require("./window/utils"); +const { setTimeout } = require("./timers"); +const unload = require("./system/unload"); +const { uuid } = require("./util/uuid"); // Data types definition const valid = { @@ -102,7 +102,7 @@ let widgetAttributes = { // Import data definitions from loader, but don't compose with it as Model // functions allow us to recreate easily all Loader code. -let loaderAttributes = require("api-utils/content/loader").validationAttributes; +let loaderAttributes = require("./content/loader").validationAttributes; for (let i in loaderAttributes) widgetAttributes[i] = loaderAttributes[i]; @@ -708,7 +708,7 @@ WidgetChrome.prototype._createNode = function WC__createNode() { // Temporary work around require("self") failing on unit-test execution ... let jetpackID = "testID"; try { - jetpackID = require("self").id; + jetpackID = require("./self").id; } catch(e) {} // Compute an unique and stable widget id with jetpack id and widget.id diff --git a/packages/api-utils/lib/window/browser.js b/lib/sdk/window/browser.js similarity index 85% rename from packages/api-utils/lib/window/browser.js rename to lib/sdk/window/browser.js index 14695843b..2b63a83e9 100644 --- a/packages/api-utils/lib/window/browser.js +++ b/lib/sdk/window/browser.js @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { Class } = require('../heritage'); +const { Class } = require('../core/heritage'); const { windowNS } = require('./namespace'); const { on, off, once } = require('../event/core'); -const { method } = require('../functional'); +const { method } = require('../lang/functional'); const { getWindowTitle } = require('./utils'); -const unload = require('../unload'); +const unload = require('../system/unload'); const { getMode } = require('../private-browsing/utils'); const { EventTarget } = require('../event/target'); @@ -31,8 +31,8 @@ const BrowserWindow = Class({ // NOTE: Fennec only has one window, which is assumed below // TODO: remove assumption below // NOTE: tabs requires windows - get tabs() require('addon-kit/tabs'), - get activeTab() require('addon-kit/tabs').activeTab, + get tabs() require('../tabs'), + get activeTab() require('../tabs').activeTab, on: method(on), removeListener: method(off), once: method(once), diff --git a/packages/api-utils/lib/window/namespace.js b/lib/sdk/window/namespace.js similarity index 80% rename from packages/api-utils/lib/window/namespace.js rename to lib/sdk/window/namespace.js index b01ce15d3..b486f888d 100644 --- a/packages/api-utils/lib/window/namespace.js +++ b/lib/sdk/window/namespace.js @@ -3,4 +3,4 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -exports.windowNS = require('../namespace').ns(); +exports.windowNS = require('../core/namespace').ns(); diff --git a/packages/api-utils/lib/window/utils.js b/lib/sdk/window/utils.js similarity index 98% rename from packages/api-utils/lib/window/utils.js rename to lib/sdk/window/utils.js index ee3a7fc53..d43161d47 100644 --- a/packages/api-utils/lib/window/utils.js +++ b/lib/sdk/window/utils.js @@ -8,13 +8,13 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'); -const array = require('../array'); +const array = require('../util/array'); const windowWatcher = Cc['@mozilla.org/embedcomp/window-watcher;1']. getService(Ci.nsIWindowWatcher); const appShellService = Cc['@mozilla.org/appshell/appShellService;1']. getService(Ci.nsIAppShellService); -const observers = require('api-utils/observer-service'); +const observers = require('../deprecated/observer-service'); const WM = Cc['@mozilla.org/appshell/window-mediator;1']. getService(Ci.nsIWindowMediator); diff --git a/packages/addon-kit/lib/windows.js b/lib/sdk/windows.js similarity index 68% rename from packages/addon-kit/lib/windows.js rename to lib/sdk/windows.js index 6bf19b814..15399c9c8 100644 --- a/packages/addon-kit/lib/windows.js +++ b/lib/sdk/windows.js @@ -7,11 +7,11 @@ module.metadata = { 'stability': 'stable' }; -if (require('api-utils/xul-app').is('Firefox')) { - module.exports = require('api-utils/windows/firefox'); +if (require('./system/xul-app').is('Firefox')) { + module.exports = require('./windows/firefox'); } -else if (require('api-utils/xul-app').is('Fennec')) { - module.exports = require('api-utils/windows/fennec'); +else if (require('./system/xul-app').is('Fennec')) { + module.exports = require('./windows/fennec'); } else { throw new Error([ diff --git a/packages/api-utils/lib/windows/dom.js b/lib/sdk/windows/dom.js similarity index 94% rename from packages/api-utils/lib/windows/dom.js rename to lib/sdk/windows/dom.js index 90270c0d3..ac2b86b05 100644 --- a/packages/api-utils/lib/windows/dom.js +++ b/lib/sdk/windows/dom.js @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { Trait } = require('../traits'); +const { Trait } = require('../deprecated/traits'); const { getWindowTitle } = require('../window/utils'); const { getMode } = require('../private-browsing/utils'); diff --git a/packages/api-utils/lib/windows/fennec.js b/lib/sdk/windows/fennec.js similarity index 88% rename from packages/api-utils/lib/windows/fennec.js rename to lib/sdk/windows/fennec.js index 843d530ae..91bb0b87c 100644 --- a/packages/api-utils/lib/windows/fennec.js +++ b/lib/sdk/windows/fennec.js @@ -3,16 +3,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { Class } = require('../heritage'); +const { Class } = require('../core/heritage'); const { BrowserWindow } = require('../window/browser'); -const windowUtils = require('../window-utils'); +const windowUtils = require('../deprecated/window-utils'); +const { isBrowser, WindowTracker } = windowUtils; const { windowNS } = require('../window/namespace'); const { on, off, once, emit } = require('../event/core'); -const { method } = require('../functional'); -const { WindowTracker } = require('../window-utils'); -const { isBrowser } = require('../window/utils'); +const { method } = require('../lang/functional'); const { EventTarget } = require('../event/target'); -const { List, addListItem } = require('../list/new'); +const { List, addListItem } = require('../util/list'); const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec, consider using require("tabs") instead'; diff --git a/packages/api-utils/lib/windows/firefox.js b/lib/sdk/windows/firefox.js similarity index 96% rename from packages/api-utils/lib/windows/firefox.js rename to lib/sdk/windows/firefox.js index 23d0ee272..de43dee00 100644 --- a/packages/api-utils/lib/windows/firefox.js +++ b/lib/sdk/windows/firefox.js @@ -4,19 +4,19 @@ 'use strict'; const { Cc, Ci, Cr } = require('chrome'), - { Trait } = require('../traits'), - { List } = require('../list'), - { EventEmitter } = require('../events'), + { Trait } = require('../deprecated/traits'), + { List } = require('../deprecated/list'), + { EventEmitter } = require('../deprecated/events'), { WindowTabs, WindowTabTracker } = require('./tabs-firefox'), { WindowDom } = require('./dom'), { WindowLoader } = require('./loader'), { isBrowser, getWindowDocShell } = require('../window/utils'), { Options } = require('../tabs/common'), - apiUtils = require('../api-utils'), - unload = require('unload'), - windowUtils = require('../window-utils'), + apiUtils = require('../deprecated/api-utils'), + unload = require('../system/unload'), + windowUtils = require('../deprecated/window-utils'), { WindowTrackerTrait } = windowUtils, - { ns } = require('namespace'), + { ns } = require('../core/namespace'), { observer: windowObserver } = require('./observer'), { isWindowPBEnabled } = require('../private-browsing/utils'); diff --git a/packages/api-utils/lib/windows/loader.js b/lib/sdk/windows/loader.js similarity index 97% rename from packages/api-utils/lib/windows/loader.js rename to lib/sdk/windows/loader.js index 54a9e2c92..be3d84ce6 100644 --- a/packages/api-utils/lib/windows/loader.js +++ b/lib/sdk/windows/loader.js @@ -8,8 +8,8 @@ module.metadata = { }; const { Cc, Ci } = require('chrome'), - { setTimeout } = require('../timer'), - { Trait } = require('../traits'), + { setTimeout } = require('../timers'), + { Trait } = require('../deprecated/traits'), { openDialog } = require('../window/utils'), ON_LOAD = 'load', diff --git a/packages/api-utils/lib/windows/observer.js b/lib/sdk/windows/observer.js similarity index 83% rename from packages/api-utils/lib/windows/observer.js rename to lib/sdk/windows/observer.js index 877b20fba..1097bf399 100644 --- a/packages/api-utils/lib/windows/observer.js +++ b/lib/sdk/windows/observer.js @@ -8,10 +8,10 @@ module.metadata = { "stability": "unstable" }; -const { EventEmitterTrait: EventEmitter } = require("../events"); -const { WindowTracker, windowIterator } = require("../window-utils"); -const { DOMEventAssembler } = require("../events/assembler"); -const { Trait } = require("../light-traits"); +const { EventEmitterTrait: EventEmitter } = require("../deprecated/events"); +const { WindowTracker, windowIterator } = require("../deprecated/window-utils"); +const { DOMEventAssembler } = require("../deprecated/events/assembler"); +const { Trait } = require("../deprecated/light-traits"); // Event emitter objects used to register listeners and emit events on them // when they occur. diff --git a/packages/api-utils/lib/windows/tabs-fennec.js b/lib/sdk/windows/tabs-fennec.js similarity index 94% rename from packages/api-utils/lib/windows/tabs-fennec.js rename to lib/sdk/windows/tabs-fennec.js index 3b2f83a1d..ddf4aebbb 100644 --- a/packages/api-utils/lib/windows/tabs-fennec.js +++ b/lib/sdk/windows/tabs-fennec.js @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { Class } = require('../heritage'); +const { Class } = require('../core/heritage'); const { Tab } = require('../tabs/tab'); const { browserWindows } = require('./fennec'); const { windowNS } = require('../window/namespace'); @@ -11,12 +11,12 @@ const { tabsNS, tabNS } = require('../tabs/namespace'); const { openTab, getTabs, getSelectedTab } = require('../tabs/utils'); const { Options } = require('../tabs/common'); const { on, once, off, emit } = require('../event/core'); -const { method } = require('../functional'); +const { method } = require('../lang/functional'); const { EVENTS } = require('../tabs/events'); const { EventTarget } = require('../event/target'); -const { when: unload } = require('../unload'); -const { windowIterator } = require('../window-utils'); -const { List, addListItem, removeListItem } = require('../list/new'); +const { when: unload } = require('../system/unload'); +const { windowIterator } = require('../deprecated/window-utils'); +const { List, addListItem, removeListItem } = require('../util/list'); const mainWindow = windowNS(browserWindows.activeWindow).window; diff --git a/packages/api-utils/lib/windows/tabs-firefox.js b/lib/sdk/windows/tabs-firefox.js similarity index 97% rename from packages/api-utils/lib/windows/tabs-firefox.js rename to lib/sdk/windows/tabs-firefox.js index d7b50c524..f41e7529a 100644 --- a/packages/api-utils/lib/windows/tabs-firefox.js +++ b/lib/sdk/windows/tabs-firefox.js @@ -7,10 +7,10 @@ module.metadata = { "stability": "unstable" }; -const { Trait } = require("../traits"); -const { List } = require("../list"); +const { Trait } = require("../deprecated/traits"); +const { List } = require("../deprecated/list"); const { Tab } = require("../tabs/tab"); -const { EventEmitter } = require("../events"); +const { EventEmitter } = require("../deprecated/events"); const { EVENTS } = require("../tabs/events"); const { getOwnerWindow, getActiveTab, getTabs, openTab, activateTab } = require("../tabs/utils"); diff --git a/packages/api-utils/lib/loader.js b/lib/toolkit/loader.js similarity index 99% rename from packages/api-utils/lib/loader.js rename to lib/toolkit/loader.js index 28ead692e..09a9889aa 100644 --- a/packages/api-utils/lib/loader.js +++ b/lib/toolkit/loader.js @@ -169,6 +169,7 @@ const evaluate = iced(function evaluate(sandbox, uri, options) { source: null }, options); + return source ? Cu.evalInSandbox(source, sandbox, version, uri, line) : loadSubScript(uri, sandbox, encoding); }); @@ -396,3 +397,4 @@ const Loader = iced(function Loader(options) { exports.Loader = Loader; }); + diff --git a/mapping.json b/mapping.json new file mode 100644 index 000000000..dd6d42361 --- /dev/null +++ b/mapping.json @@ -0,0 +1,81 @@ +{ + "api-utils": "sdk/deprecated/api-utils", + "base64": "sdk/base64", + "content": "sdk/content/content", + "deprecate": "sdk/util/deprecate", + "event/core": "sdk/event/core", + "events": "sdk/deprecated/events", + "functional": "sdk/core/functional", + "l10n/core": "sdk/l10n/core", + "l10n/html": "sdk/l10n/html", + "l10n/loader": "sdk/l10n/loader", + "l10n/locale": "sdk/l10n/locale", + "l10n/prefs": "sdk/l10n/prefs", + "list": "sdk/util/list", + "loader": "sdk/loader/loader", + "memory": "sdk/deprecated/memory", + "namespace": "sdk/core/namespace", + "observer-service": "sdk/deprecated/observer-service", + "preferences-service": "sdk/preferences/service", + "promise": "sdk/core/promise", + "system": "sdk/system", + "system/events": "sdk/system/events", + "tabs/tab": "sdk/tabs/tab", + "tabs/utils": "sdk/tabs/utils", + "timer": "sdk/timers", + "traits": "sdk/deprecated/traits", + "unload": "sdk/system/unload", + "window-utils": "sdk/deprecated/window-utils", + "window/utils": "sdk/window/utils", + "windows/dom": "sdk/windows/dom", + "windows/loader": "sdk/windows/loader", + "xul-app": "sdk/system/xul-app", + "url": "sdk/url", + "traceback": "sdk/console/traceback", + "xhr": "sdk/net/xhr", + "match-pattern": "sdk/page-mod/match-pattern", + "tab-browser": "sdk/deprecated/tab-browser", + "file": "sdk/io/file", + "runtime": "sdk/system/runtime", + "xpcom": "sdk/platform/xpcom", + "querystring": "sdk/querystring", + "text-streams": "sdk/io/text-streams", + "app-strings": "sdk/deprecated/app-strings", + "light-traits": "sdk/deprecated/light-traits", + "environment": "sdk/system/environment", + "keyboard/utils": "sdk/keyboard/utils", + "dom/events": "sdk/dom/events", + "utils/data": "sdk/io/data", + "test/assert": "sdk/test/assert", + "hidden-frame": "sdk/frame/hidden-frame", + "collection": "sdk/util/collection", + "array": "sdk/util/array", + "cortex": "sdk/deprecated/cortex", + + + "addon-page": "sdk/addon-page", + "clipboard": "sdk/clipboard", + "context-menu": "sdk/context-menu", + "hotkeys": "sdk/hotkeys", + "indexed-db": "sdk/indexed-db", + "l10n": "sdk/l10n", + "notifications": "sdk/notifications", + "page-mod": "sdk/page-mod", + "page-worker": "sdk/page-worker", + "panel": "sdk/panel", + "passwords": "sdk/passwords", + "private-browsing": "sdk/private-browsing", + "request": "sdk/request", + "selection": "sdk/selection", + "self": "sdk/self", + "simple-prefs": "sdk/simple-prefs", + "simple-storage": "sdk/simple-storage", + "tabs": "sdk/tabs", + "timers": "sdk/timers", + "widget": "sdk/widget", + "windows": "sdk/windows", + + "harness": "sdk/test/harness", + "run-tests": "sdk/test/runner", + "test": "sdk/test" +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..7519eb603 --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "addon-sdk", + "description": "Add-on development made easy.", + "keywords": [ + "javascript", "engine", "addon", "extension", + "xulrunner", "firefox", "browser" + ], + "loader": "lib/sdk/loader/cuddlefish.js", + "license": "MPL 2.0" +} diff --git a/packages/addon-kit/README.md b/packages/addon-kit/README.md deleted file mode 100644 index cfbb4dfa2..000000000 --- a/packages/addon-kit/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -The addon-kit package provides high-level APIs for add-on developers. -Most of the needs of most add-on developers should be served by the modules -found here. Modules in this packages don't require any special privileges to -run. - -The modules in the addon-kit package are relatively stable. We intend to add -new APIs here and extend existing ones, but will avoid making incompatible -changes to them unless absolutely necessary. diff --git a/packages/addon-kit/lib/timers.js b/packages/addon-kit/lib/timers.js deleted file mode 100644 index 4297b3232..000000000 --- a/packages/addon-kit/lib/timers.js +++ /dev/null @@ -1,12 +0,0 @@ -/* 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": "stable" -}; - -// This module just proxies to the low level equivalent "timer" in "api-utils". -module.exports = require("api-utils/timer"); diff --git a/packages/addon-kit/package.json b/packages/addon-kit/package.json deleted file mode 100644 index 8cd643f87..000000000 --- a/packages/addon-kit/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "addon-kit", - "description": "Add-on development made easy.", - "keywords": ["javascript", "engine", "platform", "xulrunner", "jetpack-high-level"], - "author": "Atul Varma (http://toolness.com/) ", - "contributors": [ - "Myk Melez (http://melez.com/) ", - "Daniel Aquino " - ], - "license": "MPL 2.0", - "dependencies": ["api-utils"] -} diff --git a/packages/addon-kit/tests/test-timers.js b/packages/addon-kit/tests/test-timers.js deleted file mode 100644 index 90b26bfc1..000000000 --- a/packages/addon-kit/tests/test-timers.js +++ /dev/null @@ -1,12 +0,0 @@ -/* 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/. */ -const timers = require("timers"); - -exports.testTimeout = function (test) { - test.waitUntilDone(); - timers.setTimeout(function () { - test.pass("timers.setTimeout works"); - test.done(); - }, 0); -} diff --git a/packages/api-utils/README.md b/packages/api-utils/README.md deleted file mode 100644 index 55adb57cc..000000000 --- a/packages/api-utils/README.md +++ /dev/null @@ -1,35 +0,0 @@ - - -API Utils provides a basic CommonJS infrastructure for -developing traditional XULRunner add-ons and applications. It is -the basis for the Add-on SDK. - -To address issues present in traditional add-on development, -API Utils provides mechanisms for: - -* writing and executing test cases, inspired by Python's [nose][] - package, -* tracking JS objects of interest to aid in memory profiling and leak - detection, -* registering callbacks that perform cleanup tasks when modules are - unloaded, -* easily reporting errors with full stack tracebacks. - -API Utils also has the following characteristics: - -* Beautiful, concise documentation. -* A rigorous test suite ensuring that the library doesn't break as the - Mozilla platform evolves. -* Solid developer ergonomics ensuring that developers can easily find - out why something they're doing isn't working. - -API Utils is intended to be very small and only contain the bare -minimum of functionality that all add-ons need. - -Note that the API Utils package has not fully stabilized yet, meaning that -we do still expect to make incompatible changes to its APIs in future releases -of the SDK. - - [nose]: http://code.google.com/p/python-nose/ diff --git a/packages/api-utils/lib/find-tests.js b/packages/api-utils/lib/find-tests.js deleted file mode 100644 index 60550bf7b..000000000 --- a/packages/api-utils/lib/find-tests.js +++ /dev/null @@ -1,5 +0,0 @@ -/* 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/. */ - -// this file left intentionally blank diff --git a/packages/api-utils/package.json b/packages/api-utils/package.json deleted file mode 100644 index 1e777feb9..000000000 --- a/packages/api-utils/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "api-utils", - "description": "Foundational infrastructure and utilities.", - "keywords": ["javascript", "engine", "platform", "xulrunner", - "jetpack-low-level"], - "author": "Atul Varma (http://toolness.com/) ", - "contributors": [ - "Myk Melez (http://melez.com/) ", - "Daniel Aquino " - ], - "license": "MPL 2.0", - "dependencies": ["addon-kit"], - "loader": "lib/cuddlefish.js" -} diff --git a/packages/test-harness/README.md b/packages/test-harness/README.md deleted file mode 100644 index b22824b9a..000000000 --- a/packages/test-harness/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - - -For more information on testing in the Add-on SDK, see the -[Unit Testing](dev-guide/tutorials/unit-testing.html) -tutorial. - - -This package contains a program that finds and runs tests. It is -automatically used whenever the `cfx test` command is executed. diff --git a/packages/test-harness/package.json b/packages/test-harness/package.json deleted file mode 100644 index b44fb069f..000000000 --- a/packages/test-harness/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "test-harness", - "description": "A harness for running Jetpack tests.", - "author": "Atul Varma (http://toolness.com/)", - "keywords": ["jetpack-low-level"], - "license": "MPL 2.0", - "dependencies": ["api-utils"] -} diff --git a/python-lib/cuddlefish/__init__.py b/python-lib/cuddlefish/__init__.py index 8a29b1c25..7a40a5cba 100644 --- a/python-lib/cuddlefish/__init__.py +++ b/python-lib/cuddlefish/__init__.py @@ -119,9 +119,9 @@ (("", "--extra-packages",), dict(dest="extra_packages", help=("extra packages to include, " "comma-separated. Default is " - "'addon-kit'."), + "'addon-sdk'."), metavar=None, - default="addon-kit", + default="addon-sdk", cmds=['run', 'xpi', 'test', 'testex', 'testpkgs', 'testall', 'testcfx'])), @@ -216,7 +216,7 @@ "containing test runner " "program (default is " "test-harness)"), - default="test-harness", + default="addon-sdk", cmds=['test', 'testex', 'testpkgs', 'testall'])), # --keydir was removed in 1.0b5, but we keep it around in the options @@ -425,8 +425,12 @@ def test_all_examples(env_root, defaults): def test_all_packages(env_root, defaults): packages_dir = os.path.join(env_root, "packages") - packages = [dirname for dirname in os.listdir(packages_dir) - if os.path.isdir(os.path.join(packages_dir, dirname))] + if os.path.isdir(packages_dir): + packages = [dirname for dirname in os.listdir(packages_dir) + if os.path.isdir(os.path.join(packages_dir, dirname))] + else: + packages = [] + packages.append(env_root) packages.sort() print >>sys.stderr, "Testing all available packages: %s." % (", ".join(packages)) sys.stderr.flush() @@ -573,7 +577,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, elif command == "docs": from cuddlefish.docs import generate if len(args) > 1: - docs_home = generate.generate_named_file(env_root, filename=args[1]) + docs_home = generate.generate_named_file(env_root, filename_and_path=args[1]) else: docs_home = generate.generate_local_docs(env_root) webbrowser.open(docs_home) @@ -690,11 +694,11 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, # the choice of loader for manifest-generation purposes. In practice, # this means that alternative loaders probably won't work with # --strip-xpi. - assert packaging.DEFAULT_LOADER == "api-utils" - assert pkg_cfg.packages["api-utils"].loader == "lib/cuddlefish.js" - cuddlefish_js_path = os.path.join(pkg_cfg.packages["api-utils"].root_dir, - "lib", "cuddlefish.js") - loader_modules = [("api-utils", "lib", "cuddlefish", cuddlefish_js_path)] + assert packaging.DEFAULT_LOADER == "addon-sdk" + assert pkg_cfg.packages["addon-sdk"].loader == "lib/sdk/loader/cuddlefish.js" + cuddlefish_js_path = os.path.join(pkg_cfg.packages["addon-sdk"].root_dir, + "lib", "sdk", "loader", "cuddlefish.js") + loader_modules = [("addon-sdk", "lib", "sdk/loader/cuddlefish", cuddlefish_js_path)] scan_tests = command == "test" test_filter_re = None if scan_tests and options.filter: @@ -740,8 +744,8 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, if command == "test": # This should be contained in the test runner package. # maybe just do: target_cfg.main = 'test-harness/run-tests' - harness_options['main'] = 'test-harness/run-tests' - harness_options['mainPath'] = manifest.get_manifest_entry("test-harness", "lib", "run-tests").get_path() + harness_options['main'] = 'sdk/test/runner' + harness_options['mainPath'] = manifest.get_manifest_entry("addon-sdk", "lib", "sdk/test/runner").get_path() else: harness_options['main'] = target_cfg.get('main') harness_options['mainPath'] = manifest.top_path diff --git a/python-lib/cuddlefish/app-extension/bootstrap.js b/python-lib/cuddlefish/app-extension/bootstrap.js index 2704cd480..7850a62f2 100644 --- a/python-lib/cuddlefish/app-extension/bootstrap.js +++ b/python-lib/cuddlefish/app-extension/bootstrap.js @@ -177,10 +177,10 @@ function startup(data, reasonCode) { } }); - let module = cuddlefish.Module('api-utils/cuddlefish', cuddlefishURI); + let module = cuddlefish.Module('addon-sdk/sdk/loader/cuddlefish', cuddlefishURI); let require = cuddlefish.Require(loader, module); - require('api-utils/addon/runner').startup(reason, { + require('sdk/addon/runner').startup(reason, { loader: loader, main: main, prefsURI: rootURI + 'defaults/preferences/prefs.js' diff --git a/python-lib/cuddlefish/docs/documentationitem.py b/python-lib/cuddlefish/docs/documentationitem.py new file mode 100755 index 000000000..7e33a4e84 --- /dev/null +++ b/python-lib/cuddlefish/docs/documentationitem.py @@ -0,0 +1,88 @@ +# 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/. + +import sys, os + +class DocumentationItemInfo(object): + def __init__(self, root, md_path, filename): + # SDK-root + "doc" + "sdk" + self.root = root + # full path to MD file, without filename + self.source_path = md_path + # MD filename + self.source_filename = filename + + def root(self): + return self.root + + def source_path(self): + return self.source_path + + def source_filename(self): + return self.source_filename + + def base_filename(self): + return self.source_filename[:-len(".md")] + + def source_path_and_filename(self): + return os.sep.join([self.source_path, self.source_filename]) + + def source_path_relative_from_root(self): + return self.source_path[len(self.root) + 1:] + +class DevGuideItemInfo(DocumentationItemInfo): + def __init__(self, root, md_path, filename): + DocumentationItemInfo.__init__(self, root, md_path, filename) + + def destination_path(self): + root_pieces = self.root.split(os.sep) + root_pieces[-1] = "dev-guide" + return os.sep.join([os.sep.join(root_pieces), self.source_path_relative_from_root()]) + +class ModuleInfo(DocumentationItemInfo): + def __init__(self, root, md_path, filename): + DocumentationItemInfo.__init__(self, root, md_path, filename) + + def destination_path(self): + root_pieces = self.root.split(os.sep) + root_pieces[-1] = "modules" + relative_pieces = self.source_path_relative_from_root().split(os.sep) + return os.sep.join(root_pieces + relative_pieces) + + def relative_url(self): + relative_pieces = self.source_path_relative_from_root().split(os.sep) + return "/".join(relative_pieces) + "/" + self.base_filename() + ".html" + + def name(self): + if os.sep.join([self.root, "sdk"]) == self.source_path: + return self.source_filename[:-3] + else: + path_from_root_pieces = self.source_path_relative_from_root().split(os.sep) + return "/".join(["/".join(path_from_root_pieces[1:]), self.source_filename[:-len(".md")]]) + + def level(self): + if os.sep.join([self.root, "sdk"]) == self.source_path: + return "high" + else: + return "low" + +def get_module_list(root): + module_list = [] + for (dirpath, dirnames, filenames) in os.walk(root): + for filename in filenames: + if filename.endswith(".md"): + module_list.append(ModuleInfo(root, dirpath, filename)) + return module_list + +def get_devguide_list(root): + devguide_list = [] + for (dirpath, dirnames, filenames) in os.walk(root): + for filename in filenames: + if filename.endswith(".md"): + devguide_list.append(DevGuideItemInfo(root, dirpath, filename)) + return devguide_list + +if __name__ == "__main__": + module_list = get_module_list(sys.argv[1]) + print [module_info.name for module_info in module_list] diff --git a/python-lib/cuddlefish/docs/generate.py b/python-lib/cuddlefish/docs/generate.py old mode 100644 new mode 100755 index 0183f032f..65a03e6c7 --- a/python-lib/cuddlefish/docs/generate.py +++ b/python-lib/cuddlefish/docs/generate.py @@ -8,13 +8,15 @@ import hashlib import tarfile import StringIO -import HTMLParser -import urlparse -from cuddlefish import packaging from cuddlefish.docs import apiparser from cuddlefish.docs import apirenderer from cuddlefish.docs import webdocs +from documentationitem import get_module_list +from documentationitem import get_devguide_list +from documentationitem import ModuleInfo +from documentationitem import DevGuideItemInfo +from linkrewriter import rewrite_links import simplejson as json DIGEST = "status.md5" @@ -37,7 +39,7 @@ def clean_generated_docs(docs_dir): dev_guide_dir = os.path.join(docs_dir, "dev-guide") if os.path.exists(dev_guide_dir): shutil.rmtree(dev_guide_dir) - api_doc_dir = os.path.join(docs_dir, "packages") + api_doc_dir = os.path.join(docs_dir, "modules") if os.path.exists(api_doc_dir): shutil.rmtree(api_doc_dir) @@ -52,16 +54,18 @@ def generate_static_docs(env_root): def generate_local_docs(env_root): return generate_docs(env_root, get_base_url(env_root)) -def generate_named_file(env_root, filename): +def generate_named_file(env_root, filename_and_path): web_docs = webdocs.WebDocs(env_root, get_base_url(env_root)) - # next, generate api doc or guide doc - abs_path = os.path.abspath(filename) - if abs_path.startswith(os.path.join(env_root, 'packages')): - doc_html, dest_dir, filename = generate_api_doc(env_root, abs_path, web_docs) - write_file(env_root, doc_html, dest_dir, filename, False) + abs_path = os.path.abspath(filename_and_path) + path, filename = os.path.split(abs_path) + if abs_path.startswith(os.path.join(env_root, 'doc', 'module-source')): + module_root = os.sep.join([env_root, "doc", "module-source"]) + module_info = ModuleInfo(module_root, path, filename) + write_module_doc(env_root, web_docs, module_info, False) elif abs_path.startswith(os.path.join(get_sdk_docs_path(env_root), 'dev-guide-source')): - doc_html, dest_dir, filename = generate_guide_doc(env_root, abs_path, web_docs) - write_file(env_root, doc_html, dest_dir, filename, False) + devguide_root = os.sep.join([env_root, "doc", "dev-guide-source"]) + devguideitem_info = DevGuideItemInfo(devguide_root, path, filename) + write_devguide_doc(env_root, web_docs, devguideitem_info, False) else: raise ValueError("Not a valid path to a documentation file") @@ -87,13 +91,14 @@ def generate_docs(env_root, base_url=None, stdout=sys.stdout): return get_base_url(env_root) + "index.html" # this function builds a hash of the name and last modification date of: -# * every file in "packages" which ends in ".md" -# * every file in "static-files" which does not start with "." +# * every file in "doc/sdk" which ends in ".md" +# * every file in "doc/dev-guide-source" which ends in ".md" +# * every file in "doc/static-files" which does not start with "." def calculate_current_status(env_root): docs_dir = get_sdk_docs_path(env_root) current_status = hashlib.md5() - package_src_dir = os.path.join(env_root, "packages") - for (dirpath, dirnames, filenames) in os.walk(package_src_dir): + module_src_dir = os.path.join(env_root, "doc", "module-source") + for (dirpath, dirnames, filenames) in os.walk(module_src_dir): for filename in filenames: if filename.endswith(".md"): current_status.update(filename) @@ -124,67 +129,29 @@ def generate_docs_from_scratch(env_root, base_url): if n.endswith("~"): os.unlink(os.path.join(dirpath, n)) - # generate api docs from all packages - os.mkdir(os.path.join(docs_dir, "packages")) - # create the index file and save that - pkg_cfg = packaging.build_pkg_cfg(env_root) - index = json.dumps(packaging.build_pkg_index(pkg_cfg)) - index_path = os.path.join(docs_dir, "packages", 'index.json') - open(index_path, 'w').write(index) + # generate api docs for all modules + if not os.path.exists(os.path.join(docs_dir, "modules")): + os.mkdir(os.path.join(docs_dir, "modules")) + module_root = os.sep.join([env_root, "doc", "module-source"]) + module_list = get_module_list(module_root) + [write_module_doc(env_root, web_docs, module_info, must_rewrite_links) for module_info in module_list] - # for each package, generate its docs - for pkg_name, pkg in pkg_cfg['packages'].items(): - src_dir = pkg.root_dir - package_dirname = os.path.basename(src_dir) - dest_dir = os.path.join(docs_dir, "packages", package_dirname) - os.mkdir(dest_dir) - - src_readme = os.path.join(src_dir, "README.md") - if os.path.exists(src_readme): - shutil.copyfile(src_readme, - os.path.join(dest_dir, "README.md")) - - # create the package page - package_filename = os.path.join(dest_dir, "index.html") - if not os.path.exists(package_filename): - package_doc_html = web_docs.create_package_page(pkg_name) - replace_file(env_root, package_filename, package_doc_html, must_rewrite_links) - - # generate all the API docs - docs_src_dir = os.path.join(src_dir, "doc") - if os.path.isdir(os.path.join(src_dir, "docs")): - docs_src_dir = os.path.join(src_dir, "docs") - generate_file_tree(env_root, docs_src_dir, web_docs, generate_api_doc, must_rewrite_links) - - # generate all the guide docs - dev_guide_src = os.path.join(docs_dir, "dev-guide-source") - generate_file_tree(env_root, dev_guide_src, web_docs, generate_guide_doc, must_rewrite_links) + # generate dev-guide docs + devguide_root = os.sep.join([env_root, "doc", "dev-guide-source"]) + devguide_list = get_devguide_list(devguide_root) + [write_devguide_doc(env_root, web_docs, devguide_info, must_rewrite_links) for devguide_info in devguide_list] # make /md/dev-guide/welcome.html the top level index file - doc_html, dest_dir, filename = generate_guide_doc(env_root, os.path.join(docs_dir, 'dev-guide-source', 'index.md'), web_docs) + doc_html = web_docs.create_guide_page(os.path.join(docs_dir, 'dev-guide-source', 'index.md')) write_file(env_root, doc_html, docs_dir, 'index', False) -def generate_file_tree(env_root, src_dir, web_docs, generate_file, must_rewrite_links): - for (dirpath, dirnames, filenames) in os.walk(src_dir): - assert dirpath.startswith(src_dir) # what is this for?? - for filename in filenames: - if filename.endswith("~"): - continue - src_path = os.path.join(dirpath, filename) - if src_path.endswith(".md"): - # write the standalone HTML files - doc_html, dest_dir, filename = generate_file(env_root, src_path, web_docs) - write_file(env_root, doc_html, dest_dir, filename, must_rewrite_links) - -def generate_api_doc(env_root, src_dir, web_docs): - doc_html = web_docs.create_module_page(src_dir) - dest_dir, filename = get_api_doc_dest_path(env_root, src_dir) - return doc_html, dest_dir, filename +def write_module_doc(env_root, web_docs, module_info, must_rewrite_links): + doc_html = web_docs.create_module_page(module_info.source_path_and_filename()) + write_file(env_root, doc_html, module_info.destination_path(), module_info.base_filename(), must_rewrite_links) -def generate_guide_doc(env_root, src_dir, web_docs): - doc_html = web_docs.create_guide_page(src_dir) - dest_dir, filename = get_guide_doc_dest_path(env_root, src_dir) - return doc_html, dest_dir, filename +def write_devguide_doc(env_root, web_docs, devguide_info, must_rewrite_links): + doc_html = web_docs.create_guide_page(devguide_info.source_path_and_filename()) + write_file(env_root, doc_html, devguide_info.destination_path(), devguide_info.base_filename(), must_rewrite_links) def write_file(env_root, doc_html, dest_dir, filename, must_rewrite_links): if not os.path.exists(dest_dir): @@ -199,94 +166,5 @@ def replace_file(env_root, dest_path, file_contents, must_rewrite_links): # before we copy the final version, we'll rewrite the links # I'll do this last, just because we know definitely what the dest_path is at this point if must_rewrite_links and dest_path.endswith(".html"): - file_contents = rewrite_links(env_root, file_contents, dest_path) + file_contents = rewrite_links(env_root, get_sdk_docs_path(env_root), file_contents, dest_path) open(dest_path, "w").write(file_contents) - -def rewrite_links(env_root, page, dest_path): - dest_path_depth = len(dest_path.split(os.sep)) -1 # because dest_path includes filename - docs_root_depth = len(get_sdk_docs_path(env_root).split(os.sep)) - relative_depth = dest_path_depth - docs_root_depth - linkRewriter = LinkRewriter("../" * relative_depth) - return linkRewriter.rewrite_links(page) - -# Given the full path to an API source file, and the root, -# return a tuple of: -# 1) the full path to the corresponding HTML file, without the filename -# 2) the filename without the extension -def get_guide_doc_dest_path(env_root, src_dir): - src_dir_relative = src_dir[len(os.path.join(get_sdk_docs_path(env_root), "dev-guide-source")) + 1:] - return os.path.split(os.path.join(get_sdk_docs_path(env_root), "dev-guide", src_dir_relative)[:-3]) - -# Given the full path to a dev guide source file, and the root, -# return a tuple of: -# 1) the full path to the corresponding HTML file, without the filename -# 2) the filename without the extension -def get_api_doc_dest_path(env_root, src_dir): - src_dir_relative = src_dir[len(env_root) + 1:] - src_dir_relative_pieces = src_dir_relative.split(os.sep) - del src_dir_relative_pieces[2] - src_dir_relative = os.sep.join(src_dir_relative_pieces) - return os.path.split(os.path.join(get_sdk_docs_path(env_root), src_dir_relative)[:-3]) - -class LinkRewriter(HTMLParser.HTMLParser): - def __init__(self, link_prefix): - HTMLParser.HTMLParser.__init__(self) - self.stack = [] - self.link_prefix = link_prefix - - def rewrite_links(self, page): - self.feed(page) - self.close() - page = ''.join(self.stack) - self.stack = [] - return page - - def handle_decl(self, decl): - self.stack.append("") - - def handle_comment(self, decl): - self.stack.append("") - - def handle_starttag(self, tag, attrs): - self.stack.append(self.__html_start_tag(tag, self._rewrite_link(attrs))) - - def handle_entityref(self, name): - self.stack.append("&" + name + ";") - - def handle_endtag(self, tag): - self.stack.append(self.__html_end_tag(tag)) - - def handle_startendtag(self, tag, attrs): - self.stack.append(self.__html_startend_tag(tag, self._rewrite_link(attrs))) - - def _rewrite_link(self, attrs): - attrs = dict(attrs) - href = attrs.get('href', '') - if href: - parsed = urlparse.urlparse(href) - if not parsed.scheme: - attrs['href'] = self.link_prefix + href - src = attrs.get('src', '') - if src: - parsed = urlparse.urlparse(src) - if not parsed.scheme: - attrs['src'] = self.link_prefix + src - return attrs - - def handle_data(self, data): - self.stack.append(data) - - def __html_start_tag(self, tag, attrs): - return '<%s%s>' % (tag, self.__html_attrs(attrs)) - - def __html_startend_tag(self, tag, attrs): - return '<%s%s/>' % (tag, self.__html_attrs(attrs)) - - def __html_end_tag(self, tag): - return '' % (tag) - - def __html_attrs(self, attrs): - _attrs = '' - if attrs: - _attrs = ' %s' % (' '.join([('%s="%s"' % (k,v)) for k,v in dict(attrs).iteritems()])) - return _attrs diff --git a/python-lib/cuddlefish/docs/linkrewriter.py b/python-lib/cuddlefish/docs/linkrewriter.py new file mode 100644 index 000000000..8c3407723 --- /dev/null +++ b/python-lib/cuddlefish/docs/linkrewriter.py @@ -0,0 +1,78 @@ +# 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/. + +import os +import sys +import HTMLParser +import urlparse + +def rewrite_links(env_root, sdk_docs_path, page, dest_path): + dest_path_depth = len(dest_path.split(os.sep)) -1 # because dest_path includes filename + docs_root_depth = len(sdk_docs_path.split(os.sep)) + relative_depth = dest_path_depth - docs_root_depth + linkRewriter = LinkRewriter("../" * relative_depth) + return linkRewriter.rewrite_links(page) + +class LinkRewriter(HTMLParser.HTMLParser): + def __init__(self, link_prefix): + HTMLParser.HTMLParser.__init__(self) + self.stack = [] + self.link_prefix = link_prefix + + def rewrite_links(self, page): + self.feed(page) + self.close() + page = ''.join(self.stack) + self.stack = [] + return page + + def handle_decl(self, decl): + self.stack.append("") + + def handle_comment(self, decl): + self.stack.append("") + + def handle_starttag(self, tag, attrs): + self.stack.append(self.__html_start_tag(tag, self._rewrite_link(attrs))) + + def handle_entityref(self, name): + self.stack.append("&" + name + ";") + + def handle_endtag(self, tag): + self.stack.append(self.__html_end_tag(tag)) + + def handle_startendtag(self, tag, attrs): + self.stack.append(self.__html_startend_tag(tag, self._rewrite_link(attrs))) + + def _rewrite_link(self, attrs): + attrs = dict(attrs) + href = attrs.get('href', '') + if href: + parsed = urlparse.urlparse(href) + if not parsed.scheme: + attrs['href'] = self.link_prefix + href + src = attrs.get('src', '') + if src: + parsed = urlparse.urlparse(src) + if not parsed.scheme: + attrs['src'] = self.link_prefix + src + return attrs + + def handle_data(self, data): + self.stack.append(data) + + def __html_start_tag(self, tag, attrs): + return '<%s%s>' % (tag, self.__html_attrs(attrs)) + + def __html_startend_tag(self, tag, attrs): + return '<%s%s/>' % (tag, self.__html_attrs(attrs)) + + def __html_end_tag(self, tag): + return '' % (tag) + + def __html_attrs(self, attrs): + _attrs = '' + if attrs: + _attrs = ' %s' % (' '.join([('%s="%s"' % (k,v)) for k,v in dict(attrs).iteritems()])) + return _attrs diff --git a/python-lib/cuddlefish/docs/webdocs.py b/python-lib/cuddlefish/docs/webdocs.py old mode 100644 new mode 100755 index dcecc78eb..7c30e5088 --- a/python-lib/cuddlefish/docs/webdocs.py +++ b/python-lib/cuddlefish/docs/webdocs.py @@ -9,28 +9,17 @@ from cuddlefish import packaging from cuddlefish.docs import apirenderer from cuddlefish._version import get_versions +from documentationitem import get_module_list INDEX_PAGE = '/doc/static-files/base.html' BASE_URL_INSERTION_POINT = '\n' return result -def is_third_party(package_json): - return (not is_high_level(package_json)) and \ - (not(is_low_level(package_json))) - -def is_high_level(package_json): - return 'jetpack-high-level' in package_json.get('keywords', []) - -def is_low_level(package_json): - return 'jetpack-low-level' in package_json.get('keywords', []) - def insert_after(target, insertion_point_id, text_to_insert): insertion_point = target.find(insertion_point_id) + len(insertion_point_id) return target[:insertion_point] + text_to_insert + target[insertion_point:] @@ -72,51 +51,18 @@ def create_module_page(self, path): module_content = apirenderer.md_to_div(md_path) return self._create_page(module_content) - def create_package_page(self, package_name): - package_content = self._create_package_detail(package_name) - return self._create_page(package_content) - def _create_page(self, page_content): page = self._insert_title(self.base_page, page_content) page = insert_after(page, CONTENT_ID, page_content) return page.encode('utf8') - def _create_module_list(self, package_json): - package_name = package_json['name'] - libs = package_json['files'][1]['lib'][1] - doc_path = package_json.get('doc', None) - if not doc_path: - return '' - modules = get_documentation(package_name, libs, doc_path) - modules.sort() - module_items = '' - relative_doc_path = doc_path[len(self.root) + 1:] - relative_doc_path_pieces = relative_doc_path.split(os.sep) - del relative_doc_path_pieces[-1] - relative_doc_URL = "/".join(relative_doc_path_pieces) - for module in modules: - module_link = tag_wrap('/'.join(module), 'a', \ - {'href': relative_doc_URL + '/' + '/'.join(module) + '.html'}) - module_items += module_link - return module_items - - def _create_package_summaries(self, packages_json, include): - packages = '' - for package_name in packages_json.keys(): - package_json = packages_json[package_name] - if not include(package_json): - continue - package_path = self.pkg_cfg["packages"][package_name]["root_dir"] - package_directory = package_path[len(self.root) + 1:] - package_directory = "/".join(package_directory.split(os.sep)) - package_link = tag_wrap(package_name, 'a', {'href': \ - package_directory + "/" \ - + 'index.html'}) - text = tag_wrap(package_link, 'h4') - text += self._create_module_list(package_json) - packages += tag_wrap(text, 'li', {'class':'package-summary', \ - 'style':'display: block;'}) - return packages + def _make_module_text(self, module_list): + module_text = '' + for module in module_list: + module_link = tag_wrap(module.name(), 'a', \ + {'href': "/".join(["modules", module.relative_url()])}) + module_text += module_link + return module_text def _create_base_page(self, root, base_url): base_page = unicode(open(root + INDEX_PAGE, 'r').read(), 'utf8') @@ -125,63 +71,17 @@ def _create_base_page(self, root, base_url): base_page = insert_after(base_page, BASE_URL_INSERTION_POINT, base_tag) sdk_version = get_versions()["version"] base_page = insert_after(base_page, VERSION_INSERTION_POINT, "Version " + sdk_version) - third_party_summaries = \ - self._create_package_summaries(self.packages_json, is_third_party) - base_page = insert_after(base_page, \ - THIRD_PARTY_PACKAGE_SUMMARIES, third_party_summaries) - high_level_summaries = \ - self._create_package_summaries(self.packages_json, is_high_level) + module_list = get_module_list(os.sep.join([root, "doc", "module-source"])) + high_level_module_list = [module_info for module_info in module_list if module_info.level() == "high"] + high_level_module_text = self._make_module_text(high_level_module_list) base_page = insert_after(base_page, \ - HIGH_LEVEL_PACKAGE_SUMMARIES, high_level_summaries) - low_level_summaries = \ - self._create_package_summaries(self.packages_json, is_low_level) + HIGH_LEVEL_MODULE_SUMMARIES, high_level_module_text) + low_level_module_list = [module_info for module_info in module_list if module_info.level() == "low"] + low_level_module_text = self._make_module_text(low_level_module_list) base_page = insert_after(base_page, \ - LOW_LEVEL_PACKAGE_SUMMARIES, low_level_summaries) + LOW_LEVEL_MODULE_SUMMARIES, low_level_module_text) return base_page - def _create_package_detail_row(self, field_value, \ - field_descriptor, field_name): - meta = tag_wrap(tag_wrap(field_descriptor, 'span', \ - {'class':'meta-header'}), 'td') - value = tag_wrap(tag_wrap(field_value, 'span', \ - {'class':field_name}), 'td') - return tag_wrap(meta + value, 'tr') - - def _create_package_detail_table(self, package_json): - table_contents = '' - if package_json.get('author', None): - table_contents += self._create_package_detail_row(\ - cgi.escape(package_json['author']), 'Author', 'author') - if package_json.get('version', None): - table_contents += self._create_package_detail_row(\ - package_json['version'], 'Version', 'version') - if package_json.get('license', None): - table_contents += self._create_package_detail_row(\ - package_json['license'], 'License', 'license') - if package_json.get('dependencies', None): - table_contents += self._create_package_detail_row(\ - ', '.join(package_json['dependencies']), \ - 'Dependencies', 'dependencies') - table_contents += self._create_package_detail_row(\ - self._create_module_list(package_json), 'Modules', 'modules') - return tag_wrap(tag_wrap(table_contents, 'tbody'), 'table', \ - {'class':'meta-table'}) - - def _create_package_detail(self, package_name): - package_json = self.packages_json.get(package_name, None) - if not package_json: - raise IOError(errno.ENOENT, 'Package not found') - # pieces of the package detail: 1) title, 2) table, 3) description - package_title = tag_wrap(package_name, 'h1') - table = self._create_package_detail_table(package_json) - description = '' - if package_json.get('readme', None): - description += tag_wrap(tag_wrap(\ - markdown.markdown(\ - package_json['readme']), 'p'), 'div', {'class':'docs'}) - return tag_wrap(package_title + table + description, 'div', \ - {'class':'package-detail'}) - def _insert_title(self, target, content): match = re.search('

.*

', content) if match: diff --git a/python-lib/cuddlefish/manifest.py b/python-lib/cuddlefish/manifest.py index 2d8f93ce1..672d8edf6 100644 --- a/python-lib/cuddlefish/manifest.py +++ b/python-lib/cuddlefish/manifest.py @@ -8,6 +8,11 @@ SEP = os.path.sep from cuddlefish.util import filter_filenames, filter_dirnames +# Load new layout mapping hashtable +path = os.path.join(os.environ.get('CUDDLEFISH_ROOT'), "mapping.json") +data = open(path, 'r').read() +NEW_LAYOUT_MAPPING = json.loads(data) + def js_zipname(packagename, modulename): return "%s-lib/%s.js" % (packagename, modulename) def docs_zipname(packagename, modulename): @@ -185,7 +190,7 @@ def build(self, scan_tests, test_filter_re): self.top_path = top_me.get_path() self.datamaps[self.target_cfg.name] = DataMap(self.target_cfg) if scan_tests: - mi = self._find_module_in_package("test-harness", "lib", "run-tests", []) + mi = self._find_module_in_package("addon-sdk", "lib", "sdk/test/runner", []) self.process_module(mi) # also scan all test files in all packages that we use. By making # a copy of self.used_packagenames first, we refrain from @@ -213,8 +218,8 @@ def build(self, scan_tests, test_filter_re): test_modules.append( (testname, tme) ) # also add it as an artificial dependency of unit-test-finder, so # the runtime dynamic load can work. - test_finder = self.get_manifest_entry("api-utils", "lib", - "unit-test-finder") + test_finder = self.get_manifest_entry("addon-sdk", "lib", + "sdk/deprecated/unit-test-finder") for (testname,tme) in test_modules: test_finder.add_requirement(testname, tme) # finally, tell the runtime about it, so they won't have to @@ -427,12 +432,12 @@ def BAD(msg): modulename = from_module.name #print " %s require(%s))" % (from_module, reqname) - bits = reqname.split("/") if reqname.startswith("./") or reqname.startswith("../"): # 1: they want something relative to themselves, always from # their own package them = modulename.split("/")[:-1] + bits = reqname.split("/") while bits[0] in (".", ".."): if not bits: raise BAD("no actual modulename") @@ -451,8 +456,21 @@ def BAD(msg): # non-relative import. Might be a short name (requiring a search # through "library" packages), or a fully-qualified one. + # Search for a module in new layout. + # First normalize require argument in order to easily find a mapping + normalized = reqname + if normalized.endswith(".js"): + normalized = normalized[:-len(".js")] + if normalized.startswith("addon-kit/"): + normalized = normalized[len("addon-kit/"):] + if normalized.startswith("api-utils/"): + normalized = normalized[len("api-utils/"):] + if normalized in NEW_LAYOUT_MAPPING: + reqname = NEW_LAYOUT_MAPPING[normalized] + if "/" in reqname: # 2: PKG/MOD: find PKG, look inside for MOD + bits = reqname.split("/") lookfor_pkg = bits[0] lookfor_mod = "/".join(bits[1:]) mi = self._get_module_from_package(lookfor_pkg, diff --git a/python-lib/cuddlefish/packaging.py b/python-lib/cuddlefish/packaging.py index 392a3f359..bf95fedeb 100644 --- a/python-lib/cuddlefish/packaging.py +++ b/python-lib/cuddlefish/packaging.py @@ -11,8 +11,10 @@ from cuddlefish.bunch import Bunch MANIFEST_NAME = 'package.json' +DEFAULT_LOADER = 'addon-sdk' -DEFAULT_LOADER = 'api-utils' +# Is different from root_dir when running tests +env_root = os.environ.get('CUDDLEFISH_ROOT') DEFAULT_PROGRAM_MODULE = 'main' @@ -221,7 +223,7 @@ def _is_same_file(a, b): return a == b def build_config(root_dir, target_cfg, packagepath=[]): - dirs_to_scan = [] + dirs_to_scan = [env_root] # root is addon-sdk dir, diff from root_dir in tests def add_packages_from_config(pkgconfig): if 'packages' in pkgconfig: @@ -318,7 +320,7 @@ def add_section_to_build(cfg, section, is_code=False, def add_locale_to_build(cfg): # Bug 730776: Ignore locales for addon-kit, that are only for unit tests - if not is_running_tests and cfg.name == "addon-kit": + if not is_running_tests and cfg.name == "addon-sdk": return path = resolve_dir(cfg, cfg['locale']) diff --git a/python-lib/cuddlefish/tests/linker-files/one/lib/main.js b/python-lib/cuddlefish/tests/linker-files/one/lib/main.js index 7b1f0de19..88fd75175 100644 --- a/python-lib/cuddlefish/tests/linker-files/one/lib/main.js +++ b/python-lib/cuddlefish/tests/linker-files/one/lib/main.js @@ -5,5 +5,5 @@ var panel = require("panel"); var two = require("two.js"); var a = require("./two"); -var b = require("addon-kit/tabs.js"); +var b = require("sdk/tabs.js"); var c = require("./subdir/three"); diff --git a/python-lib/cuddlefish/tests/static-files/packages/aardvark/doc/aardvark-feeder.md b/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/aardvark-feeder.md similarity index 100% rename from python-lib/cuddlefish/tests/static-files/packages/aardvark/doc/aardvark-feeder.md rename to python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/aardvark-feeder.md diff --git a/python-lib/cuddlefish/tests/static-files/packages/minimal/docs/main.md b/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/anteater/anteater.md similarity index 59% rename from python-lib/cuddlefish/tests/static-files/packages/minimal/docs/main.md rename to python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/anteater/anteater.md index 54518d38d..c480ce336 100644 --- a/python-lib/cuddlefish/tests/static-files/packages/minimal/docs/main.md +++ b/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/anteater/anteater.md @@ -2,4 +2,9 @@ - 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/. --> -minimal docs +The `anteater` module should not be used by anyone. + + +@function + Releases the anteater. Do not call this function. + diff --git a/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/main.md b/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/main.md new file mode 100644 index 000000000..e69de29bb diff --git a/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/not_a_doc.js b/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/not_a_doc.js new file mode 100644 index 000000000..f4abc3bf3 --- /dev/null +++ b/python-lib/cuddlefish/tests/static-files/doc/module-source/sdk/not_a_doc.js @@ -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/. + +not a doc \ No newline at end of file diff --git a/python-lib/cuddlefish/tests/static-files/doc/static-files/base.html b/python-lib/cuddlefish/tests/static-files/doc/static-files/base.html index 56c993dc6..3dd3df1a6 100644 --- a/python-lib/cuddlefish/tests/static-files/doc/static-files/base.html +++ b/python-lib/cuddlefish/tests/static-files/doc/static-files/base.html @@ -88,7 +88,7 @@ @@ -104,7 +104,7 @@ diff --git a/python-lib/cuddlefish/tests/static-files/packages/aardvark/package.json b/python-lib/cuddlefish/tests/static-files/packages/aardvark/package.json index 07eb9b958..afb5698e9 100644 --- a/python-lib/cuddlefish/tests/static-files/packages/aardvark/package.json +++ b/python-lib/cuddlefish/tests/static-files/packages/aardvark/package.json @@ -3,5 +3,5 @@ "description": "A package w/ a main module; can be built into an extension.", "keywords": ["potato"], "version": "1.0", - "dependencies": ["api-utils", "barbeque"] + "dependencies": ["addon-sdk", "barbeque"] } diff --git a/python-lib/cuddlefish/tests/static-files/packages/anteater_files/package.json b/python-lib/cuddlefish/tests/static-files/packages/anteater_files/package.json index 0e2b552f8..9684581da 100644 --- a/python-lib/cuddlefish/tests/static-files/packages/anteater_files/package.json +++ b/python-lib/cuddlefish/tests/static-files/packages/anteater_files/package.json @@ -4,5 +4,5 @@ "description": "A package w/ a main module; can be built into an extension.", "keywords": ["potato"], "version": "1.0", - "dependencies": ["api-utils", "barbeque"] + "dependencies": ["addon-sdk", "barbeque"] } diff --git a/python-lib/cuddlefish/tests/test_generate.py b/python-lib/cuddlefish/tests/test_generate.py index ce5665e16..6502ee33f 100644 --- a/python-lib/cuddlefish/tests/test_generate.py +++ b/python-lib/cuddlefish/tests/test_generate.py @@ -16,12 +16,14 @@ INITIAL_FILESET = [ ["static-files", "base.html"], \ ["dev-guide", "index.html"], \ - ["packages", "aardvark", "index.html"] ] + ["modules", "sdk", "aardvark-feeder.html"], \ + ["modules", "sdk", "anteater", "anteater.html"]] EXTENDED_FILESET = [ ["static-files", "base.html"], \ ["dev-guide", "extra.html"], \ ["dev-guide", "index.html"], \ - ["packages", "aardvark", "index.html"] ] + ["modules", "sdk", "aardvark-feeder.html"], \ + ["modules", "sdk", "anteater", "anteater.html"]] EXTRAFILE = ["dev-guide", "extra.html"] @@ -128,11 +130,11 @@ def test_generate_docs(self): docs_root = os.path.join(test_root, "doc") generate.clean_generated_docs(docs_root) new_digest = self.check_generate_regenerate_cycle(test_root, INITIAL_FILESET) - # touching an MD file under packages **does** cause a regenerate - os.utime(os.path.join(test_root, "packages", "aardvark", "doc", "main.md"), None) + # touching an MD file under sdk **does** cause a regenerate + os.utime(os.path.join(test_root, "doc", "module-source", "sdk", "aardvark-feeder.md"), None) new_digest = self.check_generate_regenerate_cycle(test_root, INITIAL_FILESET, new_digest) - # touching a non MD file under packages **does not** cause a regenerate - os.utime(os.path.join(test_root, "packages", "aardvark", "lib", "main.js"), None) + # touching a non MD file under sdk **does not** cause a regenerate + os.utime(os.path.join(test_root, "doc", "module-source", "sdk", "not_a_doc.js"), None) self.check_generate_is_skipped(test_root, INITIAL_FILESET, new_digest) # touching a non MD file under static-files **does not** cause a regenerate os.utime(os.path.join(docs_root, "static-files", "another.html"), None) diff --git a/python-lib/cuddlefish/tests/test_linker.py b/python-lib/cuddlefish/tests/test_linker.py index 84f6a09e9..792af6f54 100755 --- a/python-lib/cuddlefish/tests/test_linker.py +++ b/python-lib/cuddlefish/tests/test_linker.py @@ -31,15 +31,15 @@ def test_deps(self): deps = packaging.get_deps_for_targets(pkg_cfg, ["one"]) self.failUnlessEqual(deps, ["one"]) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - self.failUnlessEqual(deps, ["addon-kit", "api-utils", "one"]) + [target_cfg.name, "addon-sdk"]) + self.failUnlessEqual(deps, ["addon-sdk", "one"]) def test_manifest(self): target_cfg = self.get_pkg("one") pkg_cfg = packaging.build_config(ROOT, target_cfg) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - self.failUnlessEqual(deps, ["addon-kit", "api-utils", "one"]) + [target_cfg.name, "addon-sdk"]) + self.failUnlessEqual(deps, ["addon-sdk", "one"]) # target_cfg.dependencies is not provided, so we'll search through # all known packages (everything in 'deps'). m = manifest.build_manifest(target_cfg, pkg_cfg, deps, scan_tests=False) @@ -48,10 +48,10 @@ def test_manifest(self): def assertReqIs(modname, reqname, path): reqs = m["one/lib/%s.js" % modname]["requirements"] self.failUnlessEqual(reqs[reqname]["path"], path) - assertReqIs("main", "panel", "addon-kit/lib/panel.js") + assertReqIs("main", "panel", "addon-sdk/lib/sdk/panel.js") assertReqIs("main", "two.js", "one/lib/two.js") assertReqIs("main", "./two", "one/lib/two.js") - assertReqIs("main", "addon-kit/tabs.js", "addon-kit/lib/tabs.js") + assertReqIs("main", "sdk/tabs.js", "addon-sdk/lib/sdk/tabs.js") assertReqIs("main", "./subdir/three", "one/lib/subdir/three.js") assertReqIs("two", "main", "one/lib/main.js") assertReqIs("subdir/three", "../main", "one/lib/main.js") @@ -69,8 +69,8 @@ def test_main_in_deps(self): pkg_cfg = packaging.build_config(ROOT, target_cfg, packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - self.failUnlessEqual(deps, ["addon-kit", "api-utils", "three"]) + [target_cfg.name, "addon-sdk"]) + self.failUnlessEqual(deps, ["addon-sdk", "three"]) m = manifest.build_manifest(target_cfg, pkg_cfg, deps, scan_tests=False) m = m.get_harness_options_manifest() def assertReqIs(modname, reqname, path): @@ -86,8 +86,8 @@ def test_relative_main_in_top(self): pkg_cfg = packaging.build_config(ROOT, target_cfg, packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - self.failUnlessEqual(deps, ["addon-kit", "api-utils", "five"]) + [target_cfg.name, "addon-sdk"]) + self.failUnlessEqual(deps, ["addon-sdk", "five"]) # all we care about is that this next call doesn't raise an exception m = manifest.build_manifest(target_cfg, pkg_cfg, deps, scan_tests=False) m = m.get_harness_options_manifest() @@ -100,8 +100,8 @@ def test_unreachable_relative_main_in_top(self): pkg_cfg = packaging.build_config(ROOT, target_cfg, packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - self.failUnlessEqual(deps, ["addon-kit", "api-utils", "six"]) + [target_cfg.name, "addon-sdk"]) + self.failUnlessEqual(deps, ["addon-sdk", "six"]) self.assertRaises(manifest.UnreachablePrefixError, manifest.build_manifest, target_cfg, pkg_cfg, deps, scan_tests=False) @@ -112,8 +112,8 @@ def test_unreachable_in_deps(self): pkg_cfg = packaging.build_config(ROOT, target_cfg, packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - self.failUnlessEqual(deps, ["addon-kit", "api-utils", "four"]) + [target_cfg.name, "addon-sdk"]) + self.failUnlessEqual(deps, ["addon-sdk", "four"]) self.assertRaises(manifest.UnreachablePrefixError, manifest.build_manifest, target_cfg, pkg_cfg, deps, scan_tests=False) @@ -190,7 +190,7 @@ def _test(basedir): names = zf.namelist() # the first problem found in bug 664840 was that cuddlefish.js # (the loader) was stripped out on windows, due to a /-vs-\ bug - self.assertIn("resources/api-utils/lib/cuddlefish.js", names) + self.assertIn("resources/addon-sdk/lib/sdk/loader/cuddlefish.js", names) # the second problem found in bug 664840 was that an addon # without an explicit tests/ directory would copy all files from # the package into a bogus JID-PKGNAME-tests/ directory, so check @@ -220,7 +220,7 @@ def _test(basedir): self.failUnlessEqual(e.args[0], 0) zf = zipfile.ZipFile("seven.xpi", "r") names = zf.namelist() - self.assertIn("resources/api-utils/lib/cuddlefish.js", names) + self.assertIn("resources/addon-sdk/lib/sdk/loader/cuddlefish.js", names) testfiles = [fn for fn in names if "seven/tests" in fn] self.failUnlessEqual([], testfiles) self.assertIn("resources/seven/data/text.data", diff --git a/python-lib/cuddlefish/tests/test_packaging.py b/python-lib/cuddlefish/tests/test_packaging.py index ff3d85105..ccd281293 100644 --- a/python-lib/cuddlefish/tests/test_packaging.py +++ b/python-lib/cuddlefish/tests/test_packaging.py @@ -45,10 +45,10 @@ def test_basic(self): configs = get_configs('aardvark') packages = configs.pkg_cfg.packages - self.assertTrue('api-utils' in packages) + self.assertTrue('addon-sdk' in packages) self.assertTrue('aardvark' in packages) - self.assertTrue('api-utils' in packages.aardvark.dependencies) - self.assertEqual(packages['api-utils'].loader, 'lib/loader.js') + self.assertTrue('addon-sdk' in packages.aardvark.dependencies) + self.assertEqual(packages['addon-sdk'].loader, 'lib/sdk/loader/cuddlefish.js') self.assertTrue(packages.aardvark.main == 'main') self.assertTrue(packages.aardvark.version == "1.0") diff --git a/python-lib/cuddlefish/tests/test_webdocs.py b/python-lib/cuddlefish/tests/test_webdocs.py index d9d4eab54..8bb9b493c 100644 --- a/python-lib/cuddlefish/tests/test_webdocs.py +++ b/python-lib/cuddlefish/tests/test_webdocs.py @@ -8,23 +8,6 @@ from cuddlefish.docs import webdocs class WebDocTests(unittest.TestCase): - def test_create_package_doc(self): - root = os.path.join(os.getcwd() + \ - '/python-lib/cuddlefish/tests/static-files') - web_docs = webdocs.WebDocs(root) - aarvark_package = web_docs.create_package_page('aardvark') - self._test_common_contents(aarvark_package) - self.assertTrue('

aardvark

'\ - in aarvark_package) - self.assertTrue(\ - 'Author'\ - in aarvark_package) - self.assertTrue(\ - 'Jon Smith'\ - in aarvark_package) - self.assertTrue(\ - 'aardvark - Add-on SDK Documentation'\ - in aarvark_package) def test_create_guide1_doc(self): root = os.path.join(os.getcwd() + \ @@ -58,7 +41,7 @@ def test_create_module_doc(self): '/python-lib/cuddlefish/tests/static-files') web_docs = webdocs.WebDocs(root) module = web_docs.create_module_page(os.path.join(\ - root + '/packages/aardvark/doc/aardvark-feeder.blah')) + root + '/doc/module-source/sdk/aardvark-feeder.blah')) self._test_common_contents(module) self.assertTrue(\ 'aardvark-feeder - Add-on SDK Documentation'\ @@ -87,11 +70,9 @@ def test_create_module_doc(self): def _test_common_contents(self, doc): self.assertTrue(\ - 'anteater/anteater' in doc) self.assertTrue(\ - 'main' in doc) + 'aardvark-feeder' in doc) if __name__ == "__main__": unittest.main() diff --git a/python-lib/cuddlefish/tests/test_xpi.py b/python-lib/cuddlefish/tests/test_xpi.py index d2656b42d..9e7e83a8c 100644 --- a/python-lib/cuddlefish/tests/test_xpi.py +++ b/python-lib/cuddlefish/tests/test_xpi.py @@ -163,8 +163,8 @@ def test_contents(self): pkg_cfg = packaging.build_config(self.root, target_cfg, packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) - api_utils_dir = pkg_cfg.packages["api-utils"].lib[0] + [target_cfg.name, "addon-sdk"]) + addon_sdk_dir = pkg_cfg.packages["addon-sdk"].lib[0] m = manifest.build_manifest(target_cfg, pkg_cfg, deps, scan_tests=False) used_files = list(m.get_used_files()) here = up(os.path.abspath(__file__)) @@ -182,12 +182,12 @@ def absify(*parts): ("three-deps", "three-c", "lib", "sub", "foo.js") ]] - add_api_utils = lambda path: os.path.join(api_utils_dir, path) - expected.extend([add_api_utils(module) for module in [ - "self.js", - "promise.js", - os.path.join("url", "io.js"), - os.path.join("utils", "object.js") + add_addon_sdk= lambda path: os.path.join(addon_sdk_dir, path) + expected.extend([add_addon_sdk(module) for module in [ + os.path.join("sdk", "self.js"), + os.path.join("sdk", "core", "promise.js"), + os.path.join("sdk", "net", "url.js"), + os.path.join("sdk", "util", "object.js") ]]) missing = set(expected) - set(used_files) @@ -219,15 +219,17 @@ def absify(*parts): "install.rdf", "defaults/preferences/prefs.js", "resources/", - "resources/api-utils/", - "resources/api-utils/data/", - "resources/api-utils/lib/", - "resources/api-utils/lib/self.js", - "resources/api-utils/lib/utils/", - "resources/api-utils/lib/url/", - "resources/api-utils/lib/promise.js", - "resources/api-utils/lib/utils/object.js", - "resources/api-utils/lib/url/io.js", + "resources/addon-sdk/", + "resources/addon-sdk/data/", + "resources/addon-sdk/lib/", + "resources/addon-sdk/lib/sdk/", + "resources/addon-sdk/lib/sdk/self.js", + "resources/addon-sdk/lib/sdk/core/", + "resources/addon-sdk/lib/sdk/util/", + "resources/addon-sdk/lib/sdk/net/", + "resources/addon-sdk/lib/sdk/core/promise.js", + "resources/addon-sdk/lib/sdk/util/object.js", + "resources/addon-sdk/lib/sdk/net/url.js", "resources/three/", "resources/three/lib/", "resources/three/lib/main.js", @@ -287,7 +289,7 @@ def test_scantests(self): packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) + [target_cfg.name, "addon-sdk"]) m = manifest.build_manifest(target_cfg, pkg_cfg, deps, scan_tests=True) self.failUnlessEqual(sorted(m.get_all_test_modules()), sorted(["test-one", "test-two"])) @@ -312,10 +314,10 @@ def test_scantests(self): limit_to=None) x = zipfile.ZipFile(xpi_name, "r") names = x.namelist() - self.failUnless("resources/api-utils/lib/unit-test.js" in names, names) - self.failUnless("resources/api-utils/lib/unit-test-finder.js" in names, names) - self.failUnless("resources/test-harness/lib/harness.js" in names, names) - self.failUnless("resources/test-harness/lib/run-tests.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/deprecated/unit-test.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/deprecated/unit-test-finder.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/test/harness.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/test/runner.js" in names, names) # all files are copied into the XPI, even the things that don't look # like tests. self.failUnless("resources/three/tests/test-one.js" in names, names) @@ -328,7 +330,7 @@ def test_scantests_filter(self): pkg_cfg = packaging.build_config(self.root, target_cfg, packagepath=package_path) deps = packaging.get_deps_for_targets(pkg_cfg, - [target_cfg.name, "addon-kit"]) + [target_cfg.name, "addon-sdk"]) FILTER = ".*one.*" m = manifest.build_manifest(target_cfg, pkg_cfg, deps, scan_tests=True, test_filter_re=FILTER) @@ -355,10 +357,10 @@ def test_scantests_filter(self): limit_to=None) x = zipfile.ZipFile(xpi_name, "r") names = x.namelist() - self.failUnless("resources/api-utils/lib/unit-test.js" in names, names) - self.failUnless("resources/api-utils/lib/unit-test-finder.js" in names, names) - self.failUnless("resources/test-harness/lib/harness.js" in names, names) - self.failUnless("resources/test-harness/lib/run-tests.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/deprecated/unit-test.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/deprecated/unit-test-finder.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/test/harness.js" in names, names) + self.failUnless("resources/addon-sdk/lib/sdk/test/runner.js" in names, names) # get_all_test_modules() respects the filter. But all files are still # copied into the XPI. self.failUnless("resources/three/tests/test-one.js" in names, names) diff --git a/test/addons/l10n/main.js b/test/addons/l10n/main.js index eab7f1649..b4e980f57 100644 --- a/test/addons/l10n/main.js +++ b/test/addons/l10n/main.js @@ -3,9 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const prefs = require("preferences-service"); -const { Loader } = require('test-harness/loader'); -const { resolveURI } = require('api-utils/loader'); +const prefs = require("sdk/preferences/service"); +const { Loader } = require('sdk/test/loader'); +const { resolveURI } = require('toolkit/loader'); const { rootURI } = require("@loader/options"); const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS"; @@ -33,7 +33,7 @@ function createTest(locale, testFunction) { // the right .json file setLocale(locale); // Initialize main l10n module in order to load new locale files - loader.require("api-utils/l10n/loader"). + loader.require("sdk/l10n/loader"). load(rootURI). then(function success(data) { definePseudo(loader, '@l10n/data', data); @@ -56,7 +56,7 @@ function createTest(locale, testFunction) { } exports.testExactMatching = createTest("fr-FR", function(assert, loader, done) { - let _ = loader.require("addon-kit/l10n").get; + let _ = loader.require("sdk/l10n").get; assert.equal(_("Not translated"), "Not translated", "Key not translated"); assert.equal(_("Translated"), "Oui", @@ -90,11 +90,11 @@ exports.testHtmlLocalization = createTest("en-GB", function(assert, loader, done // Ensure initing html component that watch document creations // Note that this module is automatically initialized in // cuddlefish.js:Loader.main in regular addons. But it isn't for unit tests. - let loaderHtmlL10n = loader.require("api-utils/l10n/html"); + let loaderHtmlL10n = loader.require("sdk/l10n/html"); loaderHtmlL10n.enable(); - let uri = require("self").data.url("test-localization.html"); - let worker = loader.require("page-worker").Page({ + let uri = require("sdk/self").data.url("test-localization.html"); + let worker = loader.require("sdk/page-worker").Page({ contentURL: uri, contentScript: "new " + function ContentScriptScope() { let nodes = document.body.querySelectorAll("*[data-l10n-id]"); @@ -124,7 +124,7 @@ exports.testHtmlLocalization = createTest("en-GB", function(assert, loader, done }); exports.testEnUsLocaleName = createTest("en-US", function(assert, loader, done) { - let _ = loader.require("addon-kit/l10n").get; + let _ = loader.require("sdk/l10n").get; assert.equal(_("Not translated"), "Not translated", "String w/o translation is kept as-is"); @@ -164,7 +164,7 @@ exports.testEnUsLocaleName = createTest("en-US", function(assert, loader, done) }); exports.testShortLocaleName = createTest("eo", function(assert, loader, done) { - let _ = loader.require("addon-kit/l10n").get; + let _ = loader.require("sdk/l10n").get; assert.equal(_("Not translated"), "Not translated", "String w/o translation is kept as-is"); assert.equal(_("Translated"), "jes", @@ -176,6 +176,6 @@ exports.testShortLocaleName = createTest("eo", function(assert, loader, done) { // Before running tests, disable HTML service which is automatially enabled // in api-utils/addon/runner.js -require('api-utils/l10n/html').disable(); +require('sdk/l10n/html').disable(); -require("test-harness/run-tests").runTestsFromModule(module); +require("sdk/test/runner").runTestsFromModule(module); diff --git a/packages/api-utils/tests/commonjs-test-adapter/asserts.js b/test/commonjs-test-adapter/asserts.js similarity index 100% rename from packages/api-utils/tests/commonjs-test-adapter/asserts.js rename to test/commonjs-test-adapter/asserts.js diff --git a/packages/api-utils/tests/fixtures/addon-install-unit-test@mozilla.com.xpi b/test/fixtures/addon-install-unit-test@mozilla.com.xpi similarity index 100% rename from packages/api-utils/tests/fixtures/addon-install-unit-test@mozilla.com.xpi rename to test/fixtures/addon-install-unit-test@mozilla.com.xpi diff --git a/packages/api-utils/tests/fixtures/chrome-worker/addEventListener.js b/test/fixtures/chrome-worker/addEventListener.js similarity index 100% rename from packages/api-utils/tests/fixtures/chrome-worker/addEventListener.js rename to test/fixtures/chrome-worker/addEventListener.js diff --git a/packages/api-utils/tests/fixtures/chrome-worker/jsctypes.js b/test/fixtures/chrome-worker/jsctypes.js similarity index 100% rename from packages/api-utils/tests/fixtures/chrome-worker/jsctypes.js rename to test/fixtures/chrome-worker/jsctypes.js diff --git a/packages/api-utils/tests/fixtures/chrome-worker/onerror.js b/test/fixtures/chrome-worker/onerror.js similarity index 100% rename from packages/api-utils/tests/fixtures/chrome-worker/onerror.js rename to test/fixtures/chrome-worker/onerror.js diff --git a/packages/api-utils/tests/fixtures/chrome-worker/onmessage.js b/test/fixtures/chrome-worker/onmessage.js similarity index 100% rename from packages/api-utils/tests/fixtures/chrome-worker/onmessage.js rename to test/fixtures/chrome-worker/onmessage.js diff --git a/packages/api-utils/tests/fixtures/chrome-worker/setTimeout.js b/test/fixtures/chrome-worker/setTimeout.js similarity index 100% rename from packages/api-utils/tests/fixtures/chrome-worker/setTimeout.js rename to test/fixtures/chrome-worker/setTimeout.js diff --git a/packages/api-utils/tests/fixtures/chrome-worker/xhr.js b/test/fixtures/chrome-worker/xhr.js similarity index 100% rename from packages/api-utils/tests/fixtures/chrome-worker/xhr.js rename to test/fixtures/chrome-worker/xhr.js diff --git a/packages/api-utils/tests/fixtures/es5.js b/test/fixtures/es5.js similarity index 100% rename from packages/api-utils/tests/fixtures/es5.js rename to test/fixtures/es5.js diff --git a/packages/api-utils/tests/fixtures/loader/cycles/a.js b/test/fixtures/loader/cycles/a.js similarity index 100% rename from packages/api-utils/tests/fixtures/loader/cycles/a.js rename to test/fixtures/loader/cycles/a.js diff --git a/packages/api-utils/tests/fixtures/loader/cycles/b.js b/test/fixtures/loader/cycles/b.js similarity index 100% rename from packages/api-utils/tests/fixtures/loader/cycles/b.js rename to test/fixtures/loader/cycles/b.js diff --git a/packages/api-utils/tests/fixtures/loader/cycles/c.js b/test/fixtures/loader/cycles/c.js similarity index 100% rename from packages/api-utils/tests/fixtures/loader/cycles/c.js rename to test/fixtures/loader/cycles/c.js diff --git a/packages/api-utils/tests/fixtures/loader/cycles/main.js b/test/fixtures/loader/cycles/main.js similarity index 100% rename from packages/api-utils/tests/fixtures/loader/cycles/main.js rename to test/fixtures/loader/cycles/main.js diff --git a/packages/api-utils/tests/fixtures/sandbox-complex-character.js b/test/fixtures/sandbox-complex-character.js similarity index 100% rename from packages/api-utils/tests/fixtures/sandbox-complex-character.js rename to test/fixtures/sandbox-complex-character.js diff --git a/packages/api-utils/tests/fixtures/sandbox-normal.js b/test/fixtures/sandbox-normal.js similarity index 100% rename from packages/api-utils/tests/fixtures/sandbox-normal.js rename to test/fixtures/sandbox-normal.js diff --git a/packages/api-utils/tests/loader/fixture.js b/test/loader/fixture.js similarity index 100% rename from packages/api-utils/tests/loader/fixture.js rename to test/loader/fixture.js diff --git a/packages/api-utils/tests/modules/add.js b/test/modules/add.js similarity index 100% rename from packages/api-utils/tests/modules/add.js rename to test/modules/add.js diff --git a/packages/api-utils/tests/modules/async1.js b/test/modules/async1.js similarity index 100% rename from packages/api-utils/tests/modules/async1.js rename to test/modules/async1.js diff --git a/packages/api-utils/tests/modules/async2.js b/test/modules/async2.js similarity index 100% rename from packages/api-utils/tests/modules/async2.js rename to test/modules/async2.js diff --git a/packages/api-utils/tests/modules/badExportAndReturn.js b/test/modules/badExportAndReturn.js similarity index 100% rename from packages/api-utils/tests/modules/badExportAndReturn.js rename to test/modules/badExportAndReturn.js diff --git a/packages/api-utils/tests/modules/badFirst.js b/test/modules/badFirst.js similarity index 100% rename from packages/api-utils/tests/modules/badFirst.js rename to test/modules/badFirst.js diff --git a/packages/api-utils/tests/modules/badSecond.js b/test/modules/badSecond.js similarity index 100% rename from packages/api-utils/tests/modules/badSecond.js rename to test/modules/badSecond.js diff --git a/packages/api-utils/tests/modules/blue.js b/test/modules/blue.js similarity index 100% rename from packages/api-utils/tests/modules/blue.js rename to test/modules/blue.js diff --git a/packages/api-utils/tests/modules/castor.js b/test/modules/castor.js similarity index 100% rename from packages/api-utils/tests/modules/castor.js rename to test/modules/castor.js diff --git a/packages/api-utils/tests/modules/cheetah.js b/test/modules/cheetah.js similarity index 100% rename from packages/api-utils/tests/modules/cheetah.js rename to test/modules/cheetah.js diff --git a/packages/api-utils/tests/modules/color.js b/test/modules/color.js similarity index 100% rename from packages/api-utils/tests/modules/color.js rename to test/modules/color.js diff --git a/packages/api-utils/tests/modules/dupe.js b/test/modules/dupe.js similarity index 100% rename from packages/api-utils/tests/modules/dupe.js rename to test/modules/dupe.js diff --git a/packages/api-utils/tests/modules/dupeNested.js b/test/modules/dupeNested.js similarity index 100% rename from packages/api-utils/tests/modules/dupeNested.js rename to test/modules/dupeNested.js diff --git a/packages/api-utils/tests/modules/dupeSetExports.js b/test/modules/dupeSetExports.js similarity index 100% rename from packages/api-utils/tests/modules/dupeSetExports.js rename to test/modules/dupeSetExports.js diff --git a/packages/api-utils/tests/modules/exportsEquals.js b/test/modules/exportsEquals.js similarity index 100% rename from packages/api-utils/tests/modules/exportsEquals.js rename to test/modules/exportsEquals.js diff --git a/packages/api-utils/tests/modules/green.js b/test/modules/green.js similarity index 100% rename from packages/api-utils/tests/modules/green.js rename to test/modules/green.js diff --git a/packages/api-utils/tests/modules/lion.js b/test/modules/lion.js similarity index 100% rename from packages/api-utils/tests/modules/lion.js rename to test/modules/lion.js diff --git a/packages/api-utils/tests/modules/orange.js b/test/modules/orange.js similarity index 100% rename from packages/api-utils/tests/modules/orange.js rename to test/modules/orange.js diff --git a/packages/api-utils/tests/modules/pollux.js b/test/modules/pollux.js similarity index 100% rename from packages/api-utils/tests/modules/pollux.js rename to test/modules/pollux.js diff --git a/packages/api-utils/tests/modules/red.js b/test/modules/red.js similarity index 100% rename from packages/api-utils/tests/modules/red.js rename to test/modules/red.js diff --git a/packages/api-utils/tests/modules/setExports.js b/test/modules/setExports.js similarity index 100% rename from packages/api-utils/tests/modules/setExports.js rename to test/modules/setExports.js diff --git a/packages/api-utils/tests/modules/subtract.js b/test/modules/subtract.js similarity index 100% rename from packages/api-utils/tests/modules/subtract.js rename to test/modules/subtract.js diff --git a/packages/api-utils/tests/modules/tiger.js b/test/modules/tiger.js similarity index 100% rename from packages/api-utils/tests/modules/tiger.js rename to test/modules/tiger.js diff --git a/packages/api-utils/tests/modules/traditional1.js b/test/modules/traditional1.js similarity index 100% rename from packages/api-utils/tests/modules/traditional1.js rename to test/modules/traditional1.js diff --git a/packages/api-utils/tests/modules/traditional2.js b/test/modules/traditional2.js similarity index 100% rename from packages/api-utils/tests/modules/traditional2.js rename to test/modules/traditional2.js diff --git a/packages/api-utils/tests/modules/types/cat.js b/test/modules/types/cat.js similarity index 100% rename from packages/api-utils/tests/modules/types/cat.js rename to test/modules/types/cat.js diff --git a/packages/addon-kit/tests/pagemod-test-helpers.js b/test/pagemod-test-helpers.js similarity index 92% rename from packages/addon-kit/tests/pagemod-test-helpers.js rename to test/pagemod-test-helpers.js index 8f8e3f775..c76bcb954 100644 --- a/packages/addon-kit/tests/pagemod-test-helpers.js +++ b/test/pagemod-test-helpers.js @@ -5,9 +5,9 @@ "use strict"; const {Cc,Ci} = require("chrome"); -const timer = require("timer"); -const xulApp = require("xul-app"); -const { Loader } = require("test-harness/loader"); +const timer = require("sdk/timers"); +const xulApp = require("sdk/system/xul-app"); +const { Loader } = require("sdk/test/loader"); /** * A helper function that creates a PageMod, then opens the specified URL @@ -36,7 +36,7 @@ exports.testPageMod = function testPageMod(test, testURL, pageModOptions, test.waitUntilDone(); let loader = Loader(module); - let pageMod = loader.require("page-mod"); + let pageMod = loader.require("sdk/page-mod"); var pageMods = [new pageMod.PageMod(opts) for each(opts in pageModOptions)]; diff --git a/packages/addon-kit/tests/tabs/test-fennec-tabs.js b/test/tabs/test-fennec-tabs.js similarity index 97% rename from packages/addon-kit/tests/tabs/test-fennec-tabs.js rename to test/tabs/test-fennec-tabs.js index a6b4d17c6..f3cd66056 100644 --- a/packages/addon-kit/tests/tabs/test-fennec-tabs.js +++ b/test/tabs/test-fennec-tabs.js @@ -4,10 +4,10 @@ 'use strict'; const { Cc, Ci } = require('chrome'); -const { Loader } = require('test-harness/loader'); -const timer = require('timer'); -const tabs = require('tabs'); -const windows = require('windows'); +const { Loader } = require('sdk/test/loader'); +const timer = require('sdk/timers'); +const tabs = require('sdk/tabs'); +const windows = require('sdk/windows'); const tabsLen = tabs.length; const URL = 'data:text/html;charset=utf-8,#title#'; @@ -37,8 +37,8 @@ exports.testAutomaticDestroy = function(test) { let loader2 = Loader(module); let loader3 = Loader(module); - let tabs2 = loader2.require('tabs'); - let tabs3 = loader3.require('tabs'); + let tabs2 = loader2.require('sdk/tabs'); + let tabs3 = loader3.require('sdk/tabs'); let tabs2Len = tabs2.length; tabs2.on('open', function onOpen(tab) { @@ -110,7 +110,7 @@ exports.testAutomaticDestroy = function(test) { exports.testTabProperties = function(test) { test.waitUntilDone(); let { loader, errors } = LoaderWithHookedConsole(); - let tabs = loader.require('tabs'); + let tabs = loader.require('sdk/tabs'); let url = "data:text/html;charset=utf-8,foofoo"; let tabsLen = tabs.length; @@ -230,7 +230,7 @@ exports.testTabMove = function(test) { test.waitUntilDone(); let { loader, errors } = LoaderWithHookedConsole(); - let tabs = loader.require('tabs'); + let tabs = loader.require('sdk/tabs'); let url = "data:text/html;charset=utf-8,testTabMove"; @@ -264,7 +264,7 @@ exports.testTabsOpen_alt = function(test) { test.waitUntilDone(); let { loader, errors } = LoaderWithHookedConsole(); - let tabs = loader.require('tabs'); + let tabs = loader.require('sdk/tabs'); let url = "data:text/html;charset=utf-8,default"; tabs.open({ @@ -289,7 +289,7 @@ exports.testOpenPinned_alt = function(test) { test.waitUntilDone(); let { loader, errors } = LoaderWithHookedConsole(); - let tabs = loader.require('tabs'); + let tabs = loader.require('sdk/tabs'); let url = "about:blank"; tabs.open({ @@ -313,7 +313,7 @@ exports.testPinUnpin_alt = function(test) { test.waitUntilDone(); let { loader, errors } = LoaderWithHookedConsole(); - let tabs = loader.require('tabs'); + let tabs = loader.require('sdk/tabs'); let url = "data:text/html;charset=utf-8,default"; tabs.open({ diff --git a/packages/addon-kit/tests/tabs/test-firefox-tabs.js b/test/tabs/test-firefox-tabs.js similarity index 94% rename from packages/addon-kit/tests/tabs/test-firefox-tabs.js rename to test/tabs/test-firefox-tabs.js index a3d7563ad..d7c822be1 100644 --- a/packages/addon-kit/tests/tabs/test-firefox-tabs.js +++ b/test/tabs/test-firefox-tabs.js @@ -4,19 +4,19 @@ 'use strict'; const { Cc, Ci } = require('chrome'); -const { Loader } = require('test-harness/loader'); -const timer = require('timer'); -const { StringBundle } = require('api-utils/app-strings'); +const { Loader } = require('sdk/test/loader'); +const timer = require('sdk/timers'); +const { StringBundle } = require('sdk/deprecated/app-strings'); // TEST: tabs.activeTab getter exports.testActiveTab_getter = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,foo"; - require("tab-browser").addTab( + require("sdk/deprecated/tab-browser").addTab( url, { onLoad: function(e) { @@ -37,7 +37,7 @@ exports.testBug682681_aboutURI = function(test) { let tabStrings = StringBundle('chrome://browser/locale/tabbrowser.properties'); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); tabs.on('ready', function onReady(tab) { tabs.removeListener('ready', onReady); @@ -63,7 +63,7 @@ exports.testTitleForDataURI = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); tabs.on('ready', function onReady(tab) { tabs.removeListener('ready', onReady); @@ -87,8 +87,8 @@ exports.testTitleForDataURI = function(test) { exports.testBrowserWindowCreationOnActivate = function(test) { test.waitUntilDone(); - let windows = require("windows").browserWindows; - let tabs = require("tabs"); + let windows = require("sdk/windows").browserWindows; + let tabs = require("sdk/tabs"); let gotActivate = false; @@ -108,7 +108,7 @@ exports.testActiveTab_setter = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,foo"; tabs.on('ready', function onReady(tab) { @@ -137,13 +137,13 @@ exports.testAutomaticDestroy = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); // Create a second tab instance that we will destroy let called = false; let loader = Loader(module); - let tabs2 = loader.require("tabs"); + let tabs2 = loader.require("sdk/tabs"); tabs2.on('open', function onOpen(tab) { called = true; }); @@ -166,7 +166,7 @@ exports.testAutomaticDestroy = function(test) { exports.testTabProperties = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs= require("tabs"); + let tabs= require("sdk/tabs"); let url = "data:text/html;charset=utf-8,foofoo"; tabs.open({ url: url, @@ -187,7 +187,7 @@ exports.testTabProperties = function(test) { exports.testTabContentTypeAndReload = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,foofoo"; let urlXML = "data:text/xml;charset=utf-8,bar"; tabs.open({ @@ -209,7 +209,7 @@ exports.testTabContentTypeAndReload = function(test) { exports.testTabsIteratorAndLength = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let startCount = 0; for each (let t in tabs) startCount++; test.assertEqual(startCount, tabs.length, "length property is correct"); @@ -233,7 +233,7 @@ exports.testTabsIteratorAndLength = function(test) { exports.testTabLocation = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url1 = "data:text/html;charset=utf-8,foo"; let url2 = "data:text/html;charset=utf-8,bar"; @@ -258,7 +258,7 @@ exports.testTabLocation = function(test) { exports.testTabClose = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,foo"; test.assertNotEqual(tabs.activeTab.url, url, "tab is not the active tab"); @@ -282,7 +282,7 @@ exports.testTabClose = function(test) { exports.testTabReload = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,"; tabs.open({ url: url, onReady: function onReady(tab) { @@ -315,7 +315,7 @@ exports.testTabReload = function(test) { exports.testTabMove = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,foo"; tabs.open({ @@ -334,7 +334,7 @@ exports.testTabMove = function(test) { exports.testOpen = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,default"; tabs.open({ url: url, @@ -351,12 +351,12 @@ exports.testOpen = function(test) { // TEST: open pinned tab exports.testOpenPinned = function(test) { - const xulApp = require("xul-app"); + const xulApp = require("sdk/system/xul-app"); if (xulApp.versionInRange(xulApp.platformVersion, "2.0b2", "*")) { // test tab pinning test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,default"; tabs.open({ url: url, @@ -375,11 +375,11 @@ exports.testOpenPinned = function(test) { // TEST: pin/unpin opened tab exports.testPinUnpin = function(test) { - const xulApp = require("xul-app"); + const xulApp = require("sdk/system/xul-app"); if (xulApp.versionInRange(xulApp.platformVersion, "2.0b2", "*")) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,default"; tabs.open({ url: url, @@ -402,7 +402,7 @@ exports.testPinUnpin = function(test) { exports.testInBackground = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let activeUrl = tabs.activeTab.url; let url = "data:text/html;charset=utf-8,background"; test.assertEqual(activeWindow, window, "activeWindow matches this window"); @@ -425,10 +425,10 @@ exports.testInBackground = function(test) { exports.testOpenInNewWindow = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let cache = []; - let windowUtils = require("window-utils"); + let windowUtils = require("sdk/deprecated/window-utils"); let wt = new windowUtils.WindowTracker({ onTrack: function(win) { cache.push(win); @@ -464,7 +464,7 @@ exports.testOpenInNewWindow = function(test) { exports.testTabsEvent_onOpen = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,1"; let eventCount = 0; @@ -490,7 +490,7 @@ exports.testTabsEvent_onOpen = function(test) { exports.testTabsEvent_onClose = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,onclose"; let eventCount = 0; @@ -522,7 +522,7 @@ exports.testTabsEvent_onCloseWindow = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let closeCount = 0, individualCloseCount = 0; function listener() { @@ -576,7 +576,7 @@ exports.testTabsEvent_onCloseWindow = function(test) { exports.testTabsEvent_onReady = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,onready"; let eventCount = 0; @@ -602,7 +602,7 @@ exports.testTabsEvent_onReady = function(test) { exports.testTabsEvent_onActivate = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,onactivate"; let eventCount = 0; @@ -628,7 +628,7 @@ exports.testTabsEvent_onActivate = function(test) { exports.testTabsEvent_onDeactivate = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,ondeactivate"; let eventCount = 0; @@ -659,7 +659,7 @@ exports.testTabsEvent_onDeactivate = function(test) { exports.testTabsEvent_pinning = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let url = "data:text/html;charset=utf-8,1"; tabs.on('open', function onOpen(tab) { @@ -687,7 +687,7 @@ exports.testTabsEvent_pinning = function(test) { exports.testPerTabEvents = function(test) { test.waitUntilDone(); openBrowserWindow(function(window, browser) { - var tabs = require("tabs"); + var tabs = require("sdk/tabs"); let eventCount = 0; tabs.open({ @@ -715,7 +715,7 @@ exports.testAttachOnOpen = function (test) { // Take care that attach has to be called on tab ready and not on tab open. test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); tabs.open({ url: "data:text/html;charset=utf-8,foobar", @@ -739,7 +739,7 @@ exports.testAttachOnMultipleDocuments = function (test) { // Example of attach that process multiple tab documents test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let firstLocation = "data:text/html;charset=utf-8,foobar"; let secondLocation = "data:text/html;charset=utf-8,bar"; let thirdLocation = "data:text/html;charset=utf-8,fox"; @@ -821,7 +821,7 @@ exports.testAttachWrappers = function (test) { // Check that content script has access to wrapped values by default test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let document = "data:text/html;charset=utf-8,"; let count = 0; @@ -855,7 +855,7 @@ exports.testAttachUnwrapped = function (test) { // Check that content script has access to unwrapped values through unsafeWindow test.waitUntilDone(); openBrowserWindow(function(window, browser) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); let document = "data:text/html;charset=utf-8,"; let count = 0; @@ -884,7 +884,7 @@ exports['test window focus changes active tab'] = function(test) { test.waitUntilDone(); let win1 = openBrowserWindow(function() { let win2 = openBrowserWindow(function() { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); tabs.on("activate", function onActivate() { tabs.removeListener("activate", onActivate); test.pass("activate was called on windows focus change."); @@ -901,9 +901,9 @@ exports['test ready event on new window tab'] = function(test) { test.waitUntilDone(); let uri = encodeURI("data:text/html;charset=utf-8,Waiting for ready event!"); - require("tabs").on("ready", function onReady(tab) { + require("sdk/tabs").on("ready", function onReady(tab) { if (tab.url === uri) { - require("tabs").removeListener("ready", onReady); + require("sdk/tabs").removeListener("ready", onReady); test.pass("ready event was emitted"); closeBrowserWindow(window, function() { test.done(); @@ -965,7 +965,7 @@ function closeBrowserWindow(window, callback) { // throw. In that case, remove all tests above from exports, and add one dummy // test that passes. try { - require("tabs"); + require("sdk/tabs"); } catch (err) { // This bug should be mentioned in the error message. diff --git a/packages/addon-kit/tests/test-tabs.js b/test/tabs/test-tabs.js similarity index 100% rename from packages/addon-kit/tests/test-tabs.js rename to test/tabs/test-tabs.js diff --git a/packages/api-utils/tests/test-addon-installer.js b/test/test-addon-installer.js similarity index 93% rename from packages/api-utils/tests/test-addon-installer.js rename to test/test-addon-installer.js index b053dac97..e2d3b10e4 100644 --- a/packages/api-utils/tests/test-addon-installer.js +++ b/test/test-addon-installer.js @@ -3,10 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const { Cc, Ci, Cu } = require("chrome"); -const AddonInstaller = require("api-utils/addon/installer"); -const observers = require("api-utils/observer-service"); -const { setTimeout } = require("timer"); -const tmp = require("test-harness/tmp-file"); +const AddonInstaller = require("sdk/addon/installer"); +const observers = require("sdk/deprecated/observer-service"); +const { setTimeout } = require("sdk/timers"); +const tmp = require("sdk/test/tmp-file"); +const system = require("sdk/system"); const testFolderURL = module.uri.split('test-addon-installer.js')[0]; const ADDON_URL = testFolderURL + "fixtures/addon-install-unit-test@mozilla.com.xpi"; @@ -67,7 +68,7 @@ exports.testFailingInstallWithInvalidPath = function (test) { exports.testFailingInstallWithInvalidFile = function (test) { test.waitUntilDone(); - let directory = require("system").pathFor("ProfD"); + let directory = system.pathFor("ProfD"); AddonInstaller.install(directory).then( function onInstalled(id) { test.fail("Unexpected success"); diff --git a/packages/addon-kit/tests/test-addon-page.js b/test/test-addon-page.js similarity index 76% rename from packages/addon-kit/tests/test-addon-page.js rename to test/test-addon-page.js index fa340c90e..cff3273cf 100644 --- a/packages/addon-kit/tests/test-addon-page.js +++ b/test/test-addon-page.js @@ -4,14 +4,15 @@ 'use strict'; -const { isTabOpen, activateTab, openTab, closeTab, getURI } = require('api-utils/tabs/utils'); -const windows = require('api-utils/window-utils'); -const { Loader } = require('test-harness/loader'); -const { setTimeout } = require('api-utils/timer'); -const { is } = require('api-utils/xul-app'); -const tabs = require('tabs'); +const { isTabOpen, activateTab, openTab, + closeTab, getURI } = require('sdk/tabs/utils'); +const windows = require('sdk/deprecated/window-utils'); +const { Loader } = require('sdk/test/loader'); +const { setTimeout } = require('sdk/timers'); +const { is } = require('sdk/system/xul-app'); +const tabs = require('sdk/tabs'); -let uri = require('self').data.url('index.html'); +let uri = require('sdk/self').data.url('index.html'); function isChromeVisible(window) { let x = window.document.documentElement.getAttribute('disablechrome') @@ -43,7 +44,7 @@ exports['test that add-on page has no chrome'] = function(assert, done) { exports['test that add-on pages are closed on unload'] = function(assert, done) { let loader = Loader(module); - loader.require('addon-kit/addon-page'); + loader.require('sdk/addon-page'); // Wait for addon page document to be loaded tabs.once("ready", function listener(tab) { @@ -61,4 +62,4 @@ exports['test that add-on pages are closed on unload'] = function(assert, done) }; -require('test').run(exports); +require('sdk/test').run(exports); diff --git a/packages/api-utils/tests/test-api-utils.js b/test/test-api-utils.js similarity index 99% rename from packages/api-utils/tests/test-api-utils.js rename to test/test-api-utils.js index d63a7b08d..5ba031ac8 100644 --- a/packages/api-utils/tests/test-api-utils.js +++ b/test/test-api-utils.js @@ -4,7 +4,7 @@ * 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/. */ -const apiUtils = require("api-utils/api-utils"); +const apiUtils = require("sdk/deprecated/api-utils"); exports.testPublicConstructor = function (test) { function PrivateCtor() {} diff --git a/packages/api-utils/tests/test-app-strings.js b/test/test-app-strings.js similarity index 97% rename from packages/api-utils/tests/test-app-strings.js rename to test/test-app-strings.js index 16a2dcc56..faa52fc62 100644 --- a/packages/api-utils/tests/test-app-strings.js +++ b/test/test-app-strings.js @@ -4,7 +4,7 @@ const { Cc,Ci } = require("chrome"); -let StringBundle = require("app-strings").StringBundle; +let StringBundle = require("sdk/deprecated/app-strings").StringBundle; exports.testStringBundle = function(test) { let url = "chrome://global/locale/security/caps.properties"; diff --git a/packages/api-utils/tests/test-array.js b/test/test-array.js similarity index 97% rename from packages/api-utils/tests/test-array.js rename to test/test-array.js index 6209b0cdd..04b91a620 100644 --- a/packages/api-utils/tests/test-array.js +++ b/test/test-array.js @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict' -const array = require("array"); +const array = require("sdk/util/array"); exports.testHas = function(test) { var testAry = [1, 2, 3]; diff --git a/packages/api-utils/tests/test-base64.js b/test/test-base64.js similarity index 97% rename from packages/api-utils/tests/test-base64.js rename to test/test-base64.js index d8fca8d54..6ca750021 100644 --- a/packages/api-utils/tests/test-base64.js +++ b/test/test-base64.js @@ -4,7 +4,7 @@ "use strict"; -const base64 = require("api-utils/base64"); +const base64 = require("sdk/base64"); const text = "Awesome!"; const b64text = "QXdlc29tZSE="; diff --git a/packages/api-utils/tests/test-byte-streams.js b/test/test-byte-streams.js similarity index 95% rename from packages/api-utils/tests/test-byte-streams.js rename to test/test-byte-streams.js index dc8ecd860..18a105a07 100644 --- a/packages/api-utils/tests/test-byte-streams.js +++ b/test/test-byte-streams.js @@ -4,10 +4,10 @@ * 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/. */ -const byteStreams = require("byte-streams"); -const file = require("file"); -const { pathFor } = require("api-utils/system"); -const { Loader } = require("test-harness/loader"); +const byteStreams = require("sdk/io/byte-streams"); +const file = require("sdk/io/file"); +const { pathFor } = require("sdk/system"); +const { Loader } = require("sdk/test/loader"); const STREAM_CLOSED_ERROR = "The stream is closed and cannot be used."; @@ -145,7 +145,7 @@ exports.testTruncate = function (test) { exports.testUnload = function (test) { let loader = Loader(module); - let file = loader.require("file"); + let file = loader.require("sdk/io/file"); let filename = dataFileFilename("temp-b"); let stream = file.open(filename, "wb"); diff --git a/packages/api-utils/tests/test-chrome.js b/test/test-chrome.js similarity index 100% rename from packages/api-utils/tests/test-chrome.js rename to test/test-chrome.js diff --git a/packages/addon-kit/tests/test-clipboard.js b/test/test-clipboard.js similarity index 95% rename from packages/addon-kit/tests/test-clipboard.js rename to test/test-clipboard.js index 1239d0dc2..47497471f 100644 --- a/packages/addon-kit/tests/test-clipboard.js +++ b/test/test-clipboard.js @@ -56,7 +56,7 @@ const canvasHTML = "data:text/html," + encodeURIComponent( ); function comparePixelImages(imageA, imageB, callback) { - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); tabs.open({ url: canvasHTML, @@ -105,7 +105,7 @@ exports.testWithNoFlavor = function(test) { var contents = "hello there"; var flavor = "text"; var fullFlavor = "text/unicode"; - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); // Confirm we set the clipboard test.assert(clip.set(contents)); // Confirm flavor is set @@ -126,7 +126,7 @@ exports.testWithFlavor = function(test) { var fullFlavor = "text/html"; var unicodeFlavor = "text"; var unicodeFullFlavor = "text/unicode"; - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); test.assert(clip.set(contents, flavor)); test.assertEqual(clip.currentFlavors[0], unicodeFlavor); test.assertEqual(clip.currentFlavors[1], flavor); @@ -142,7 +142,7 @@ exports.testWithRedundantFlavor = function(test) { var contents = "hello there"; var flavor = "text"; var fullFlavor = "text/unicode"; - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); test.assert(clip.set(contents, flavor)); test.assertEqual(clip.currentFlavors[0], flavor); test.assertEqual(clip.get(), contents); @@ -153,14 +153,14 @@ exports.testWithRedundantFlavor = function(test) { exports.testNotInFlavor = function(test) { var contents = "hello there"; var flavor = "html"; - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); test.assert(clip.set(contents)); // If there's nothing on the clipboard with this flavor, should return null test.assertEqual(clip.get(flavor), null); }; exports.testSetImage = function(test) { - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); var flavor = "image"; var fullFlavor = "image/png"; @@ -171,7 +171,7 @@ exports.testSetImage = function(test) { exports.testGetImage = function(test) { test.waitUntilDone(); - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); clip.set(base64png, "image"); @@ -186,7 +186,7 @@ exports.testGetImage = function(test) { } exports.testSetImageTypeNotSupported = function(test) { - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); var flavor = "image"; test.assertRaises(function () { @@ -201,7 +201,7 @@ exports.testSetImageTypeNotSupported = function(test) { // // See: http://mxr.mozilla.org/mozilla-central/source/image/src/Decoder.cpp#136 exports.testSetImageTypeWrongData = function(test) { - var clip = require("clipboard"); + var clip = require("sdk/clipboard"); var flavor = "image"; var wrongPNG = "data:image/png" + base64jpeg.substr(15); diff --git a/packages/api-utils/tests/test-collection.js b/test/test-collection.js similarity index 98% rename from packages/api-utils/tests/test-collection.js rename to test/test-collection.js index f3e54764d..cd533bf72 100644 --- a/packages/api-utils/tests/test-collection.js +++ b/test/test-collection.js @@ -4,7 +4,7 @@ * 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/. */ -const collection = require("collection"); +const collection = require("sdk/util/collection"); exports.testAddRemove = function (test) { let coll = new collection.Collection(); diff --git a/packages/api-utils/tests/test-commonjs-test-adapter.js b/test/test-commonjs-test-adapter.js similarity index 100% rename from packages/api-utils/tests/test-commonjs-test-adapter.js rename to test/test-commonjs-test-adapter.js diff --git a/packages/api-utils/tests/test-content-loader.js b/test/test-content-loader.js similarity index 98% rename from packages/api-utils/tests/test-content-loader.js rename to test/test-content-loader.js index e19e316ed..1804ac922 100644 --- a/packages/api-utils/tests/test-content-loader.js +++ b/test/test-content-loader.js @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const { Loader } = require('content/loader'); -const self = require("self"); +const { Loader } = require('sdk/content/loader'); +const self = require("sdk/self"); exports['test:contentURL'] = function(test) { let loader = Loader(), diff --git a/packages/api-utils/tests/test-content-proxy.js b/test/test-content-proxy.js similarity index 98% rename from packages/api-utils/tests/test-content-proxy.js rename to test/test-content-proxy.js index 4103fecca..decd0c236 100644 --- a/packages/api-utils/tests/test-content-proxy.js +++ b/test/test-content-proxy.js @@ -2,13 +2,13 @@ * 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/. */ -const hiddenFrames = require("hidden-frame"); -const xulApp = require("xul-app"); +const hiddenFrames = require("sdk/frame/hidden-frame"); +const xulApp = require("sdk/system/xul-app"); const USE_JS_PROXIES = !xulApp.versionInRange(xulApp.platformVersion, "17.0a2", "*"); -const { Loader } = require('test-harness/loader'); +const { Loader } = require('sdk/test/loader'); /* * Utility function that allow to easily run a proxy test with a clean @@ -61,8 +61,8 @@ function createWorker(test, xrayWindow, contentScript, done) { // unlock key `PRIVATE_KEY`. This key should not be used anywhere else. // See `PRIVATE_KEY` definition in worker.js let loader = Loader(module); - let Worker = loader.require("api-utils/content/worker").Worker; - let key = loader.sandbox("api-utils/content/worker").PRIVATE_KEY; + let Worker = loader.require("sdk/content/worker").Worker; + let key = loader.sandbox("sdk/content/worker").PRIVATE_KEY; let worker = Worker({ exposeUnlockKey : USE_JS_PROXIES ? key : null, window: xrayWindow, @@ -817,7 +817,7 @@ if (USE_JS_PROXIES) { // Create an http server in order to simulate real cross domain documents exports.testCrossDomainIframe = createProxyTest("", function (helper) { let serverPort = 8099; - let server = require("httpd").startServerAsync(serverPort); + let server = require("sdk/test/httpd").startServerAsync(serverPort); server.registerPathHandler("/", function handle(request, response) { // Returns the webpage that receive a message and forward it back to its // parent document by appending ' world'. diff --git a/packages/api-utils/tests/test-content-symbiont.js b/test/test-content-symbiont.js similarity index 94% rename from packages/api-utils/tests/test-content-symbiont.js rename to test/test-content-symbiont.js index 1088536cd..470cf7e6b 100644 --- a/packages/api-utils/tests/test-content-symbiont.js +++ b/test/test-content-symbiont.js @@ -5,8 +5,8 @@ "use strict"; const { Cc, Ci } = require('chrome'); -const { Symbiont } = require('content/symbiont'); -const self = require("self"); +const { Symbiont } = require('sdk/content/symbiont'); +const self = require("sdk/self"); function makeWindow() { let content = @@ -135,7 +135,7 @@ exports['test:pageWorker'] = function(test) { exports["test:document element present on 'start'"] = function(test) { test.waitUntilDone(); - let xulApp = require("xul-app"); + let xulApp = require("sdk/system/xul-app"); let worker = Symbiont({ contentURL: "about:buildconfig", contentScript: "self.postMessage(!!document.documentElement)", @@ -154,7 +154,7 @@ exports["test:direct communication with trusted document"] = function(test) { test.waitUntilDone(); let worker = Symbiont({ - contentURL: require("self").data.url("test-trusted-document.html") + contentURL: require("sdk/self").data.url("test-trusted-document.html") }); worker.port.on('document-to-addon', function (arg) { @@ -169,7 +169,7 @@ exports["test:`addon` is not available when a content script is set"] = function test.waitUntilDone(); let worker = Symbiont({ - contentURL: require("self").data.url("test-trusted-document.html"), + contentURL: require("sdk/self").data.url("test-trusted-document.html"), contentScript: "new " + function ContentScriptScope() { self.port.emit("cs-to-addon", "addon" in unsafeWindow); } diff --git a/packages/api-utils/tests/test-content-worker.js b/test/test-content-worker.js similarity index 98% rename from packages/api-utils/tests/test-content-worker.js rename to test/test-content-worker.js index 5aed08ca4..82f63f96a 100644 --- a/packages/api-utils/tests/test-content-worker.js +++ b/test/test-content-worker.js @@ -5,9 +5,9 @@ "use stirct"; const { Cc, Ci } = require("chrome"); -const { setTimeout } = require("api-utils/timer"); -const { Loader, Require, override } = require("test-harness/loader"); -const { Worker } = require("api-utils/content/worker"); +const { setTimeout } = require("sdk/timers"); +const { Loader, Require, override } = require("sdk/test/loader"); +const { Worker } = require("sdk/content/worker"); const DEFAULT_CONTENT_URL = "data:text/html;charset=utf-8,foo"; @@ -374,7 +374,7 @@ exports["test:ensure console.xxx works in cs"] = WorkerTest( } // Finally, create a worker that will call all console methods - let worker = loader.require("content/worker").Worker({ + let worker = loader.require("sdk/content/worker").Worker({ window: browser.contentWindow, contentScript: "new " + function WorkerScope() { console.log("log"); diff --git a/packages/addon-kit/tests/test-context-menu.html b/test/test-context-menu.html similarity index 100% rename from packages/addon-kit/tests/test-context-menu.html rename to test/test-context-menu.html diff --git a/packages/addon-kit/tests/test-context-menu.js b/test/test-context-menu.js similarity index 98% rename from packages/addon-kit/tests/test-context-menu.js rename to test/test-context-menu.js index 90dc7e98f..727028f05 100644 --- a/packages/addon-kit/tests/test-context-menu.js +++ b/test/test-context-menu.js @@ -5,8 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ let {Cc,Ci} = require("chrome"); -const { Loader } = require('test-harness/loader'); -const timer = require("timer"); +const { Loader } = require('sdk/test/loader'); +const timer = require("sdk/timers"); // These should match the same constants in the module. const ITEM_CLASS = "jetpack-context-menu-item"; @@ -455,7 +455,7 @@ exports.testContentScriptFile = function (test) { // But accept files from data folder let item = new loader.cm.Item({ label: "item", - contentScriptFile: require("self").data.url("test-context-menu.js") + contentScriptFile: require("sdk/self").data.url("test-context-menu.js") }); test.showMenu(null, function (popup) { @@ -1293,7 +1293,7 @@ exports.testSetLabelBeforeShowOverflow = function (test) { test = new TestHelper(test); let loader = test.newLoader(); - let prefs = loader.loader.require("preferences-service"); + let prefs = loader.loader.require("sdk/preferences/service"); prefs.set(OVERFLOW_THRESH_PREF, 0); let items = [ @@ -1318,7 +1318,7 @@ exports.testSetLabelAfterShowOverflow = function (test) { test = new TestHelper(test); let loader = test.newLoader(); - let prefs = loader.loader.require("preferences-service"); + let prefs = loader.loader.require("sdk/preferences/service"); prefs.set(OVERFLOW_THRESH_PREF, 0); let items = [ @@ -1586,14 +1586,14 @@ exports.testItemImage = function (test) { test = new TestHelper(test); let loader = test.newLoader(); - let imageURL = require("self").data.url("moz_favicon.ico"); + let imageURL = require("sdk/self").data.url("moz_favicon.ico"); let item = new loader.cm.Item({ label: "item", image: imageURL }); let menu = new loader.cm.Menu({ label: "menu", image: imageURL, items: [] }); test.showMenu(null, function (popup) { test.checkMenu([item, menu], [], []); - let imageURL2 = require("self").data.url("dummy.ico"); + let imageURL2 = require("sdk/self").data.url("dummy.ico"); item.image = imageURL2; menu.image = imageURL2; test.checkMenu([item, menu], [], []); @@ -1646,7 +1646,7 @@ exports.testMenuDestroy = function (test) { // NO TESTS BELOW THIS LINE! /////////////////////////////////////////////////// // Run only a dummy test if context-menu doesn't support the host app. -if (!require("xul-app").is("Firefox")) { +if (!require("sdk/system/xul-app").is("Firefox")) { module.exports = { testAppNotSupported: function (test) { test.pass("context-menu does not support this application."); @@ -2005,8 +2005,8 @@ TestHelper.prototype = { let loader = Loader(module); let wrapper = { loader: loader, - cm: loader.require("context-menu"), - globalScope: loader.sandbox("context-menu"), + cm: loader.require("sdk/context-menu"), + globalScope: loader.sandbox("sdk/context-menu"), unload: function () { loader.unload(); let idx = self.loaders.indexOf(wrapper); @@ -2023,7 +2023,7 @@ TestHelper.prototype = { shouldOverflow: function (presentItems) { return presentItems.length > (this.loaders.length ? - this.loaders[0].loader.require("preferences-service"). + this.loaders[0].loader.require("sdk/preferences/service"). get(OVERFLOW_THRESH_PREF, OVERFLOW_THRESH_DEFAULT) : OVERFLOW_THRESH_DEFAULT); }, diff --git a/packages/api-utils/tests/test-cortex.js b/test/test-cortex.js similarity index 98% rename from packages/api-utils/tests/test-cortex.js rename to test/test-cortex.js index 9f13f0ec9..ab3d19478 100644 --- a/packages/api-utils/tests/test-cortex.js +++ b/test/test-cortex.js @@ -6,7 +6,7 @@ "use strict"; -var Cortex = require("cortex").Cortex; +var Cortex = require("sdk/deprecated/cortex").Cortex; exports["test property changes propagate"] = function (assert) { var source = { diff --git a/packages/api-utils/tests/test-cuddlefish.js b/test/test-cuddlefish.js similarity index 85% rename from packages/api-utils/tests/test-cuddlefish.js rename to test/test-cuddlefish.js index af4562aba..f160469ef 100644 --- a/packages/api-utils/tests/test-cuddlefish.js +++ b/test/test-cuddlefish.js @@ -4,7 +4,7 @@ 'use strict'; -const { Loader, Require, unload, override } = require('api-utils/cuddlefish'); +const { Loader, Require, unload, override } = require('sdk/loader/cuddlefish'); const packaging = require('@loader/options'); exports['test loader'] = function(assert) { @@ -32,11 +32,11 @@ exports['test loader'] = function(assert) { var unloadsCalled = ''; - require("api-utils/unload").when(function(reason) { + require("sdk/system/unload").when(function(reason) { assert.equal(reason, 'test', 'unload reason is passed'); unloadsCalled += 'a'; }); - require('unload.js').when(function() { + require('sdk/system/unload.js').when(function() { unloadsCalled += 'b'; }); diff --git a/packages/api-utils/tests/test-deprecate.js b/test/test-deprecate.js similarity index 93% rename from packages/api-utils/tests/test-deprecate.js rename to test/test-deprecate.js index 04d68b386..b1e0f3233 100644 --- a/packages/api-utils/tests/test-deprecate.js +++ b/test/test-deprecate.js @@ -2,8 +2,8 @@ * 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/. */ -const deprecate = require("deprecate"); -var { Loader } = require("test-harness/loader"); +const deprecate = require("sdk/util/deprecate"); +var { Loader } = require("sdk/test/loader"); function LoaderWithHookedConsole() { let errors = []; @@ -17,7 +17,7 @@ function LoaderWithHookedConsole() { return { loader: loader, - deprecate: loader.require("api-utils/deprecate"), + deprecate: loader.require("sdk/util/deprecate"), errors: errors } } diff --git a/packages/api-utils/tests/test-list.js b/test/test-deprecated-list.js similarity index 98% rename from packages/api-utils/tests/test-list.js rename to test/test-deprecated-list.js index 1d8e04600..4b5f5982d 100644 --- a/packages/api-utils/tests/test-list.js +++ b/test/test-deprecated-list.js @@ -28,7 +28,7 @@ function assertList(test, array, list) { } } -const { List } = require('api-utils/list'); +const { List } = require('sdk/deprecated/list'); exports['test:test for'] = function(test) { let fixture = List(3, 2, 1); diff --git a/packages/api-utils/tests/test-dom.js b/test/test-dom.js similarity index 94% rename from packages/api-utils/tests/test-dom.js rename to test/test-dom.js index 52ab1c3ec..87c8372cd 100644 --- a/packages/api-utils/tests/test-dom.js +++ b/test/test-dom.js @@ -4,8 +4,8 @@ "use strict"; -const events = require("dom/events"); -const { activeBrowserWindow: { document } } = require("window-utils"); +const events = require("sdk/dom/events"); +const { activeBrowserWindow: { document } } = require("sdk/deprecated/window-utils"); const window = document.window; exports["test on / emit"] = function (assert, done) { diff --git a/packages/api-utils/tests/test-environment.js b/test/test-environment.js similarity index 97% rename from packages/api-utils/tests/test-environment.js rename to test/test-environment.js index 1d7e78369..413997f36 100644 --- a/packages/api-utils/tests/test-environment.js +++ b/test/test-environment.js @@ -4,7 +4,7 @@ 'use strict'; -const { env } = require('api-utils/environment'); +const { env } = require('sdk/system/environment'); const { Cc, Ci } = require('chrome'); const { get, set, exists } = Cc['@mozilla.org/process/environment;1']. getService(Ci.nsIEnvironment); diff --git a/packages/api-utils/tests/test-errors.js b/test/test-errors.js similarity index 98% rename from packages/api-utils/tests/test-errors.js rename to test/test-errors.js index 64bb6c9ab..91ffd7896 100644 --- a/packages/api-utils/tests/test-errors.js +++ b/test/test-errors.js @@ -2,7 +2,7 @@ * 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/. */ -var errors = require("errors"); +var errors = require("sdk/deprecated/errors"); exports.testCatchAndLog = function(test) { var caught = []; diff --git a/packages/api-utils/tests/test-event-core.js b/test/test-event-core.js similarity index 97% rename from packages/api-utils/tests/test-event-core.js rename to test/test-event-core.js index 3db7def12..2d9413760 100644 --- a/packages/api-utils/tests/test-event-core.js +++ b/test/test-event-core.js @@ -4,8 +4,8 @@ 'use strict'; -const { on, once, off, emit, count, amass } = require('api-utils/event/core'); -const { Loader } = require('test-harness/loader'); +const { on, once, off, emit, count, amass } = require('sdk/event/core'); +const { Loader } = require('sdk/test/loader'); exports['test add a listener'] = function(assert) { let events = [ { name: 'event#1' }, 'event#2' ]; @@ -166,7 +166,7 @@ exports['test unhandled errors'] = function(assert) { }} }) }); - let { emit, on } = loader.require('api-utils/event/core'); + let { emit, on } = loader.require('sdk/event/core'); let target = {}; let boom = Error('Boom!'); let drax = Error('Draax!!'); diff --git a/packages/api-utils/tests/test-event-target.js b/test/test-event-target.js similarity index 93% rename from packages/api-utils/tests/test-event-target.js rename to test/test-event-target.js index 30a0c2b88..d972454da 100644 --- a/packages/api-utils/tests/test-event-target.js +++ b/test/test-event-target.js @@ -4,9 +4,9 @@ 'use strict'; -const { emit } = require('api-utils/event/core'); -const { EventTarget } = require('api-utils/event/target'); -const { Loader } = require('test-harness/loader'); +const { emit } = require('sdk/event/core'); +const { EventTarget } = require('sdk/event/target'); +const { Loader } = require('sdk/test/loader'); exports['test add a listener'] = function(assert) { let events = [ { name: 'event#1' }, 'event#2' ]; @@ -138,9 +138,9 @@ exports['test error handling'] = function(assert) { exports['test unhandled errors'] = function(assert) { let exceptions = []; let loader = Loader(module); - let { emit } = loader.require('api-utils/event/core'); - let { EventTarget } = loader.require('api-utils/event/target'); - Object.defineProperties(loader.sandbox('api-utils/event/core'), { + let { emit } = loader.require('sdk/event/core'); + let { EventTarget } = loader.require('sdk/event/target'); + Object.defineProperties(loader.sandbox('sdk/event/core'), { console: { value: { exception: function(e) { exceptions.push(e); diff --git a/packages/api-utils/tests/test-events.js b/test/test-events.js similarity index 98% rename from packages/api-utils/tests/test-events.js rename to test/test-events.js index 3fe6f0380..a1f87bf77 100644 --- a/packages/api-utils/tests/test-events.js +++ b/test/test-events.js @@ -5,7 +5,7 @@ 'use strict'; // Exposing private methods as public in order to test -const EventEmitter = require('events').EventEmitter.compose({ +const EventEmitter = require('sdk/deprecated/events').EventEmitter.compose({ listeners: function(type) this._listeners(type), emit: function() this._emit.apply(this, arguments), emitOnObject: function() this._emitOnObject.apply(this, arguments), @@ -243,7 +243,7 @@ exports['test:once'] = function(test) { }; exports["test:removing once"] = function(test) { - let e = require("events").EventEmitterTrait.create(); + let e = require("sdk/deprecated/events").EventEmitterTrait.create(); e.once("foo", function() { test.pass("listener was called"); }); e.once("error", function() { test.fail("error event was emitted"); }); e._emit("foo", "bug-656684"); diff --git a/packages/api-utils/tests/test-file.js b/test/test-file.js similarity index 97% rename from packages/api-utils/tests/test-file.js rename to test/test-file.js index de89db80e..33344b215 100644 --- a/packages/api-utils/tests/test-file.js +++ b/test/test-file.js @@ -4,12 +4,12 @@ "use strict"; -const { pathFor } = require('api-utils/system'); -const file = require("api-utils/file"); -const url = require("api-utils/url"); +const { pathFor } = require('sdk/system'); +const file = require("sdk/io/file"); +const url = require("sdk/url"); -const byteStreams = require("api-utils/byte-streams"); -const textStreams = require("api-utils/text-streams"); +const byteStreams = require("sdk/io/byte-streams"); +const textStreams = require("sdk/io/text-streams"); const ERRORS = { FILE_NOT_FOUND: /^path does not exist: .+$/, diff --git a/packages/api-utils/tests/test-frame-utils.js b/test/test-frame-utils.js similarity index 96% rename from packages/api-utils/tests/test-frame-utils.js rename to test/test-frame-utils.js index 1ccf49085..6225f00a6 100644 --- a/packages/api-utils/tests/test-frame-utils.js +++ b/test/test-frame-utils.js @@ -4,8 +4,8 @@ 'use strict'; -const { open } = require('api-utils/window/utils'); -const { create } = require('api-utils/frame/utils'); +const { open } = require('sdk/window/utils'); +const { create } = require('sdk/frame/utils'); exports['test frame creation'] = function(assert, done) { let window = open('data:text/html;charset=utf-8,Window'); diff --git a/packages/api-utils/tests/test-functional.js b/test/test-functional.js similarity index 98% rename from packages/api-utils/tests/test-functional.js rename to test/test-functional.js index 377a709ff..81d36e986 100644 --- a/packages/api-utils/tests/test-functional.js +++ b/test/test-functional.js @@ -2,8 +2,8 @@ * 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/. */ -const { setTimeout } = require('api-utils/timer'); -const utils = require('api-utils/functional'); +const { setTimeout } = require('sdk/timers'); +const utils = require('sdk/lang/functional'); const { invoke, defer, curry, compose, memoize, once, delay, wrap } = utils; exports['test forwardApply'] = function(assert) { diff --git a/packages/api-utils/tests/test-globals.js b/test/test-globals.js similarity index 100% rename from packages/api-utils/tests/test-globals.js rename to test/test-globals.js diff --git a/packages/api-utils/tests/test-heritage.js b/test/test-heritage.js similarity index 99% rename from packages/api-utils/tests/test-heritage.js rename to test/test-heritage.js index 1bb2b5933..493ffddee 100644 --- a/packages/api-utils/tests/test-heritage.js +++ b/test/test-heritage.js @@ -4,7 +4,7 @@ "use strict"; -const { Class, extend, mix, obscure } = require('api-utils/heritage'); +const { Class, extend, mix, obscure } = require('sdk/core/heritage'); exports['test extend'] = function(assert) { let ancestor = { a: 1 }; diff --git a/packages/api-utils/tests/test-hidden-frame.js b/test/test-hidden-frame.js similarity index 97% rename from packages/api-utils/tests/test-hidden-frame.js rename to test/test-hidden-frame.js index 2fd5ce0bd..cf99df5e2 100644 --- a/packages/api-utils/tests/test-hidden-frame.js +++ b/test/test-hidden-frame.js @@ -28,7 +28,7 @@ tests.testFrame = function(test) { let hiddenFrameSupported = true; try { - hiddenFrames = require("hidden-frame"); + hiddenFrames = require("sdk/frame/hidden-frame"); HiddenFrame = hiddenFrames.HiddenFrame; } catch(ex if ex.message == [ diff --git a/packages/addon-kit/tests/test-hotkeys.js b/test/test-hotkeys.js similarity index 82% rename from packages/addon-kit/tests/test-hotkeys.js rename to test/test-hotkeys.js index f78fb657b..7dc590f88 100644 --- a/packages/addon-kit/tests/test-hotkeys.js +++ b/test/test-hotkeys.js @@ -4,13 +4,14 @@ "use strict"; -const { Hotkey } = require("hotkeys"); -const { keyDown } = require("dom/events/keys"); -const { Loader } = require('test-harness/loader'); -const timer = require("timer"); +const { Hotkey } = require("sdk/hotkeys"); +const { keyDown } = require("sdk/dom/events/keys"); +const { Loader } = require('sdk/test/loader'); +const timer = require("sdk/timers"); +const winUtils = require("sdk/deprecated/window-utils"); exports["test hotkey: function key"] = function(assert, done) { - var element = require("window-utils").activeBrowserWindow.document.documentElement; + var element = winUtils.activeBrowserWindow.document.documentElement; var showHotKey = Hotkey({ combo: "f1", onPress: function() { @@ -33,7 +34,7 @@ exports["test hotkey: function key"] = function(assert, done) { }; exports["test hotkey: accel alt shift"] = function(assert, done) { - var element = require("window-utils").activeBrowserWindow.document.documentElement; + var element = winUtils.activeBrowserWindow.document.documentElement; var showHotKey = Hotkey({ combo: "accel-shift-6", onPress: function() { @@ -56,7 +57,7 @@ exports["test hotkey: accel alt shift"] = function(assert, done) { }; exports["test hotkey meta & control"] = function(assert, done) { - var element = require("window-utils").activeBrowserWindow.document.documentElement; + var element = winUtils.activeBrowserWindow.document.documentElement; var showHotKey = Hotkey({ combo: "meta-3", onPress: function() { @@ -79,7 +80,7 @@ exports["test hotkey meta & control"] = function(assert, done) { }; exports["test hotkey: control-1 / meta--"] = function(assert, done) { - var element = require("window-utils").activeBrowserWindow.document.documentElement; + var element = winUtils.activeBrowserWindow.document.documentElement; var showHotKey = Hotkey({ combo: "control-1", onPress: function() { @@ -123,7 +124,7 @@ exports["test invalid combos"] = function(assert) { }; exports["test no exception on unmodified keypress"] = function(assert) { - var element = require("window-utils").activeBrowserWindow.document.documentElement; + var element = winUtils.activeBrowserWindow.document.documentElement; var someHotkey = Hotkey({ combo: "control-alt-1", onPress: function() { @@ -138,8 +139,8 @@ exports["test hotkey: automatic destroy"] = function(assert, done) { let loader = Loader(module); var called = false; - var element = loader.require("window-utils").activeBrowserWindow.document.documentElement; - var hotkey = loader.require("hotkeys").Hotkey({ + var element = loader.require("sdk/deprecated/window-utils").activeBrowserWindow.document.documentElement; + var hotkey = loader.require("sdk/hotkeys").Hotkey({ combo: "accel-shift-x", onPress: function() { called = true; diff --git a/packages/api-utils/tests/test-httpd.js b/test/test-httpd.js similarity index 86% rename from packages/api-utils/tests/test-httpd.js rename to test/test-httpd.js index dc1adf149..1ab952245 100644 --- a/packages/api-utils/tests/test-httpd.js +++ b/test/test-httpd.js @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const port = 8099; -const file = require("api-utils/file"); -const { pathFor } = require("api-utils/system"); +const file = require("sdk/io/file"); +const { pathFor } = require("sdk/system"); exports.testBasicHTTPServer = function(test) { let basePath = pathFor("TmpD"); @@ -14,13 +14,13 @@ exports.testBasicHTTPServer = function(test) { fileStream.write(content); fileStream.close(); - let { startServerAsync } = require("httpd"); + let { startServerAsync } = require("sdk/test/httpd"); let srv = startServerAsync(port, basePath); test.waitUntilDone(); // Request this very file. - let Request = require('request').Request; + let Request = require('sdk/request').Request; Request({ url: "http://localhost:" + port + "/test-httpd.txt", onComplete: function (response) { @@ -39,7 +39,7 @@ exports.testBasicHTTPServer = function(test) { exports.testDynamicServer = function (test) { let content = "This is the HTTPD test file.\n"; - let { startServerAsync } = require("httpd"); + let { startServerAsync } = require("sdk/test/httpd"); let srv = startServerAsync(port); // See documentation here: @@ -54,7 +54,7 @@ exports.testDynamicServer = function (test) { test.waitUntilDone(); // Request this very file. - let Request = require('request').Request; + let Request = require('sdk/request').Request; Request({ url: "http://localhost:" + port + "/test-httpd.txt", onComplete: function (response) { diff --git a/packages/api-utils/tests/test-keyboard-observer.js b/test/test-keyboard-observer.js similarity index 78% rename from packages/api-utils/tests/test-keyboard-observer.js rename to test/test-keyboard-observer.js index 7d1fcf047..091ec73c5 100644 --- a/packages/api-utils/tests/test-keyboard-observer.js +++ b/test/test-keyboard-observer.js @@ -4,15 +4,15 @@ "use strict"; -const { keyPress } = require("api-utils/dom/events/keys"); -const { Loader } = require("test-harness/loader"); -const timer = require("timer"); +const { keyPress } = require("sdk/dom/events/keys"); +const { Loader } = require("sdk/test/loader"); +const timer = require("sdk/timers"); exports["test unload keyboard observer"] = function(assert, done) { let loader = Loader(module); - let element = loader.require("api-utils/window-utils"). + let element = loader.require("sdk/deprecated/window-utils"). activeBrowserWindow.document.documentElement; - let observer = loader.require("api-utils/keyboard/observer"). + let observer = loader.require("sdk/keyboard/observer"). observer; let called = 0; diff --git a/packages/api-utils/tests/test-keyboard-utils.js b/test/test-keyboard-utils.js similarity index 95% rename from packages/api-utils/tests/test-keyboard-utils.js rename to test/test-keyboard-utils.js index 1146a7bc3..19981dec3 100644 --- a/packages/api-utils/tests/test-keyboard-utils.js +++ b/test/test-keyboard-utils.js @@ -4,8 +4,8 @@ "use strict"; -const utils = require("keyboard/utils"); -const runtime = require("runtime"); +const utils = require("sdk/keyboard/utils"); +const runtime = require("sdk/system/runtime"); const isMac = runtime.OS === "Darwin"; diff --git a/packages/api-utils/tests/test-l10n-locale.js b/test/test-l10n-locale.js similarity index 97% rename from packages/api-utils/tests/test-l10n-locale.js rename to test/test-l10n-locale.js index db559ba0e..19e716da5 100644 --- a/packages/api-utils/tests/test-l10n-locale.js +++ b/test/test-l10n-locale.js @@ -2,8 +2,8 @@ * 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/. */ -const { getPreferedLocales, findClosestLocale } = require("api-utils/l10n/locale"); -const prefs = require("preferences-service"); +const { getPreferedLocales, findClosestLocale } = require("sdk/l10n/locale"); +const prefs = require("sdk/preferences/service"); const { Cc, Ci, Cu } = require("chrome"); const { Services } = Cu.import("resource://gre/modules/Services.jsm"); const BundleService = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService); diff --git a/packages/api-utils/tests/test-l10n-plural-rules.js b/test/test-l10n-plural-rules.js similarity index 96% rename from packages/api-utils/tests/test-l10n-plural-rules.js rename to test/test-l10n-plural-rules.js index e46ecf673..6ee8a1308 100644 --- a/packages/api-utils/tests/test-l10n-plural-rules.js +++ b/test/test-l10n-plural-rules.js @@ -2,7 +2,7 @@ * 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/. */ -const { getRulesForLocale } = require("api-utils/l10n/plural-rules"); +const { getRulesForLocale } = require("sdk/l10n/plural-rules"); // For more information, please visit unicode website: // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html diff --git a/test/test-layout-change.js b/test/test-layout-change.js new file mode 100644 index 000000000..a26225159 --- /dev/null +++ b/test/test-layout-change.js @@ -0,0 +1,178 @@ +/* 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"; + +// This test makes sure that require statements used by all AMO hosted +// add-ons will be able to use old require statements. +// Tests are based on following usage data: +// https://docs.google.com/spreadsheet/ccc?key=0ApEBy-GRnGxzdHlRMHJ5RXN1aWJ4RGhINkxSd0FCQXc#gid=0 + +exports["test compatibility"] = function(assert) { + assert.equal(require("self"), + require("sdk/self"), "sdk/self -> self"); + + assert.equal(require("tabs"), + require("sdk/tabs"), "sdk/tabs -> tabs"); + + assert.equal(require("widget"), + require("sdk/widget"), "sdk/widget -> widget"); + + assert.equal(require("page-mod"), + require("sdk/page-mod"), "sdk/page-mod -> page-mod"); + + assert.equal(require("panel"), + require("sdk/panel"), "sdk/panel -> panel"); + + assert.equal(require("request"), + require("sdk/request"), "sdk/request -> request"); + + assert.equal(require("chrome"), + require("chrome"), "chrome -> chrome"); + + assert.equal(require("simple-storage"), + require("sdk/simple-storage"), "sdk/simple-storage -> simple-storage"); + + assert.equal(require("context-menu"), + require("sdk/context-menu"), "sdk/context-menu -> context-menu"); + + assert.equal(require("notifications"), + require("sdk/notifications"), "sdk/notifications -> notifications"); + + assert.equal(require("preferences-service"), + require("sdk/preferences/service"), "sdk/preferences/service -> preferences-service"); + + assert.equal(require("window-utils"), + require("sdk/deprecated/window-utils"), "sdk/deprecated/window-utils -> window-utils"); + + assert.equal(require("url"), + require("sdk/url"), "sdk/url -> url"); + + assert.equal(require("selection"), + require("sdk/selection"), "sdk/selection -> selection"); + + assert.equal(require("timers"), + require("sdk/timers"), "sdk/timers -> timers"); + + assert.equal(require("simple-prefs"), + require("sdk/simple-prefs"), "sdk/simple-prefs -> simple-prefs"); + + assert.equal(require("traceback"), + require("sdk/console/traceback"), "sdk/console/traceback -> traceback"); + + assert.equal(require("unload"), + require("sdk/system/unload"), "sdk/system/unload -> unload"); + + assert.equal(require("hotkeys"), + require("sdk/hotkeys"), "sdk/hotkeys -> hotkeys"); + + assert.equal(require("clipboard"), + require("sdk/clipboard"), "sdk/clipboard -> clipboard"); + + assert.equal(require("windows"), + require("sdk/windows"), "sdk/windows -> windows"); + + assert.equal(require("page-worker"), + require("sdk/page-worker"), "sdk/page-worker -> page-worker"); + + assert.equal(require("timer"), + require("sdk/timers"), "sdk/timers -> timer"); + + assert.equal(require("xhr"), + require("sdk/net/xhr"), "sdk/io/xhr -> xhr"); + + assert.equal(require("observer-service"), + require("sdk/deprecated/observer-service"), "sdk/deprecated/observer-service -> observer-service"); + + assert.equal(require("private-browsing"), + require("sdk/private-browsing"), "sdk/private-browsing -> private-browsing"); + + assert.equal(require("passwords"), + require("sdk/passwords"), "sdk/passwords -> passwords"); + + assert.equal(require("events"), + require("sdk/deprecated/events"), "sdk/deprecated/events -> events"); + + assert.equal(require("match-pattern"), + require("sdk/page-mod/match-pattern"), "sdk/page-mod/match-pattern -> match-pattern"); + + assert.equal(require("tab-browser"), + require("sdk/deprecated/tab-browser"), "sdk/deprecated/tab-browser -> tab-browser"); + + assert.equal(require("file"), + require("sdk/io/file"), "sdk/io/file -> file"); + + assert.equal(require("xul-app"), + require("sdk/system/xul-app"), "sdk/system/xul-app -> xul-app"); + + assert.equal(require("api-utils"), + require("sdk/deprecated/api-utils"), "sdk/deprecated/api-utils -> api-utils"); + + assert.equal(require("runtime"), + require("sdk/system/runtime"), "sdk/system/runtime -> runtime"); + + assert.equal(require("base64"), + require("sdk/base64"), "sdk/base64 -> base64"); + + assert.equal(require("xpcom"), + require("sdk/platform/xpcom"), "sdk/platform/xpcom -> xpcom"); + + assert.equal(require("traits"), + require("sdk/deprecated/traits"), "sdk/deprecated/traits -> traits"); + + assert.equal(require("keyboard/utils"), + require("sdk/keyboard/utils"), "sdk/keyboard/utils -> keyboard/utils"); + + assert.equal(require("system"), + require("sdk/system"), "sdk/system -> system"); + + assert.equal(require("querystring"), + require("sdk/querystring"), "sdk/querystring -> querystring"); + + assert.equal(require("addon-page"), + require("sdk/addon-page"), "sdk/addon-page -> addon-page"); + + assert.equal(require("tabs/utils"), + require("sdk/tabs/utils"), "sdk/tabs/utils -> tabs/utils"); + + assert.equal(require("app-strings"), + require("sdk/deprecated/app-strings"), "sdk/deprecated/app-strings -> app-strings"); + + assert.equal(require("dom/events"), + require("sdk/dom/events"), "sdk/dom/events -> dom/events"); + + assert.equal(require("tabs/tab.js"), + require("sdk/tabs/tab"), "sdk/tabs/tab -> tabs/tab.js"); + + assert.equal(require("memory"), + require("sdk/deprecated/memory"), "sdk/deprecated/memory -> memory"); + + assert.equal(require("light-traits"), + require("sdk/deprecated/light-traits"), "sdk/deprecated/light-traits -> light-traits"); + + assert.equal(require("environment"), + require("sdk/system/environment"), "sdk/system/environment -> environment"); + + assert.equal(require("utils/data"), + require("sdk/io/data"), "sdk/io/data -> utils/data"); + + assert.equal(require("test/assert"), + require("sdk/test/assert"), "sdk/test/assert -> test/assert"); + + assert.equal(require("hidden-frame"), + require("sdk/frame/hidden-frame"), "sdk/frame/hidden-frame -> hidden-frame"); + + assert.equal(require("collection"), + require("sdk/util/collection"), "sdk/util/collection -> collection"); + + assert.equal(require("array"), + require("sdk/util/array"), "sdk/util/array -> array"); + + assert.equal(require("api-utils/cortex"), + require("sdk/deprecated/cortex"), + "api-utils/cortex -> sdk/deprecated/cortex"); +}; + + +require('test').run(exports); diff --git a/packages/api-utils/tests/test-light-traits.js b/test/test-light-traits.js similarity index 100% rename from packages/api-utils/tests/test-light-traits.js rename to test/test-light-traits.js diff --git a/packages/api-utils/tests/test-new-list.js b/test/test-list.js similarity index 90% rename from packages/api-utils/tests/test-new-list.js rename to test/test-list.js index ac146a715..1e345d283 100644 --- a/packages/api-utils/tests/test-new-list.js +++ b/test/test-list.js @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; -const { List, addListItem, removeListItem } = require('api-utils/list/new'); -const { Class } = require('api-utils/heritage'); +const { List, addListItem, removeListItem } = require('sdk/util/list'); +const { Class } = require('sdk/core/heritage'); exports.testList = function(test) { let list = List(); diff --git a/packages/api-utils/tests/test-loader.js b/test/test-loader.js similarity index 92% rename from packages/api-utils/tests/test-loader.js rename to test/test-loader.js index fe59b00ff..08c285fe8 100644 --- a/packages/api-utils/tests/test-loader.js +++ b/test/test-loader.js @@ -4,7 +4,7 @@ 'use strict'; -let { Loader, main, unload } = require('api-utils/loader'); +let { Loader, main, unload } = require('toolkit/loader'); exports['test dependency cycles'] = function(assert) { let uri = module.uri.substr(0, module.uri.lastIndexOf('/')) + diff --git a/packages/api-utils/tests/test-match-pattern.js b/test/test-match-pattern.js similarity index 98% rename from packages/api-utils/tests/test-match-pattern.js rename to test/test-match-pattern.js index 9cedf6699..f0db49262 100644 --- a/packages/api-utils/tests/test-match-pattern.js +++ b/test/test-match-pattern.js @@ -4,7 +4,7 @@ * 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/. */ -const { MatchPattern } = require("match-pattern"); +const { MatchPattern } = require("sdk/page-mod/match-pattern"); exports.testMatchPatternTestTrue = function(test) { function ok(pattern, url) { diff --git a/packages/api-utils/tests/test-memory.js b/test/test-memory.js similarity index 92% rename from packages/api-utils/tests/test-memory.js rename to test/test-memory.js index 99e1682d4..e225707d5 100644 --- a/packages/api-utils/tests/test-memory.js +++ b/test/test-memory.js @@ -2,7 +2,7 @@ * 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/. */ -var memory = require("api-utils/memory"); +var memory = require("sdk/deprecated/memory"); exports.testMemory = function(test) { test.pass("Skipping this test until Gecko memory debugging issues " + diff --git a/packages/addon-kit/tests/test-module.js b/test/test-module.js similarity index 84% rename from packages/addon-kit/tests/test-module.js rename to test/test-module.js index 957d0754b..6c9c6c2b7 100644 --- a/packages/addon-kit/tests/test-module.js +++ b/test/test-module.js @@ -6,12 +6,12 @@ /** Disabled because of Bug 672199 exports["test module exports are frozen"] = function(assert) { - assert.ok(Object.isFrozen(require("addon-kit/hotkeys")), + assert.ok(Object.isFrozen(require("sdk/hotkeys")), "module exports are frozen"); }; exports["test redefine exported property"] = function(assert) { - let hotkeys = require("addon-kit/hotkeys"); + let hotkeys = require("sdk/hotkeys"); let { Hotkey } = hotkeys; try { Object.defineProperty(hotkeys, 'Hotkey', { value: {} }); } catch(e) {} assert.equal(hotkeys.Hotkey, Hotkey, "exports can't be redefined"); @@ -19,7 +19,7 @@ exports["test redefine exported property"] = function(assert) { */ exports["test can't delete exported property"] = function(assert) { - let hotkeys = require("addon-kit/hotkeys"); + let hotkeys = require("sdk/hotkeys"); let { Hotkey } = hotkeys; try { delete hotkeys.Hotkey; } catch(e) {} @@ -27,7 +27,7 @@ exports["test can't delete exported property"] = function(assert) { }; exports["test can't override exported property"] = function(assert) { - let hotkeys = require("addon-kit/hotkeys"); + let hotkeys = require("sdk/hotkeys"); let { Hotkey } = hotkeys; try { hotkeys.Hotkey = Object } catch(e) {} diff --git a/packages/api-utils/tests/test-modules.js b/test/test-modules.js similarity index 100% rename from packages/api-utils/tests/test-modules.js rename to test/test-modules.js diff --git a/packages/api-utils/tests/test-namespace.js b/test/test-namespace.js similarity index 95% rename from packages/api-utils/tests/test-namespace.js rename to test/test-namespace.js index 58f96ff2b..dfe88da60 100644 --- a/packages/api-utils/tests/test-namespace.js +++ b/test/test-namespace.js @@ -4,9 +4,9 @@ "use strict"; -const { ns } = require("api-utils/namespace"); +const { ns } = require("sdk/core/namespace"); const { Cc, Ci, Cu } = require("chrome"); -const { setTimeout } = require("api-utils/timer") +const { setTimeout } = require("sdk/timers") exports["test post GC references"] = function (assert, done) { var target = {}, local = ns() @@ -88,7 +88,7 @@ exports["test multi namespace"] = function(assert) { }; exports["test ns alias"] = function(assert) { - assert.strictEqual(ns, require('api-utils/namespace').Namespace, + assert.strictEqual(ns, require('sdk/core/namespace').Namespace, "ns is an alias of Namespace"); }; diff --git a/packages/api-utils/tests/test-url-io.js b/test/test-net-url.js similarity index 89% rename from packages/api-utils/tests/test-url-io.js rename to test/test-net-url.js index 54cee6077..302c402ca 100644 --- a/packages/api-utils/tests/test-url-io.js +++ b/test/test-net-url.js @@ -4,7 +4,7 @@ "use strict"; -const { readURI, readURISync } = require("api-utils/url/io"); +const { readURI, readURISync } = require("sdk/net/url"); const { data } = require("self"); const utf8text = "Hello, ゼロ!"; @@ -17,7 +17,7 @@ const chromeURI = "chrome://global-platform/locale/accessible.properties"; exports["test async readURI"] = function(assert, done) { let content = ""; - readURI(data.url("test-uri-io.txt")).then(function(data) { + readURI(data.url("test-net-url.txt")).then(function(data) { content = data; assert.equal(content, utf8text, "The URL content is loaded properly"); done(); @@ -32,7 +32,7 @@ exports["test async readURI"] = function(assert, done) { exports["test sync readURI"] = function(assert) { let content = ""; - readURI(data.url("test-uri-io.txt"), { sync: true }).then(function(data) { + readURI(data.url("test-net-url.txt"), { sync: true }).then(function(data) { content = data; }, function() { assert.fail("should not reject"); @@ -42,7 +42,7 @@ exports["test sync readURI"] = function(assert) { } exports["test readURISync"] = function(assert) { - let content = readURISync(data.url("test-uri-io.txt")); + let content = readURISync(data.url("test-net-url.txt")); assert.equal(content, utf8text, "The URL content is loaded properly"); } @@ -50,7 +50,7 @@ exports["test readURISync"] = function(assert) { exports["test async readURI with ISO-8859-1 charset"] = function(assert, done) { let content = ""; - readURI(data.url("test-uri-io.txt"), { charset : "ISO-8859-1"}).then(function(data) { + readURI(data.url("test-net-url.txt"), { charset : "ISO-8859-1"}).then(function(data) { content = data; assert.equal(content, latin1text, "The URL content is loaded properly"); done(); @@ -65,7 +65,7 @@ exports["test async readURI with ISO-8859-1 charset"] = function(assert, done) { exports["test sync readURI with ISO-8859-1 charset"] = function(assert) { let content = ""; - readURI(data.url("test-uri-io.txt"), { + readURI(data.url("test-net-url.txt"), { sync: true, charset: "ISO-8859-1" }).then(function(data) { @@ -78,13 +78,13 @@ exports["test sync readURI with ISO-8859-1 charset"] = function(assert) { } exports["test readURISync with ISO-8859-1 charset"] = function(assert) { - let content = readURISync(data.url("test-uri-io.txt"), "ISO-8859-1"); + let content = readURISync(data.url("test-net-url.txt"), "ISO-8859-1"); assert.equal(content, latin1text, "The URL content is loaded properly"); } exports["test async readURI with not existing file"] = function(assert, done) { - readURI(data.url("test-uri-io-fake.txt")).then(function(data) { + readURI(data.url("test-net-url-fake.txt")).then(function(data) { assert.fail("should not resolve"); done(); }, function(reason) { @@ -94,7 +94,7 @@ exports["test async readURI with not existing file"] = function(assert, done) { } exports["test sync readURI with not existing file"] = function(assert) { - readURI(data.url("test-uri-io-fake.txt"), { sync: true }).then(function(data) { + readURI(data.url("test-net-url-fake.txt"), { sync: true }).then(function(data) { assert.fail("should not resolve"); }, function(reason) { assert.ok(reason.indexOf("Failed to read:") === 0); @@ -103,7 +103,7 @@ exports["test sync readURI with not existing file"] = function(assert) { exports["test readURISync with not existing file"] = function(assert) { assert.throws(function() { - readURISync(data.url("test-uri-io-fake.txt")); + readURISync(data.url("test-net-url-fake.txt")); }, /NS_ERROR_FILE_NOT_FOUND/); } diff --git a/packages/addon-kit/tests/test-notifications.js b/test/test-notifications.js similarity index 88% rename from packages/addon-kit/tests/test-notifications.js rename to test/test-notifications.js index 267c700e9..3f2941018 100644 --- a/packages/addon-kit/tests/test-notifications.js +++ b/test/test-notifications.js @@ -4,11 +4,11 @@ * 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/. */ -const { Loader } = require('test-harness/loader'); +const { Loader } = require('sdk/test/loader'); exports.testOnClick = function (test) { let [loader, mockAlertServ] = makeLoader(module); - let notifs = loader.require("notifications"); + let notifs = loader.require("sdk/notifications"); let data = "test data"; let opts = { onClick: function (clickedData) { @@ -39,8 +39,8 @@ function makeLoader(test) { this._alertListener.observe(null, "alertclickcallback", this._cookie); } }; - loader.require("notifications"); - let scope = loader.sandbox("notifications"); + loader.require("sdk/notifications"); + let scope = loader.sandbox("sdk/notifications"); scope.notify = mockAlertServ.showAlertNotification.bind(mockAlertServ); return [loader, mockAlertServ]; }; diff --git a/packages/api-utils/tests/test-observer-service.js b/test/test-observer-service.js similarity index 88% rename from packages/api-utils/tests/test-observer-service.js rename to test/test-observer-service.js index 091079bb5..bd4c90326 100644 --- a/packages/api-utils/tests/test-observer-service.js +++ b/test/test-observer-service.js @@ -2,10 +2,10 @@ * 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/. */ -const observers = require("api-utils/observer-service"); +const observers = require("sdk/deprecated/observer-service"); const { Cc, Ci } = require("chrome"); -const { Loader } = require("test-harness/loader"); -const { PlainTextConsole } = require("api-utils/plain-text-console"); +const { Loader } = require("sdk/test/loader"); +const { PlainTextConsole } = require("sdk/console/plain-text"); exports.testUnloadAndErrorLogging = function(test) { var prints = []; @@ -14,7 +14,7 @@ exports.testUnloadAndErrorLogging = function(test) { prints.push(_); }) }); - var sbobsvc = loader.require("api-utils/observer-service"); + var sbobsvc = loader.require("sdk/deprecated/observer-service"); var timesCalled = 0; var cb = function(subject, data) { @@ -29,7 +29,7 @@ exports.testUnloadAndErrorLogging = function(test) { sbobsvc.add("narg", badCb); observers.notify("narg", "yo yo"); var lines = prints[0].split("\n"); - test.assertEqual(lines[0], "error: " + require("self").name + ": An exception occurred."); + test.assertEqual(lines[0], "error: " + require("sdk/self").name + ": An exception occurred."); test.assertEqual(lines[1], "Traceback (most recent call last):"); test.assertEqual(lines.slice(-2)[0], "Error: foo"); diff --git a/packages/test-harness/tests/test-packaging.js b/test/test-packaging.js similarity index 70% rename from packages/test-harness/tests/test-packaging.js rename to test/test-packaging.js index a61bd4427..b7a96cdbd 100644 --- a/packages/test-harness/tests/test-packaging.js +++ b/test/test-packaging.js @@ -2,14 +2,14 @@ * 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/. */ -var url = require("url"); -var file = require("file"); +var url = require("sdk/url"); +var file = require("sdk/io/file"); var {Cm,Ci} = require("chrome"); var options = require("@loader/options"); exports.testPackaging = function(test) { - test.assertEqual(options.metadata.author, - 'Atul Varma (http://toolness.com/)', + test.assertEqual(options.metadata.description, + "Add-on development made easy.", "packaging metadata should be available"); }; diff --git a/packages/addon-kit/tests/test-page-mod.js b/test/test-page-mod.js similarity index 94% rename from packages/addon-kit/tests/test-page-mod.js rename to test/test-page-mod.js index 3ae205124..2221012cf 100644 --- a/packages/addon-kit/tests/test-page-mod.js +++ b/test/test-page-mod.js @@ -4,14 +4,15 @@ "use strict"; -var pageMod = require("page-mod"); -var testPageMod = require("pagemod-test-helpers").testPageMod; -const { Loader } = require('test-harness/loader'); -const tabs = require("tabs"); -const timer = require("timer"); +var pageMod = require("sdk/page-mod"); +var testPageMod = require("./pagemod-test-helpers").testPageMod; +const { Loader } = require('sdk/test/loader'); +const tabs = require("sdk/tabs"); +const timer = require("sdk/timers"); const { Cc, Ci } = require("chrome"); -const windowUtils = require('api-utils/window/utils'); -const { getTabContentWindow, getActiveTab } = require("api-utils/tabs/utils"); +const { open } = require('sdk/window/utils'); +const windowUtils = require('sdk/deprecated/window-utils'); +const { getTabContentWindow, getActiveTab } = require('sdk/tabs/utils'); /* XXX This can be used to delay closing the test Firefox instance for interactive * testing or visual inspection. This test is registered first so that it runs @@ -303,7 +304,7 @@ exports.testHistory = function(test) { // We need a valid url in order to have a working History API. // (i.e do not work on data: or about: pages) // Test bug 679054. - let url = require("self").data.url("test-page-mod.html"); + let url = require("sdk/self").data.url("test-page-mod.html"); let callbackDone = null; testPageMod(test, url, [{ include: url, @@ -331,7 +332,7 @@ exports.testRelatedTab = function(test) { test.waitUntilDone(); let tab; - let { PageMod } = require("page-mod"); + let { PageMod } = require("sdk/page-mod"); let pageMod = new PageMod({ include: "about:*", onAttach: function(worker) { @@ -355,7 +356,7 @@ exports.testWorksWithExistingTabs = function(test) { test.waitUntilDone(); let url = "data:text/html;charset=utf-8," + encodeURI("Test unique document"); - let { PageMod } = require("page-mod"); + let { PageMod } = require("sdk/page-mod"); tabs.open({ url: url, onReady: function onReady(tab) { @@ -377,9 +378,9 @@ exports.testWorksWithExistingTabs = function(test) { exports['test tab worker on message'] = function(test) { test.waitUntilDone(); - let { browserWindows } = require("windows"); - let tabs = require("tabs"); - let { PageMod } = require("page-mod"); + let { browserWindows } = require("sdk/windows"); + let tabs = require("sdk/tabs"); + let { PageMod } = require("sdk/page-mod"); let url1 = "data:text/html;charset=utf-8,tab1

worker1.tab

"; let url2 = "data:text/html;charset=utf-8,tab2

worker2.tab

"; @@ -422,7 +423,7 @@ exports.testAutomaticDestroy = function(test) { test.waitUntilDone(); let loader = Loader(module); - let pageMod = loader.require("page-mod").PageMod({ + let pageMod = loader.require("sdk/page-mod").PageMod({ include: "about:*", contentScriptWhen: "start", onAttach: function(w) { @@ -434,7 +435,7 @@ exports.testAutomaticDestroy = function(test) { loader.unload(); // Then create a second tab to ensure that it is correctly destroyed - let tabs = require("tabs"); + let tabs = require("sdk/tabs"); tabs.open({ url: "about:", onReady: function onReady(tab) { @@ -449,7 +450,7 @@ exports.testAutomaticDestroy = function(test) { exports['test attachment to tabs only'] = function(test) { test.waitUntilDone(); - let { PageMod } = require('page-mod'); + let { PageMod } = require('sdk/page-mod'); let openedTab = null; // Tab opened in openTabWithIframe() let workerCount = 0; @@ -474,7 +475,7 @@ exports['test attachment to tabs only'] = function(test) { function openHiddenFrame() { console.info('Open iframe in hidden window'); - let hiddenFrames = require('api-utils/hidden-frame'); + let hiddenFrames = require('sdk/frame/hidden-frame'); let hiddenFrame = hiddenFrames.add(hiddenFrames.HiddenFrame({ onReady: function () { let element = this.element; @@ -490,7 +491,7 @@ exports['test attachment to tabs only'] = function(test) { function openToplevelWindow() { console.info('Open toplevel window'); - let win = windowUtils.open('data:text/html;charset=utf-8,bar'); + let win = open('data:text/html;charset=utf-8,bar'); win.addEventListener('DOMContentLoaded', function onload() { win.removeEventListener('DOMContentLoaded', onload, false); win.close(); @@ -500,7 +501,7 @@ exports['test attachment to tabs only'] = function(test) { function openBrowserIframe() { console.info('Open iframe in browser window'); - let window = require('api-utils/window-utils').activeBrowserWindow; + let window = require('sdk/deprecated/window-utils').activeBrowserWindow; let document = window.document; let iframe = document.createElement('iframe'); iframe.setAttribute('type', 'content'); @@ -519,7 +520,7 @@ exports['test attachment to tabs only'] = function(test) { let subContent = '