From 0118051c68deb32189174aba4da88ee910d85e16 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel Date: Tue, 10 May 2011 09:44:24 -0600 Subject: [PATCH] move all modules from nested package hierarchy into modules/, whomp on the loader code until it digs the new structure. issue #82 --- .../xulrunner.template/components/harness.js | 9 +- impl/cuddlefish/__init__.py | 92 +- .../lib => modules/internal}/cuddlefish.js | 52 +- .../api-utils/lib => modules/internal}/es5.js | 0 .../lib => modules/internal}/main.js | 10 +- .../internal}/securable-module.js | 0 .../api-utils => modules}/lib/api-utils.js | 0 .../lib/app-paths.js | 0 .../api-utils => modules}/lib/app-strings.js | 0 .../chromeless-kit => modules}/lib/appinfo.js | 0 .../api-utils => modules}/lib/byte-streams.js | 0 .../lib/canvas-proxy.js | 0 .../lib/child_process.js | 0 .../lib/chromeless-sandbox-window.js | 0 .../addon-kit => modules}/lib/clipboard.js | 0 .../api-utils => modules}/lib/collection.js | 0 .../lib/console-service.js | 0 .../api-utils => modules}/lib/content.js | 0 .../lib/content/loader.js | 0 .../lib/content/symbiont.js | 0 .../lib/content/worker.js | 0 .../chromeless-kit => modules}/lib/cookie.js | 0 {packages/api-utils => modules}/lib/cortex.js | 0 .../lib/custom-protocol.js | 0 .../lib/dictionary.js | 0 .../lib/dragdrop.js | 0 {packages/api-utils => modules}/lib/e10s.js | 0 {packages/api-utils => modules}/lib/errors.js | 0 {packages/api-utils => modules}/lib/events.js | 0 .../chromeless-kit => modules}/lib/favicon.js | 0 .../lib/file-picker.js | 0 {packages/api-utils => modules}/lib/file.js | 0 .../lib/find-tests-e10s-adapter.js | 0 .../api-utils => modules}/lib/find-tests.js | 0 .../chromeless-kit => modules}/lib/fs.js | 0 .../lib/fullscreen.js | 0 .../lib/hidden-frame-xulrunner.js | 0 .../api-utils => modules}/lib/hidden-frame.js | 0 .../chromeless-kit => modules}/lib/hotkey.js | 0 .../api-utils => modules}/lib/light-traits.js | 0 {packages/api-utils => modules}/lib/list.js | 0 .../lib/match-pattern.js | 0 {packages/api-utils => modules}/lib/memory.js | 0 .../chromeless-kit => modules}/lib/menu.js | 0 .../chromeless-kit => modules}/lib/mime.js | 0 .../chromeless-kit => modules}/lib/net.js | 0 .../lib/notifications.js | 0 .../lib/observer-service.js | 0 .../chromeless-kit => modules}/lib/path.js | 0 .../lib/plain-text-console.js | 0 .../lib/preferences-service.js | 0 .../chromeless-kit => modules}/lib/process.js | 0 .../lib/pure_js_events.js | 0 .../addon-kit => modules}/lib/request.js | 0 .../lib/self-e10s-adapter.js | 0 {packages/api-utils => modules}/lib/self.js | 0 .../lib/simple-feature.js | 0 .../api-utils => modules}/lib/text-streams.js | 0 .../lib/timer-e10s-adapter.js | 0 {packages/api-utils => modules}/lib/timer.js | 0 .../api-utils => modules}/lib/traceback.js | 0 {packages/api-utils => modules}/lib/traits.js | 0 .../api-utils => modules}/lib/traits/core.js | 0 .../chromeless-kit => modules}/lib/tray.js | 0 .../chromeless-kit => modules}/lib/ui.js | 0 .../lib/unit-test-finder.js | 0 .../api-utils => modules}/lib/unit-test.js | 0 {packages/api-utils => modules}/lib/unload.js | 0 {packages/api-utils => modules}/lib/url.js | 0 .../api-utils => modules}/lib/utils/data.js | 0 .../lib/utils/function.js | 0 .../lib/utils/registry.js | 0 .../lib/utils/thumbnail.js | 0 .../lib/web-content.js | 0 .../api-utils => modules}/lib/window-utils.js | 0 .../api-utils => modules}/lib/windows/dom.js | 0 .../lib/windows/loader.js | 0 .../api-utils => modules}/lib/windows/tabs.js | 0 {packages/api-utils => modules}/lib/xhr.js | 0 {packages/api-utils => modules}/lib/xpcom.js | 0 .../api-utils => modules}/lib/xul-app.js | 0 packages/addon-kit/README.md | 8 - packages/addon-kit/docs/clipboard.md | 58 - packages/addon-kit/docs/notifications.md | 60 - packages/addon-kit/docs/page-mod.md | 213 --- packages/addon-kit/docs/request.md | 152 -- packages/addon-kit/package.json | 13 - packages/api-utils/README.md | 31 - .../data/bootstrap-remote-process.js | 197 --- .../api-utils/data/test-content-symbiont.js | 0 packages/api-utils/docs/api-utils.md | 153 -- packages/api-utils/docs/app-strings.md | 61 - packages/api-utils/docs/collection.md | 71 - packages/api-utils/docs/content.md | 11 - packages/api-utils/docs/content/loader.md | 79 - packages/api-utils/docs/content/symbiont.md | 110 -- packages/api-utils/docs/content/worker.md | 77 - packages/api-utils/docs/cuddlefish.md | 5 - packages/api-utils/docs/e10s.md | 218 --- packages/api-utils/docs/errors.md | 38 - packages/api-utils/docs/es5.md | 47 - packages/api-utils/docs/events.md | 59 - packages/api-utils/docs/hidden-frame.md | 79 - packages/api-utils/docs/list.md | 94 -- packages/api-utils/docs/match-pattern.md | 77 - packages/api-utils/docs/memory.md | 5 - packages/api-utils/docs/observer-service.md | 70 - packages/api-utils/docs/plain-text-console.md | 8 - .../api-utils/docs/preferences-service.md | 51 - packages/api-utils/docs/securable-module.md | 93 -- packages/api-utils/docs/self.md | 58 - packages/api-utils/docs/tab-browser.md | 136 -- packages/api-utils/docs/text-streams.md | 98 -- packages/api-utils/docs/timer.md | 48 - packages/api-utils/docs/traceback.md | 65 - packages/api-utils/docs/traits.md | 244 --- packages/api-utils/docs/unit-test.md | 161 -- packages/api-utils/docs/unload.md | 55 - packages/api-utils/docs/window-utils.md | 77 - packages/api-utils/docs/xhr.md | 92 -- packages/api-utils/docs/xpcom.md | 3 - packages/api-utils/docs/xul-app.md | 72 - packages/api-utils/package.json | 14 - packages/chromeless-kit/package.json | 6 - packages/chromeless/package.json | 26 - packages/development-mode/README.md | 8 - packages/development-mode/docs/bootstrap.md | 6 - packages/development-mode/docs/main.md | 5 - packages/development-mode/lib/bootstrap.js | 151 -- packages/development-mode/lib/main.js | 93 -- packages/development-mode/package.json | 11 - packages/nsjetpack/README.md | 4 - packages/nsjetpack/components/Makefile.in | 16 - packages/nsjetpack/components/install.rdf | 29 - .../nsjetpack/components/public/Makefile.in | 16 - .../components/public/nsIJetpack.idl | 7 - packages/nsjetpack/components/src/Makefile.in | 43 - .../components/src/jetpackmodule.cpp | 39 - .../components/src/memory_profiler.cpp | 1370 ----------------- .../components/src/memory_profiler.h | 5 - .../src/memory_profiler.mrbkap-review.txt | 72 - .../nsjetpack/components/src/nsJetpack.cpp | 134 -- packages/nsjetpack/components/src/nsJetpack.h | 24 - .../components/src/server_socket.cpp | 303 ---- .../nsjetpack/components/src/server_socket.h | 42 - packages/nsjetpack/components/src/tcb.cpp | 410 ----- packages/nsjetpack/components/src/tcb.h | 74 - packages/nsjetpack/components/src/wrapper.cpp | 463 ------ packages/nsjetpack/components/src/wrapper.h | 48 - packages/nsjetpack/docs/nsjetpack.md | 428 ----- packages/nsjetpack/lib/nsjetpack.js | 18 - .../Darwin_x86-gcc3/1.9.1/libjetpack.dylib | Bin 57116 -> 0 bytes .../Darwin_x86-gcc3/1.9.2/libjetpack.dylib | Bin 54976 -> 0 bytes .../Linux_x86-gcc3/1.9.1/libjetpack.so | Bin 52186 -> 0 bytes .../Linux_x86-gcc3/1.9.2/libjetpack.so | Bin 66145 -> 0 bytes .../Linux_x86_64-gcc3/1.9.1/libjetpack.so | Bin 67188 -> 0 bytes .../Linux_x86_64-gcc3/1.9.2/libjetpack.so | Bin 86228 -> 0 bytes .../platform/WINNT_x86-msvc/1.9.1/jetpack.dll | Bin 80384 -> 0 bytes .../platform/WINNT_x86-msvc/1.9.2/jetpack.dll | Bin 80384 -> 0 bytes packages/nsjetpack/package.json | 17 - .../nsjetpack/tests/test-legacy-nsjetpack.js | 680 -------- packages/nsjetpack/tests/test-nsjetpack.js | 12 - packages/nsjetpack/xpt/jetpack.xpt | Bin 131 -> 0 bytes packages/test-harness/package.json | 9 - 164 files changed, 25 insertions(+), 7968 deletions(-) rename {packages/api-utils/lib => modules/internal}/cuddlefish.js (77%) rename {packages/api-utils/lib => modules/internal}/es5.js (100%) rename {packages/chromeless/lib => modules/internal}/main.js (97%) rename {packages/api-utils/lib => modules/internal}/securable-module.js (100%) rename {packages/api-utils => modules}/lib/api-utils.js (100%) rename {packages/chromeless-kit => modules}/lib/app-paths.js (100%) rename {packages/api-utils => modules}/lib/app-strings.js (100%) rename {packages/chromeless-kit => modules}/lib/appinfo.js (100%) rename {packages/api-utils => modules}/lib/byte-streams.js (100%) rename {packages/chromeless-kit => modules}/lib/canvas-proxy.js (100%) rename {packages/chromeless-kit => modules}/lib/child_process.js (100%) rename {packages/chromeless-kit => modules}/lib/chromeless-sandbox-window.js (100%) rename {packages/addon-kit => modules}/lib/clipboard.js (100%) rename {packages/api-utils => modules}/lib/collection.js (100%) rename {packages/chromeless-kit => modules}/lib/console-service.js (100%) rename {packages/api-utils => modules}/lib/content.js (100%) rename {packages/api-utils => modules}/lib/content/loader.js (100%) rename {packages/api-utils => modules}/lib/content/symbiont.js (100%) rename {packages/api-utils => modules}/lib/content/worker.js (100%) rename {packages/chromeless-kit => modules}/lib/cookie.js (100%) rename {packages/api-utils => modules}/lib/cortex.js (100%) rename {packages/chromeless-kit => modules}/lib/custom-protocol.js (100%) rename {packages/chromeless-kit => modules}/lib/dictionary.js (100%) rename {packages/chromeless-kit => modules}/lib/dragdrop.js (100%) rename {packages/api-utils => modules}/lib/e10s.js (100%) rename {packages/api-utils => modules}/lib/errors.js (100%) rename {packages/api-utils => modules}/lib/events.js (100%) rename {packages/chromeless-kit => modules}/lib/favicon.js (100%) rename {packages/chromeless-kit => modules}/lib/file-picker.js (100%) rename {packages/api-utils => modules}/lib/file.js (100%) rename {packages/api-utils => modules}/lib/find-tests-e10s-adapter.js (100%) rename {packages/api-utils => modules}/lib/find-tests.js (100%) rename {packages/chromeless-kit => modules}/lib/fs.js (100%) rename {packages/chromeless-kit => modules}/lib/fullscreen.js (100%) rename {packages/chromeless-kit => modules}/lib/hidden-frame-xulrunner.js (100%) rename {packages/api-utils => modules}/lib/hidden-frame.js (100%) rename {packages/chromeless-kit => modules}/lib/hotkey.js (100%) rename {packages/api-utils => modules}/lib/light-traits.js (100%) rename {packages/api-utils => modules}/lib/list.js (100%) rename {packages/api-utils => modules}/lib/match-pattern.js (100%) rename {packages/api-utils => modules}/lib/memory.js (100%) rename {packages/chromeless-kit => modules}/lib/menu.js (100%) rename {packages/chromeless-kit => modules}/lib/mime.js (100%) rename {packages/chromeless-kit => modules}/lib/net.js (100%) rename {packages/addon-kit => modules}/lib/notifications.js (100%) rename {packages/api-utils => modules}/lib/observer-service.js (100%) rename {packages/chromeless-kit => modules}/lib/path.js (100%) rename {packages/api-utils => modules}/lib/plain-text-console.js (100%) rename {packages/api-utils => modules}/lib/preferences-service.js (100%) rename {packages/chromeless-kit => modules}/lib/process.js (100%) rename {packages/chromeless-kit => modules}/lib/pure_js_events.js (100%) rename {packages/addon-kit => modules}/lib/request.js (100%) rename {packages/api-utils => modules}/lib/self-e10s-adapter.js (100%) rename {packages/api-utils => modules}/lib/self.js (100%) rename {packages/chromeless-kit => modules}/lib/simple-feature.js (100%) rename {packages/api-utils => modules}/lib/text-streams.js (100%) rename {packages/api-utils => modules}/lib/timer-e10s-adapter.js (100%) rename {packages/api-utils => modules}/lib/timer.js (100%) rename {packages/api-utils => modules}/lib/traceback.js (100%) rename {packages/api-utils => modules}/lib/traits.js (100%) rename {packages/api-utils => modules}/lib/traits/core.js (100%) rename {packages/chromeless-kit => modules}/lib/tray.js (100%) rename {packages/chromeless-kit => modules}/lib/ui.js (100%) rename {packages/api-utils => modules}/lib/unit-test-finder.js (100%) rename {packages/api-utils => modules}/lib/unit-test.js (100%) rename {packages/api-utils => modules}/lib/unload.js (100%) rename {packages/api-utils => modules}/lib/url.js (100%) rename {packages/api-utils => modules}/lib/utils/data.js (100%) rename {packages/api-utils => modules}/lib/utils/function.js (100%) rename {packages/api-utils => modules}/lib/utils/registry.js (100%) rename {packages/api-utils => modules}/lib/utils/thumbnail.js (100%) rename {packages/chromeless-kit => modules}/lib/web-content.js (100%) rename {packages/api-utils => modules}/lib/window-utils.js (100%) rename {packages/api-utils => modules}/lib/windows/dom.js (100%) rename {packages/api-utils => modules}/lib/windows/loader.js (100%) rename {packages/api-utils => modules}/lib/windows/tabs.js (100%) rename {packages/api-utils => modules}/lib/xhr.js (100%) rename {packages/api-utils => modules}/lib/xpcom.js (100%) rename {packages/api-utils => modules}/lib/xul-app.js (100%) delete mode 100644 packages/addon-kit/README.md delete mode 100644 packages/addon-kit/docs/clipboard.md delete mode 100644 packages/addon-kit/docs/notifications.md delete mode 100644 packages/addon-kit/docs/page-mod.md delete mode 100644 packages/addon-kit/docs/request.md delete mode 100644 packages/addon-kit/package.json delete mode 100644 packages/api-utils/README.md delete mode 100644 packages/api-utils/data/bootstrap-remote-process.js delete mode 100644 packages/api-utils/data/test-content-symbiont.js delete mode 100644 packages/api-utils/docs/api-utils.md delete mode 100644 packages/api-utils/docs/app-strings.md delete mode 100644 packages/api-utils/docs/collection.md delete mode 100644 packages/api-utils/docs/content.md delete mode 100644 packages/api-utils/docs/content/loader.md delete mode 100644 packages/api-utils/docs/content/symbiont.md delete mode 100644 packages/api-utils/docs/content/worker.md delete mode 100644 packages/api-utils/docs/cuddlefish.md delete mode 100644 packages/api-utils/docs/e10s.md delete mode 100644 packages/api-utils/docs/errors.md delete mode 100644 packages/api-utils/docs/es5.md delete mode 100644 packages/api-utils/docs/events.md delete mode 100644 packages/api-utils/docs/hidden-frame.md delete mode 100644 packages/api-utils/docs/list.md delete mode 100644 packages/api-utils/docs/match-pattern.md delete mode 100644 packages/api-utils/docs/memory.md delete mode 100644 packages/api-utils/docs/observer-service.md delete mode 100644 packages/api-utils/docs/plain-text-console.md delete mode 100644 packages/api-utils/docs/preferences-service.md delete mode 100644 packages/api-utils/docs/securable-module.md delete mode 100644 packages/api-utils/docs/self.md delete mode 100644 packages/api-utils/docs/tab-browser.md delete mode 100644 packages/api-utils/docs/text-streams.md delete mode 100644 packages/api-utils/docs/timer.md delete mode 100644 packages/api-utils/docs/traceback.md delete mode 100644 packages/api-utils/docs/traits.md delete mode 100644 packages/api-utils/docs/unit-test.md delete mode 100644 packages/api-utils/docs/unload.md delete mode 100644 packages/api-utils/docs/window-utils.md delete mode 100644 packages/api-utils/docs/xhr.md delete mode 100644 packages/api-utils/docs/xpcom.md delete mode 100644 packages/api-utils/docs/xul-app.md delete mode 100644 packages/api-utils/package.json delete mode 100644 packages/chromeless-kit/package.json delete mode 100644 packages/chromeless/package.json delete mode 100644 packages/development-mode/README.md delete mode 100644 packages/development-mode/docs/bootstrap.md delete mode 100644 packages/development-mode/docs/main.md delete mode 100644 packages/development-mode/lib/bootstrap.js delete mode 100644 packages/development-mode/lib/main.js delete mode 100644 packages/development-mode/package.json delete mode 100644 packages/nsjetpack/README.md delete mode 100644 packages/nsjetpack/components/Makefile.in delete mode 100644 packages/nsjetpack/components/install.rdf delete mode 100644 packages/nsjetpack/components/public/Makefile.in delete mode 100644 packages/nsjetpack/components/public/nsIJetpack.idl delete mode 100644 packages/nsjetpack/components/src/Makefile.in delete mode 100644 packages/nsjetpack/components/src/jetpackmodule.cpp delete mode 100644 packages/nsjetpack/components/src/memory_profiler.cpp delete mode 100644 packages/nsjetpack/components/src/memory_profiler.h delete mode 100644 packages/nsjetpack/components/src/memory_profiler.mrbkap-review.txt delete mode 100644 packages/nsjetpack/components/src/nsJetpack.cpp delete mode 100644 packages/nsjetpack/components/src/nsJetpack.h delete mode 100644 packages/nsjetpack/components/src/server_socket.cpp delete mode 100644 packages/nsjetpack/components/src/server_socket.h delete mode 100644 packages/nsjetpack/components/src/tcb.cpp delete mode 100644 packages/nsjetpack/components/src/tcb.h delete mode 100644 packages/nsjetpack/components/src/wrapper.cpp delete mode 100644 packages/nsjetpack/components/src/wrapper.h delete mode 100644 packages/nsjetpack/docs/nsjetpack.md delete mode 100644 packages/nsjetpack/lib/nsjetpack.js delete mode 100755 packages/nsjetpack/lib/platform/Darwin_x86-gcc3/1.9.1/libjetpack.dylib delete mode 100755 packages/nsjetpack/lib/platform/Darwin_x86-gcc3/1.9.2/libjetpack.dylib delete mode 100755 packages/nsjetpack/lib/platform/Linux_x86-gcc3/1.9.1/libjetpack.so delete mode 100755 packages/nsjetpack/lib/platform/Linux_x86-gcc3/1.9.2/libjetpack.so delete mode 100755 packages/nsjetpack/lib/platform/Linux_x86_64-gcc3/1.9.1/libjetpack.so delete mode 100755 packages/nsjetpack/lib/platform/Linux_x86_64-gcc3/1.9.2/libjetpack.so delete mode 100644 packages/nsjetpack/lib/platform/WINNT_x86-msvc/1.9.1/jetpack.dll delete mode 100644 packages/nsjetpack/lib/platform/WINNT_x86-msvc/1.9.2/jetpack.dll delete mode 100644 packages/nsjetpack/package.json delete mode 100644 packages/nsjetpack/tests/test-legacy-nsjetpack.js delete mode 100644 packages/nsjetpack/tests/test-nsjetpack.js delete mode 100644 packages/nsjetpack/xpt/jetpack.xpt delete mode 100644 packages/test-harness/package.json diff --git a/impl/appifier/resources/xulrunner.template/components/harness.js b/impl/appifier/resources/xulrunner.template/components/harness.js index 46d9abd7..5e6aa3db 100644 --- a/impl/appifier/resources/xulrunner.template/components/harness.js +++ b/impl/appifier/resources/xulrunner.template/components/harness.js @@ -160,11 +160,6 @@ function buildHarnessService(rootFileSpec, dump, logError, } function buildLoader() { - // TODO: This variable doesn't seem to be used, we should - // be able to remove it. - var compMgr = Components.manager; - compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar); - for (name in options.resources) { var path = options.resources[name]; var dir; @@ -236,7 +231,7 @@ function buildHarnessService(rootFileSpec, dump, logError, }; if (info.packageName in options.packageData) info.packageData = options.packageData[info.packageName]; - + return info; /* @@ -540,7 +535,7 @@ function getDefaults(rootFileSpec) { } options = JSON.parse(jsonData); - + if ("staticArgs" in options) { dirbase = rootFileSpec.clone(); options.staticArgs.appBasePath=dirbase.path; diff --git a/impl/cuddlefish/__init__.py b/impl/cuddlefish/__init__.py index 4ff77261..3fa2cffb 100644 --- a/impl/cuddlefish/__init__.py +++ b/impl/cuddlefish/__init__.py @@ -8,6 +8,7 @@ import subprocess import signal import tempfile +import chromeless from copy import copy import simplejson as json @@ -399,27 +400,6 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, print "Created docs in %s." % dirname return - target_cfg_json = None - if not target_cfg: - if not options.pkgdir: - options.pkgdir = find_parent_package(os.getcwd()) - if not options.pkgdir: - print >>sys.stderr, ("cannot find 'package.json' in the" - " current directory or any parent.") - sys.exit(1) - else: - options.pkgdir = os.path.abspath(options.pkgdir) - if not os.path.exists(os.path.join(options.pkgdir, 'package.json')): - print >>sys.stderr, ("cannot find 'package.json' in" - " %s." % options.pkgdir) - sys.exit(1) - - target_cfg_json = os.path.join(options.pkgdir, 'package.json') - target_cfg = packaging.get_config_in_dir(options.pkgdir) - - # At this point, we're either building an XPI or running Jetpack code in - # a Mozilla application (which includes running tests). - use_main = False timeout = None inherited_options = ['verbose', 'enable_e10s'] @@ -436,49 +416,13 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, print >>sys.stderr, "Try using '--help' for assistance." sys.exit(1) - if use_main and 'main' not in target_cfg: - print >>sys.stderr, "package.json does not have a 'main' entry." - sys.exit(1) - - print "MAIN: " + target_cfg['main'] - - if not pkg_cfg: - pkg_cfg = packaging.build_config(env_root, target_cfg) - - target = target_cfg.name + target = "main" # the harness_guid is used for an XPCOM class ID. import uuid harness_guid = str(uuid.uuid4()) print("harness_guid: %s" % harness_guid); - - # TODO: Consider keeping a cache of dynamic UUIDs, based - # on absolute filesystem pathname, in the root directory - # or something. - if command in ('package', 'run', 'appify'): - from cuddlefish.preflight import preflight_config - if target_cfg_json: - config_was_ok, modified = preflight_config( - target_cfg, - target_cfg_json, - keydir=options.keydir, - err_if_privkey_not_found=False - ) - if not config_was_ok: - if modified: - # we need to re-read package.json . The safest approach - # is to re-run the "cfx xpi"/"cfx run" command. - print >>sys.stderr, ("package.json modified: please re-run" - " 'cfx %s'" % command) - else: - print >>sys.stderr, ("package.json needs modification:" - " please update it and then re-run" - " 'cfx %s'" % command) - sys.exit(1) - # if we make it this far, we have a JID - else: - assert command == "test" unique_prefix = '%s-' % target @@ -494,17 +438,14 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, if options.extra_packages: targets.extend(options.extra_packages.split(",")) - deps = packaging.get_deps_for_targets(pkg_cfg, targets) - build = packaging.generate_build_for_target( - pkg_cfg, target, deps, - prefix=unique_prefix, # used to create resource: URLs - include_dep_tests=options.dep_tests - ) - - if 'resources' in build: - resources = build.resources - for name in resources: - resources[name] = os.path.abspath(resources[name]) + resources = { } + rootPaths = [ ] + import chromeless + path_to_modules = os.path.join(chromeless.Dirs().cuddlefish_root, "modules") + for f in os.listdir(path_to_modules): + resourceName = harness_guid + "-" + f + resources[harness_guid + "-" + f] = os.path.join(path_to_modules, f) + rootPaths.append("resource://" + resourceName + "/"); harness_contract_id = ('@mozilla.org/harness-service;1?id=%s' % harness_guid) harness_options = { @@ -515,20 +456,19 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, 'jetpackID': harness_guid, 'bundleID': harness_guid, 'staticArgs': options.static_args, + 'resources': resources, + 'loader': "resource://%s-%s/%s" % (harness_guid, "internal", "cuddlefish.js"), + 'rootPaths': rootPaths } - harness_options.update(build) - if command == "test": # This should be contained in the test runner package. harness_options['main'] = 'run-tests' else: harness_options['main'] = 'main' - for option in inherited_options: - harness_options[option] = getattr(options, option) - - harness_options['metadata'] = packaging.get_metadata(pkg_cfg, deps) +# for option in inherited_options: +# harness_options[option] = getattr(options, option) retval = 0 @@ -545,7 +485,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None, harness_options=harness_options, dev_mode=False) - else: + else: browser_code_path = options.static_args["browser"] if options.profiledir: diff --git a/packages/api-utils/lib/cuddlefish.js b/modules/internal/cuddlefish.js similarity index 77% rename from packages/api-utils/lib/cuddlefish.js rename to modules/internal/cuddlefish.js index da99ca66..d3765bfb 100644 --- a/packages/api-utils/lib/cuddlefish.js +++ b/modules/internal/cuddlefish.js @@ -46,10 +46,10 @@ var securableModule; var myURI = Components.stack.filename.split(" -> ").slice(-1)[0]; - if (global.require) + if (global.require) { // We're being loaded in a SecurableModule. securableModule = require("securable-module"); - else { + } else { var ios = Cc['@mozilla.org/network/io-service;1'] .getService(Ci.nsIIOService); var securableModuleURI = ios.newURI("securable-module.js", null, @@ -135,44 +135,6 @@ function makeManifestChecker(packaging) { var mc = { _allow: function _allow(loader, basePath, module, module_info) { - if (!basePath) { - return true; /* top-level import */ - } - let mi = packaging.getModuleInfo(basePath); - if (mi.needsChrome) - /* The module requires chrome, it can import whatever it - * wants. */ - return true; - if (!mi.dependencies) { - /* the parent isn't in the manifest: we know nothing about it */ - } else { - if (mi.dependencies[module]) { - /* they're on the list: the require() is allowed, but let's - check that they're loading the right thing */ - let parent_mi = packaging.getModuleInfo(basePath); - // parent_mi is the parent, who invoked require() - // module_info is the child, the output of resolveModule - var should_load = parent_mi.dependencies[module].url; - var is_loading = module_info.filename; - if (!should_load) { - /* the linker wasn't able to find the target module when the - XPI was constructed. */ - loader.console.warn("require("+ module +") (called from " + - basePath + ") is loading " + is_loading + - ", but the manifest couldn't find it"); - } else if (should_load != is_loading) { - loader.console.warn("require(" + module + ") (called from " + - basePath + ") is loading " + is_loading + - ", but is supposed to be loading " + - should_load); - //return false; // enable this in 0.9 - } - return true; - } - } - loader.console.warn("undeclared require(" + module + - ") called from " + basePath); - //return false; // enable this in 0.9 return true; }, allowEval: function allowEval(loader, basePath, module, module_info) { @@ -181,16 +143,6 @@ allowImport: function allowImport(loader, basePath, module, module_info, exports) { - if (module == "chrome") { - let parent_mi = packaging.getModuleInfo(basePath); - if (parent_mi.needsChrome) - return true; /* chrome is on the list, allow it */ - loader.console.warn("undeclared require(chrome) called from " + - basePath); - //return false; // enable this in 0.9 - return true; - } - return this._allow(loader, basePath, module, module_info); } }; diff --git a/packages/api-utils/lib/es5.js b/modules/internal/es5.js similarity index 100% rename from packages/api-utils/lib/es5.js rename to modules/internal/es5.js diff --git a/packages/chromeless/lib/main.js b/modules/internal/main.js similarity index 97% rename from packages/chromeless/lib/main.js rename to modules/internal/main.js index aa45c7da..23647d8e 100644 --- a/packages/chromeless/lib/main.js +++ b/modules/internal/main.js @@ -45,21 +45,21 @@ const {Ci, Cc, Cr, Cu} = require("chrome"); const path = require('path'); const appinfo = require('appinfo'); -var appWindow = null; +var appWindow = null; -// These functions are used from the test application. +// These functions are used from the test application. /* exports.getAppWindow = function () { return appWindow; } */ -exports.__defineGetter__('getAppWindow', function () { - return appWindow; +exports.__defineGetter__('getAppWindow', function () { + return appWindow; } ); exports.getAppBrowser = function () { return appWindow._browser; -} +} function testFunction(html) { return html.replace("World", "Hello"); diff --git a/packages/api-utils/lib/securable-module.js b/modules/internal/securable-module.js similarity index 100% rename from packages/api-utils/lib/securable-module.js rename to modules/internal/securable-module.js diff --git a/packages/api-utils/lib/api-utils.js b/modules/lib/api-utils.js similarity index 100% rename from packages/api-utils/lib/api-utils.js rename to modules/lib/api-utils.js diff --git a/packages/chromeless-kit/lib/app-paths.js b/modules/lib/app-paths.js similarity index 100% rename from packages/chromeless-kit/lib/app-paths.js rename to modules/lib/app-paths.js diff --git a/packages/api-utils/lib/app-strings.js b/modules/lib/app-strings.js similarity index 100% rename from packages/api-utils/lib/app-strings.js rename to modules/lib/app-strings.js diff --git a/packages/chromeless-kit/lib/appinfo.js b/modules/lib/appinfo.js similarity index 100% rename from packages/chromeless-kit/lib/appinfo.js rename to modules/lib/appinfo.js diff --git a/packages/api-utils/lib/byte-streams.js b/modules/lib/byte-streams.js similarity index 100% rename from packages/api-utils/lib/byte-streams.js rename to modules/lib/byte-streams.js diff --git a/packages/chromeless-kit/lib/canvas-proxy.js b/modules/lib/canvas-proxy.js similarity index 100% rename from packages/chromeless-kit/lib/canvas-proxy.js rename to modules/lib/canvas-proxy.js diff --git a/packages/chromeless-kit/lib/child_process.js b/modules/lib/child_process.js similarity index 100% rename from packages/chromeless-kit/lib/child_process.js rename to modules/lib/child_process.js diff --git a/packages/chromeless-kit/lib/chromeless-sandbox-window.js b/modules/lib/chromeless-sandbox-window.js similarity index 100% rename from packages/chromeless-kit/lib/chromeless-sandbox-window.js rename to modules/lib/chromeless-sandbox-window.js diff --git a/packages/addon-kit/lib/clipboard.js b/modules/lib/clipboard.js similarity index 100% rename from packages/addon-kit/lib/clipboard.js rename to modules/lib/clipboard.js diff --git a/packages/api-utils/lib/collection.js b/modules/lib/collection.js similarity index 100% rename from packages/api-utils/lib/collection.js rename to modules/lib/collection.js diff --git a/packages/chromeless-kit/lib/console-service.js b/modules/lib/console-service.js similarity index 100% rename from packages/chromeless-kit/lib/console-service.js rename to modules/lib/console-service.js diff --git a/packages/api-utils/lib/content.js b/modules/lib/content.js similarity index 100% rename from packages/api-utils/lib/content.js rename to modules/lib/content.js diff --git a/packages/api-utils/lib/content/loader.js b/modules/lib/content/loader.js similarity index 100% rename from packages/api-utils/lib/content/loader.js rename to modules/lib/content/loader.js diff --git a/packages/api-utils/lib/content/symbiont.js b/modules/lib/content/symbiont.js similarity index 100% rename from packages/api-utils/lib/content/symbiont.js rename to modules/lib/content/symbiont.js diff --git a/packages/api-utils/lib/content/worker.js b/modules/lib/content/worker.js similarity index 100% rename from packages/api-utils/lib/content/worker.js rename to modules/lib/content/worker.js diff --git a/packages/chromeless-kit/lib/cookie.js b/modules/lib/cookie.js similarity index 100% rename from packages/chromeless-kit/lib/cookie.js rename to modules/lib/cookie.js diff --git a/packages/api-utils/lib/cortex.js b/modules/lib/cortex.js similarity index 100% rename from packages/api-utils/lib/cortex.js rename to modules/lib/cortex.js diff --git a/packages/chromeless-kit/lib/custom-protocol.js b/modules/lib/custom-protocol.js similarity index 100% rename from packages/chromeless-kit/lib/custom-protocol.js rename to modules/lib/custom-protocol.js diff --git a/packages/chromeless-kit/lib/dictionary.js b/modules/lib/dictionary.js similarity index 100% rename from packages/chromeless-kit/lib/dictionary.js rename to modules/lib/dictionary.js diff --git a/packages/chromeless-kit/lib/dragdrop.js b/modules/lib/dragdrop.js similarity index 100% rename from packages/chromeless-kit/lib/dragdrop.js rename to modules/lib/dragdrop.js diff --git a/packages/api-utils/lib/e10s.js b/modules/lib/e10s.js similarity index 100% rename from packages/api-utils/lib/e10s.js rename to modules/lib/e10s.js diff --git a/packages/api-utils/lib/errors.js b/modules/lib/errors.js similarity index 100% rename from packages/api-utils/lib/errors.js rename to modules/lib/errors.js diff --git a/packages/api-utils/lib/events.js b/modules/lib/events.js similarity index 100% rename from packages/api-utils/lib/events.js rename to modules/lib/events.js diff --git a/packages/chromeless-kit/lib/favicon.js b/modules/lib/favicon.js similarity index 100% rename from packages/chromeless-kit/lib/favicon.js rename to modules/lib/favicon.js diff --git a/packages/chromeless-kit/lib/file-picker.js b/modules/lib/file-picker.js similarity index 100% rename from packages/chromeless-kit/lib/file-picker.js rename to modules/lib/file-picker.js diff --git a/packages/api-utils/lib/file.js b/modules/lib/file.js similarity index 100% rename from packages/api-utils/lib/file.js rename to modules/lib/file.js diff --git a/packages/api-utils/lib/find-tests-e10s-adapter.js b/modules/lib/find-tests-e10s-adapter.js similarity index 100% rename from packages/api-utils/lib/find-tests-e10s-adapter.js rename to modules/lib/find-tests-e10s-adapter.js diff --git a/packages/api-utils/lib/find-tests.js b/modules/lib/find-tests.js similarity index 100% rename from packages/api-utils/lib/find-tests.js rename to modules/lib/find-tests.js diff --git a/packages/chromeless-kit/lib/fs.js b/modules/lib/fs.js similarity index 100% rename from packages/chromeless-kit/lib/fs.js rename to modules/lib/fs.js diff --git a/packages/chromeless-kit/lib/fullscreen.js b/modules/lib/fullscreen.js similarity index 100% rename from packages/chromeless-kit/lib/fullscreen.js rename to modules/lib/fullscreen.js diff --git a/packages/chromeless-kit/lib/hidden-frame-xulrunner.js b/modules/lib/hidden-frame-xulrunner.js similarity index 100% rename from packages/chromeless-kit/lib/hidden-frame-xulrunner.js rename to modules/lib/hidden-frame-xulrunner.js diff --git a/packages/api-utils/lib/hidden-frame.js b/modules/lib/hidden-frame.js similarity index 100% rename from packages/api-utils/lib/hidden-frame.js rename to modules/lib/hidden-frame.js diff --git a/packages/chromeless-kit/lib/hotkey.js b/modules/lib/hotkey.js similarity index 100% rename from packages/chromeless-kit/lib/hotkey.js rename to modules/lib/hotkey.js diff --git a/packages/api-utils/lib/light-traits.js b/modules/lib/light-traits.js similarity index 100% rename from packages/api-utils/lib/light-traits.js rename to modules/lib/light-traits.js diff --git a/packages/api-utils/lib/list.js b/modules/lib/list.js similarity index 100% rename from packages/api-utils/lib/list.js rename to modules/lib/list.js diff --git a/packages/api-utils/lib/match-pattern.js b/modules/lib/match-pattern.js similarity index 100% rename from packages/api-utils/lib/match-pattern.js rename to modules/lib/match-pattern.js diff --git a/packages/api-utils/lib/memory.js b/modules/lib/memory.js similarity index 100% rename from packages/api-utils/lib/memory.js rename to modules/lib/memory.js diff --git a/packages/chromeless-kit/lib/menu.js b/modules/lib/menu.js similarity index 100% rename from packages/chromeless-kit/lib/menu.js rename to modules/lib/menu.js diff --git a/packages/chromeless-kit/lib/mime.js b/modules/lib/mime.js similarity index 100% rename from packages/chromeless-kit/lib/mime.js rename to modules/lib/mime.js diff --git a/packages/chromeless-kit/lib/net.js b/modules/lib/net.js similarity index 100% rename from packages/chromeless-kit/lib/net.js rename to modules/lib/net.js diff --git a/packages/addon-kit/lib/notifications.js b/modules/lib/notifications.js similarity index 100% rename from packages/addon-kit/lib/notifications.js rename to modules/lib/notifications.js diff --git a/packages/api-utils/lib/observer-service.js b/modules/lib/observer-service.js similarity index 100% rename from packages/api-utils/lib/observer-service.js rename to modules/lib/observer-service.js diff --git a/packages/chromeless-kit/lib/path.js b/modules/lib/path.js similarity index 100% rename from packages/chromeless-kit/lib/path.js rename to modules/lib/path.js diff --git a/packages/api-utils/lib/plain-text-console.js b/modules/lib/plain-text-console.js similarity index 100% rename from packages/api-utils/lib/plain-text-console.js rename to modules/lib/plain-text-console.js diff --git a/packages/api-utils/lib/preferences-service.js b/modules/lib/preferences-service.js similarity index 100% rename from packages/api-utils/lib/preferences-service.js rename to modules/lib/preferences-service.js diff --git a/packages/chromeless-kit/lib/process.js b/modules/lib/process.js similarity index 100% rename from packages/chromeless-kit/lib/process.js rename to modules/lib/process.js diff --git a/packages/chromeless-kit/lib/pure_js_events.js b/modules/lib/pure_js_events.js similarity index 100% rename from packages/chromeless-kit/lib/pure_js_events.js rename to modules/lib/pure_js_events.js diff --git a/packages/addon-kit/lib/request.js b/modules/lib/request.js similarity index 100% rename from packages/addon-kit/lib/request.js rename to modules/lib/request.js diff --git a/packages/api-utils/lib/self-e10s-adapter.js b/modules/lib/self-e10s-adapter.js similarity index 100% rename from packages/api-utils/lib/self-e10s-adapter.js rename to modules/lib/self-e10s-adapter.js diff --git a/packages/api-utils/lib/self.js b/modules/lib/self.js similarity index 100% rename from packages/api-utils/lib/self.js rename to modules/lib/self.js diff --git a/packages/chromeless-kit/lib/simple-feature.js b/modules/lib/simple-feature.js similarity index 100% rename from packages/chromeless-kit/lib/simple-feature.js rename to modules/lib/simple-feature.js diff --git a/packages/api-utils/lib/text-streams.js b/modules/lib/text-streams.js similarity index 100% rename from packages/api-utils/lib/text-streams.js rename to modules/lib/text-streams.js diff --git a/packages/api-utils/lib/timer-e10s-adapter.js b/modules/lib/timer-e10s-adapter.js similarity index 100% rename from packages/api-utils/lib/timer-e10s-adapter.js rename to modules/lib/timer-e10s-adapter.js diff --git a/packages/api-utils/lib/timer.js b/modules/lib/timer.js similarity index 100% rename from packages/api-utils/lib/timer.js rename to modules/lib/timer.js diff --git a/packages/api-utils/lib/traceback.js b/modules/lib/traceback.js similarity index 100% rename from packages/api-utils/lib/traceback.js rename to modules/lib/traceback.js diff --git a/packages/api-utils/lib/traits.js b/modules/lib/traits.js similarity index 100% rename from packages/api-utils/lib/traits.js rename to modules/lib/traits.js diff --git a/packages/api-utils/lib/traits/core.js b/modules/lib/traits/core.js similarity index 100% rename from packages/api-utils/lib/traits/core.js rename to modules/lib/traits/core.js diff --git a/packages/chromeless-kit/lib/tray.js b/modules/lib/tray.js similarity index 100% rename from packages/chromeless-kit/lib/tray.js rename to modules/lib/tray.js diff --git a/packages/chromeless-kit/lib/ui.js b/modules/lib/ui.js similarity index 100% rename from packages/chromeless-kit/lib/ui.js rename to modules/lib/ui.js diff --git a/packages/api-utils/lib/unit-test-finder.js b/modules/lib/unit-test-finder.js similarity index 100% rename from packages/api-utils/lib/unit-test-finder.js rename to modules/lib/unit-test-finder.js diff --git a/packages/api-utils/lib/unit-test.js b/modules/lib/unit-test.js similarity index 100% rename from packages/api-utils/lib/unit-test.js rename to modules/lib/unit-test.js diff --git a/packages/api-utils/lib/unload.js b/modules/lib/unload.js similarity index 100% rename from packages/api-utils/lib/unload.js rename to modules/lib/unload.js diff --git a/packages/api-utils/lib/url.js b/modules/lib/url.js similarity index 100% rename from packages/api-utils/lib/url.js rename to modules/lib/url.js diff --git a/packages/api-utils/lib/utils/data.js b/modules/lib/utils/data.js similarity index 100% rename from packages/api-utils/lib/utils/data.js rename to modules/lib/utils/data.js diff --git a/packages/api-utils/lib/utils/function.js b/modules/lib/utils/function.js similarity index 100% rename from packages/api-utils/lib/utils/function.js rename to modules/lib/utils/function.js diff --git a/packages/api-utils/lib/utils/registry.js b/modules/lib/utils/registry.js similarity index 100% rename from packages/api-utils/lib/utils/registry.js rename to modules/lib/utils/registry.js diff --git a/packages/api-utils/lib/utils/thumbnail.js b/modules/lib/utils/thumbnail.js similarity index 100% rename from packages/api-utils/lib/utils/thumbnail.js rename to modules/lib/utils/thumbnail.js diff --git a/packages/chromeless-kit/lib/web-content.js b/modules/lib/web-content.js similarity index 100% rename from packages/chromeless-kit/lib/web-content.js rename to modules/lib/web-content.js diff --git a/packages/api-utils/lib/window-utils.js b/modules/lib/window-utils.js similarity index 100% rename from packages/api-utils/lib/window-utils.js rename to modules/lib/window-utils.js diff --git a/packages/api-utils/lib/windows/dom.js b/modules/lib/windows/dom.js similarity index 100% rename from packages/api-utils/lib/windows/dom.js rename to modules/lib/windows/dom.js diff --git a/packages/api-utils/lib/windows/loader.js b/modules/lib/windows/loader.js similarity index 100% rename from packages/api-utils/lib/windows/loader.js rename to modules/lib/windows/loader.js diff --git a/packages/api-utils/lib/windows/tabs.js b/modules/lib/windows/tabs.js similarity index 100% rename from packages/api-utils/lib/windows/tabs.js rename to modules/lib/windows/tabs.js diff --git a/packages/api-utils/lib/xhr.js b/modules/lib/xhr.js similarity index 100% rename from packages/api-utils/lib/xhr.js rename to modules/lib/xhr.js diff --git a/packages/api-utils/lib/xpcom.js b/modules/lib/xpcom.js similarity index 100% rename from packages/api-utils/lib/xpcom.js rename to modules/lib/xpcom.js diff --git a/packages/api-utils/lib/xul-app.js b/modules/lib/xul-app.js similarity index 100% rename from packages/api-utils/lib/xul-app.js rename to modules/lib/xul-app.js diff --git a/packages/addon-kit/README.md b/packages/addon-kit/README.md deleted file mode 100644 index 9a685542..00000000 --- a/packages/addon-kit/README.md +++ /dev/null @@ -1,8 +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/docs/clipboard.md b/packages/addon-kit/docs/clipboard.md deleted file mode 100644 index 7292017e..00000000 --- a/packages/addon-kit/docs/clipboard.md +++ /dev/null @@ -1,58 +0,0 @@ - - -The `clipboard` module allows callers to interact with the system clipboard, -setting and retrieving its contents. - -You can optionally specify the type of the data to set and retrieve. -The following types are supported: - -* `text` (plain text) -* `html` (a string of HTML) - -If no data type is provided, then the module will detect it for you. - -Examples --------- - -Set and get the contents of the clipboard. - - let clipboard = require("clipboard"); - clipboard.set("Lorem ipsum dolor sit amet"); - let contents = clipboard.get(); - -Set the clipboard contents to some HTML. - - let clipboard = require("clipboard"); - clipboard.set("Lorem ipsum dolor sit amet", "html"); - -If the clipboard contains HTML content, open it in a new tab. - - let clipboard = require("clipboard"); - if (clipboard.currentFlavors.indexOf("html") != -1) - require("tabs").open("data:text/html," + clipboard.get("html")); - - -@function - Replace the contents of the user's clipboard with the provided data. -@param data {string} - The data to put on the clipboard. -@param [datatype] {string} - The type of the data (optional). - - - -@function - Get the contents of the user's clipboard. -@param [datatype] {string} - Retrieve the clipboard contents only if matching this type (optional). - The function will return null if the contents of the clipboard do not match - the supplied type. - - - -@property {array} - Data on the clipboard is sometimes available in multiple types. For example, - HTML data might be available as both a string of HTML (the `html` type) - and a string of plain text (the `text` type). This function returns an array - of all types in which the data currently on the clipboard is available. - diff --git a/packages/addon-kit/docs/notifications.md b/packages/addon-kit/docs/notifications.md deleted file mode 100644 index 81cab646..00000000 --- a/packages/addon-kit/docs/notifications.md +++ /dev/null @@ -1,60 +0,0 @@ - - -The `notifications` module allows you to display transient, -[toaster](http://en.wikipedia.org/wiki/Toast_%28computing%29)-style -desktop messages to the user. - -This API supports desktop notifications on Windows, OS X using -[Growl](http://growl.info/), and Linux using libnotify. If the user's system -does not support desktop notifications or if its notifications service is not -running, then notifications made with this API are logged to Firefox's error -console and, if the user launched Firefox from the command line, the terminal. - -Examples --------- - -Here's a typical example. When the message is clicked, a string is logged to -the console. - - var notifications = require("notifications"); - notifications.notify({ - title: "Jabberwocky", - text: "'Twas brillig, and the slithy toves", - data: "did gyre and gimble in the wabe", - onClick: function (data) { - console.log(data); - // console.log(this.data) would produce the same result. - } - }); - -This one displays an icon that's stored in the add-on's `data` directory. (See -the [`self`](#module/api-utils/self) module documentation for more information.) - - var notifications = require("notifications"); - var self = require("self"); - var myIconURL = self.data.url("myIcon.png"); - notifications.notify({ - text: "I have an icon!", - iconURL: myIconURL - }); - - - -@function - Displays a transient notification to the user. -@param options {object} - An object with the following keys. Each is optional. - @prop [title] {string} - A string to display as the message's title. - @prop [text] {string} - 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`](#module/api-utils/self) - module. - @prop [onClick] {function} - A function to be called when the user clicks the message. It will be passed - the value of `data`. - @prop [data] {string} - A string that will be passed to `onClick`. - diff --git a/packages/addon-kit/docs/page-mod.md b/packages/addon-kit/docs/page-mod.md deleted file mode 100644 index c9606438..00000000 --- a/packages/addon-kit/docs/page-mod.md +++ /dev/null @@ -1,213 +0,0 @@ - - - - -Overview --------- -The page-mod module enables add-on developers to execute scripts in the context -of specific web pages. Most obviously you could use page-mod to dynamically -modify the content of certain pages. - -The module exports a constructor function `PageMod` which creates a new page -modification (or "mod" for short). - -A page mod does not modify its pages until those pages are loaded or reloaded. -In other words, if your add-on is loaded while the user's browser is open, the -user will have to reload any open pages that match the mod for the mod to affect -them. - -To stop a page mod from making any more modifications, call its `destroy` -method. - -Like all modules that interact with web content, page-mod uses content -scripts that execute in the content process and defines a messaging API to -communicate between the content scripts and the main add-on script. For more -details on content scripting see the tutorial on [interacting with web -content](#guide/addon-development/web-content). - -To create a PageMod the add-on developer supplies: - -* a set of rules to select the desired subset of web pages based on their URL. -Each rule is specified using the -[match-pattern](#module/api-utils/match-pattern) syntax. - -* a set of content scripts to execute in the context of the desired pages. - -* a value for the onAttach option: this value is a function which will be -called when a page is loaded that matches the ruleset. This is used to set up a -communication channel between the add-on code and the content script. - -All these parameters are optional except for the ruleset, which must include -at least one rule. - -The following add-on displays an alert whenever a page matching the ruleset is -loaded: - - var pageMod = require("page-mod"); - pageMod.PageMod({ - include: "*.org", - contentScript: 'window.alert("Page matches ruleset");' - }); - -If you specify a value of "ready" for `contentScriptWhen` then the content -script can interact with the DOM itself: - - var pageMod = require("page-mod"); - pageMod.PageMod({ - include: "*.org", - contentScriptWhen: 'ready', - contentScript: 'document.body.innerHTML = ' + - ' "

Page matches ruleset

";' - }); - -### Communicating With Content Scripts### - -When a matching page is loaded the `PageMod` will call the function that the -add-on code supplied to `onAttach`. The `PageMod` supplies one argument to -this function: a `worker` object. - -The worker can be thought of as the add-on's end of -a communication channel between the add-on code and the content scripts that -have been attached to this page. - -Thus the add-on can pass messages to the content scripts by calling the -worker's `postMessage` function and can receive messages from the content -scripts by registering a function as a listener to the worker's `on` function. - -Note that if multiple matching pages are loaded simultaneously then each page -is loaded into its own execution context with its own copy of the content -scripts. In this case `onAttach` is called once for each loaded page, and the -add-on code will have a separate worker for each page: - -![Multiple workers](media/multiple-workers.jpg) - -This is demonstrated in the following example: - - var pageMod = require("page-mod"); - var tabs = require("tabs"); - - var workers = new Array(); - - pageMod.PageMod({ - include: ["http://www.mozilla*"], - contentScriptWhen: 'ready', - contentScript: "onMessage = function onMessage(message) {" + - " window.alert(message);};", - onAttach: function onAttach(worker) { - if (workers.push(worker) == 3) { - workers[0].postMessage("The first worker!"); - workers[1].postMessage("The second worker!"); - workers[2].postMessage("The third worker!"); - } - } - }); - - tabs.open("http://www.mozilla.com"); - tabs.open("http://www.mozilla.org"); - tabs.open("http://www.mozilla-europe.org"); - -Here we specify a ruleset to match any URLs starting with -"http://www.mozilla". When a page matches we add the supplied worker to -an array, and when we have three workers in the array we send a message to -each worker in turn, telling it the order in which it was attached. The -worker just displays the message in an alert box. - -This shows that separate pages execute in separate contexts and that each -context has its own communication channel with the add-on script. - -Note though that while there is a separate worker for each execution context, -the worker is shared across all the content scripts associated with a single -execution context. In the following example we pass two content scripts into -the `PageMod`: these content scripts will share a worker instance. - -In the example each content script identifies itself to the add-on script -by sending it a message using the global `postMessage` function. In the -`onAttach` function the add-on code logs the fact that a new page is -attached and registers a listener function that simply logs the message: - - - var pageMod = require("page-mod"); - const data = require("self").data; - var tabs = require("tabs"); - - pageMod.PageMod({ - include: ["http://www.mozilla*"], - contentScriptWhen: 'ready', - contentScript: ["postMessage('Content script 1 is attached to '+ " + - "document.URL);", - "postMessage('Content script 2 is attached to '+ " + - "document.URL);"], - onAttach: function onAttach(worker) { - console.log("Attaching content scripts") - worker.on('message', function(data) { - console.log(data); - }); - } - }); - - tabs.open("http://www.mozilla.com"); - -The console output of this add-on is: - -
-  info: Attaching content scripts
-  info: Content script 1 is attached to http://www.mozilla.com/en-US/
-  info: Content script 2 is attached to http://www.mozilla.com/en-US/
-
- - -@class -A PageMod object. Once activated a page mod will execute the supplied content -scripts in the context of any pages matching the pattern specified by the -'include' property. - -@constructor -Creates a PageMod. -@param options {object} - Options for the PageMod, with the following keys: - @prop include {string,array} - A match pattern string or an array of match pattern strings. These define - the pages to which the PageMod applies. See the - [match-pattern](#module/api-utils/match-pattern) module for - a description of match pattern syntax. - At least one match pattern must be supplied. - - @prop [contentScriptFile] {string,array} - The local file URLs of content scripts to load. Content scripts specified - by this option are loaded *before* those specified by the `contentScript` - option. Optional. - @prop [contentScript] {string,array} - The texts of content scripts to load. Content scripts specified by this - option are loaded *after* those specified by the `contentScriptFile` option. - Optional. - @prop [contentScriptWhen] {string} - When to load the content scripts. Optional. - Possible values are "start" (default), which loads them as soon as - the window object for the page has been created, and "ready", which loads - them once the DOM content of the page has been loaded. - @prop [onAttach] {function} -A function to call when the PageMod attaches content scripts to -a matching page. The function will be called with one argument, a `worker` -object which the add-on script can use to communicate with the content scripts -attached to the page in question. - - - - -@property {List} -A [list](#module/api-utils/list) of match pattern strings. These define the -pages to which the page mod applies. See the -[match-pattern](#module/api-utils/match-pattern) module for a description of -match patterns. Rules can be added to the list by calling its `add` method and -removed by calling its `remove` method. - - - - -@method -Stops the page mod from making any more modifications. Once destroyed the page -mod can no longer be used. Note that modifications already made to open pages -will not be undone. - - - diff --git a/packages/addon-kit/docs/request.md b/packages/addon-kit/docs/request.md deleted file mode 100644 index 46af71e0..00000000 --- a/packages/addon-kit/docs/request.md +++ /dev/null @@ -1,152 +0,0 @@ -The `request` module lets you make simple yet powerful network requests. - - -@class -The `Request` object is used to make `GET` or `POST` network requests. It is -constructed with a URL to which the request is sent. Optionally the user may -specify a collection of headers and content to send alongside the request and -a callback which will be executed once the request completes. - -Once a `Request` object has been created a `GET` request can be executed by -calling its `get()` method, or a `POST` request by calling its `post()` method. - -When the server completes the request, the `Request` object emits a "complete" -event. Registered event listeners are passed a `Response` object. - -Each `Request` object is designed to be used once. Once `GET` or `POST` are -called, attempting to call either will throw an error. - -Since the request is not being made by any particular website, requests made -here are not subject to the same-domain restriction that requests made in web -pages are subject to. - -With the exception of `response`, all of a `Request` object's properties -correspond with the options in the constructor. Each can be set by simply -performing an assignment. However, keep in mind that the same validation rules -that apply to `options` in the constructor will apply during assignment. Thus, -each can throw if given an invalid value. - -The example below shows how to use Request to get the most recent public tweet. - - var Request = require('request').Request; - var latestTweetRequest = Request({ - url: "http://api.twitter.com/1/statuses/public_timeline.json", - onComplete: function (response) { - var tweet = response.json[0]; - console.log("User: " + tweet.user.screen_name); - console.log("Tweet: " + tweet.text); - } - }); - - // Be a good consumer and check for rate limiting before doing more. - Request({ - url: "http://api.twitter.com/1/account/rate_limit_status.json", - onComplete: function (response) { - if (response.json.remaining_hits) { - latestTweetRequest.get(); - } else { - console.log("You have been rate limited!"); - } - } - }).get(); - - -@constructor -This constructor creates a request object that can be used to make network -requests. The constructor takes a single parameter `options` which is used to -set several properties on the resulting `Request`. -@param options {object} - @prop url {string} - This is the url to which the request will be made. - - @prop [onComplete] {function} - This function will be called when the request has received a response (or in - terms of XHR, when `readyState == 4`). The function is passed a `Response` - object. - - @prop [headers] {object} - An unordered collection of name/value pairs representing headers to send - with the request. - - @prop [content] {string,object} - The content to send to the server. If `content` is a string, it should be - URL-encoded (use `encodeURIComponent`). If `content` is an object, it - should be a collection of name/value pairs. Nested objects & arrays should - encode safely. - - For `GET` requests, the query string (`content`) will be appended to the - URL. For `POST` requests, the query string will be sent as the body of the - request. - - @prop [contentType] {string} - The type of content to send to the server. This explicitly sets the - `Content-Type` header. The default value is `application/x-www-form-urlencoded`. - - - -@property {string} - - - -@property {object} - - - -@property {string,object} - - - -@property {string} - - - -@property {Response} - - - -@method -Make a `GET` request. -@returns {Request} - - - -@method -Make a `POST` request. -@returns {Request} - - - - - -@class -The Response object contains the response to a network request issued using a -`Request` object. It is returned by the `get()` or `post()` method of a -`Request` object. - -All members of a `Response` object are read-only. - -@property {string} -The content of the response as plain text. - - - -@property {object} -The content of the response as a JavaScript object. The value will be `null` -if the document cannot be processed by `JSON.parse`. - - - -@property {string} -The HTTP response status code (e.g. *200*). - - - -@property {string} -The HTTP response status line (e.g. *OK*). - - - -@property {object} -The HTTP response headers represented as key/value pairs. - - diff --git a/packages/addon-kit/package.json b/packages/addon-kit/package.json deleted file mode 100644 index 753e5461..00000000 --- a/packages/addon-kit/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "addon-kit", - "description": "Add-on development made easy.", - "keywords": ["javascript", "engine", "platform", "xulrunner"], - "author": "Atul Varma (http://toolness.com/) ", - "contributors": [ - "Myk Melez (http://melez.com/) ", - "Daniel Aquino " - ], - "version": "1.0b3pre", - "license": "MPL 1.1/GPL 2.0/LGPL 2.1", - "dependencies": ["api-utils"] -} diff --git a/packages/api-utils/README.md b/packages/api-utils/README.md deleted file mode 100644 index b00e0174..00000000 --- a/packages/api-utils/README.md +++ /dev/null @@ -1,31 +0,0 @@ -API Utils provides a basic CommonJS infrastructure for -developing traditional XULRunner Extensions and applications. It is -the basis for the Add-on SDK. - -To address issues present in traditional Extension 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 extensions 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/data/bootstrap-remote-process.js b/packages/api-utils/data/bootstrap-remote-process.js deleted file mode 100644 index 86f7a81b..00000000 --- a/packages/api-utils/data/bootstrap-remote-process.js +++ /dev/null @@ -1,197 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Jetpack. - * - * The Initial Developer of the Original Code is Mozilla. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Atul Varma - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// This is the first code that's ever run in a Jetpack process. It sets up -// infrastructure and receivers needed to start a Jetpack-based addon -// in a separate process. - -// A list of scripts to inject into all new CommonJS module sandboxes. -var injectedSandboxScripts = []; - -// A table of all CommonJS modules currently loaded. -var modules = {}; - -// This object represents the chrome process, and can be used to -// communicate with it. -var chrome = { - createHandle: function() { - return createHandle(); - }, - on: function(type, listener) { - registerReceiver(type, listener); - }, - removeListener: function(type, listener) { - unregisterReceiver(type, listener); - }, - send: function(type) { - sendMessage.apply(this, arguments); - }, - call: function(name) { - var result = callMessage.apply(this, arguments); - if (result.length > 1) - throw new Error("More than one result received for call '" + name + - "': " + result.length); - if (result.length == 0) - throw new Error("No receiver registered for call '" + name + "'"); - return result[0]; - } -}; - -// Use this for really low-level debugging of this script. -function dump(msg) { - // Don't use chrome.send() to avoid infinite recursion when - // debugging chrome.send() itself. - sendMessage("dump", msg); -} - -// Taken from plain-text-console.js. -function stringify(arg) { - try { - return String(arg); - } - catch(ex) { - return ""; - } -} - -// Set up our "proxy" objects that just send messages to our parent -// process to do the real work. -var console = { - exception: function(e) { - chrome.send('console:exception', e); - }, - trace: function() { - chrome.send('console:trace', new Error()); - } -}; - -['log', 'debug', 'info', 'warn', 'error'].forEach(function(method) { - console[method] = function() { - chrome.send('console:' + method, Array.map(arguments, stringify)); - } -}); - -var memory = { - track: function() { - /* TODO */ - } -}; - -function makeRequire(base) { - var resolvedNames = {}; - - function require(name) { - // first, have we already require()d this name from this base? Just - // re-use the module - if (name && name in resolvedNames) - return resolvedNames[name].exports; - - // if not, resolve relative import names by asking the browser-process - // side for the URL/filename of the module this points to - var response = chrome.call("require", base, name); - switch (response.code) { - case "not-found": - throw new Error("Unknown module '" + name + "'."); - case "access-denied": - throw new Error("Module '" + name + "' requires chrome privileges " + - "and has no e10s adapter."); - case "error": - throw new Error("An unexpected error occurred in the chrome " + - "process."); - case "ok": - break; - default: - throw new Error("Internal error: unknown response code '" + - response.code + "'"); - }; - - // do we already have a module for this filename? - if (response.script.filename in modules) { - module = resolvedNames[name] = modules[response.script.filename]; - return module.exports; - } - - var module = createSandbox(); - - function injectScript(script) { - evalInSandbox(module, '//@line 1 "' + script.filename + - '"\n' + script.contents); - } - - injectedSandboxScripts.forEach(injectScript); - - modules[response.script.filename] = resolvedNames[name] = module; - - // Set up the globals of the sandbox. - module.exports = {}; - module.console = console; - module.memory = memory; - module.require = makeRequire(response.script.filename); - module.__url__ = response.script.filename; - - if (response.needsMessaging) - module.chrome = chrome; - - injectScript(response.script); - - return module.exports; - }; - return require; -} - -chrome.on( - "addInjectedSandboxScript", - function(name, script) { - injectedSandboxScripts.push(script); - }); - -chrome.on( - "startMain", - function(name, mainName, options) { - var mainRequire = makeRequire(null); - var main = mainRequire(mainName); - - var callbacks = { - quit: function quit(status) { - if (status === undefined) - status = "OK"; - chrome.send("quit", status); - } - }; - - if ('main' in main) - main.main(options, callbacks); - }); diff --git a/packages/api-utils/data/test-content-symbiont.js b/packages/api-utils/data/test-content-symbiont.js deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/api-utils/docs/api-utils.md b/packages/api-utils/docs/api-utils.md deleted file mode 100644 index d87acdb6..00000000 --- a/packages/api-utils/docs/api-utils.md +++ /dev/null @@ -1,153 +0,0 @@ - - - -The `api-utils` module provides some helpers useful to the SDK's high-level API -implementations. - -Introduction ------------- - -The SDK high-level API design guidelines make a number of recommendations. -This module implements some of those patterns so that your own implementations -don't need to reinvent them. - -For example, public constructors should be callable both with and without the -`new` keyword. Your module can implement this recommendation using the -`publicConstructor` function. - -Options objects or "dictionaries" are also common throughout the high-level -APIs. The guidelines recommend that public constructors should generally define -a single `options` parameter rather than defining many parameters. Since one of -the SDK's principles is to be friendly to developers, ideally all properties on -options dictionaries should be checked for correct type, and informative error -messages should be generated when clients make mistakes. With the -`validateOptions` function, your module can easily do so. - -And objects are sometimes iterable over a custom set of key/value pairs. -Such objects should have custom iterators that let consumers iterate keys, -values, or [key, value] pairs. The `addIterator` function makes it easy to do -so in a way that is consistent with the behavior of default iterators during -`for...in`, `for each...in`, and `for...in Iterator()` loops. - - -@function -Returns a function *C* that creates an instance of `privateConstructor`. *C* -may be called with or without the `new` keyword. - -The prototype of each instance returned from *C* is *C*.`prototype`, and -*C*.`prototype` is an object whose prototype is -`privateConstructor.prototype`. Instances returned from *C* are therefore -instances of both *C* and `privateConstructor`. - -Additionally, the constructor of each instance returned from *C* is *C*. - -Instances returned from *C* are automatically memory tracked using -`memory.track` under the bin name `privateConstructor.name`. - -**Example** - - function MyObject() {} - exports.MyObject = apiUtils.publicConstructor(MyObject); - -@returns {function} -A function that makes new instances of `privateConstructor`. - -@param privateConstructor {constructor} - - - -@function -A function to validate an options dictionary according to the specified -constraints. - -`map`, `is`, and `ok` are used in that order. - -The return value is an object whose keys are those keys in `requirements` that -are also in `options` and whose values are the corresponding return values of -`map` or the corresponding values in `options`. Note that any keys not shared -by both `requirements` and `options` are not in the returned object. - -**Examples** - -A typical use: - - var opts = { foo: 1337 }; - var requirements = { - foo: { - map: function (val) val.toString(), - is: ["string"], - ok: function (val) val.length > 0, - msg: "foo must be a non-empty string." - } - }; - var validatedOpts = apiUtils.validateOptions(opts, requirements); - // validatedOpts == { foo: "1337" } - -If the key `foo` is optional and doesn't need to be mapped: - - var opts = { foo: 1337 }; - var validatedOpts = apiUtils.validateOptions(opts, { foo: {} }); - // validatedOpts == { foo: 1337 } - - opts = {}; - validatedOpts = apiUtils.validateOptions(opts, { foo: {} }); - // validatedOpts == {} - -@returns {object} -A validated options dictionary given some requirements. If any of the -requirements are not met, an exception is thrown. - -@param options {object} -The options dictionary to validate. It's not modified. If it's null or -otherwise falsey, an empty object is assumed. - -@param requirements {object} -An object whose keys are the expected keys in `options`. Any key in -`options` that is not present in `requirements` is ignored. Each -value in `requirements` is itself an object describing the requirements -of its key. The keys of that object are the following, and each is optional: - -@prop [map] {function} -A function that's passed the value of the key in the `options`. `map`'s -return value is taken as the key's value in the final validated options, -`is`, and `ok`. If `map` throws an exception it is caught and discarded, -and the key's value is its value in `options`. - -@prop [is] {array} -An array containing the number of `typeof` type names. If the key's value is -none of these types it fails validation. Arrays and nulls are identified by -the special type names "array" and "null"; "object" will not match either. -No type coercion is done. - -@prop [ok] {function} -A function that is passed the key's value. If it returns false, the value -fails validation. - -@prop [msg] {string} -If the key's value fails validation, an exception is thrown. This string -will be used as its message. If undefined, a generic message is used, unless -`is` is defined, in which case the message will state that the value needs to -be one of the given types. - - - -@function -Adds an iterator to the specified object that iterates keys, values, -or [key, value] pairs depending on how it is invoked, i.e.: - - for (var key in obj) { ... } // iterate keys - for each (var val in obj) { ... } // iterate values - for (var [key, val] in Iterator(obj)) { ... } // iterate pairs - -If your object only iterates either keys or values, you don't need this -function. Simply assign a generator function that iterates the keys/values -to your object's `__iterator__` property instead, f.e.: - - obj.__iterator__ = function () { for each (var i in items) yield i; } - -@param obj {object} -the object to which to add the iterator - -@param keysValsGen {function} -a generator function that yields [key, value] pairs - diff --git a/packages/api-utils/docs/app-strings.md b/packages/api-utils/docs/app-strings.md deleted file mode 100644 index 3e4d3587..00000000 --- a/packages/api-utils/docs/app-strings.md +++ /dev/null @@ -1,61 +0,0 @@ -The `app-strings` module gives you access to the host application's localized -string bundles (`.properties` files). - -The module exports the `StringBundle` constructor function. To access a string -bundle, construct an instance of `StringBundle`, passing it the bundle's URL: - - var StringBundle = require("app-strings").StringBundle; - var bundle = StringBundle("chrome://browser/locale/browser.properties"); - -To get the value of a string, call the object's `get` method, passing it -the name of the string: - - var accessKey = bundle.get("contextMenuSearchText.accesskey"); - // "S" in the en-US locale - -To get the formatted value of a string that accepts arguments, call the object's -`get` method, passing it the name of the string and an array of arguments -with which to format the string: - - var searchText = bundle.get("contextMenuSearchText", - ["universe", "signs of intelligent life"]); - // 'Search universe for "signs of intelligent life"' in the en-US locale - -To get all strings in the bundle, iterate the object, which returns arrays -of the form [name, value]: - - for (var [name, value] in Iterator(bundle)) - console.log(name + " = " + value); - -Iteration ---------- - -for (var name in bundle) { ... } - -Iterate the names of strings in the bundle. - -for each (var val in bundle) { ... } - -Iterate the values of strings in the bundle. - -for (var [name, value] in Iterator(bundle)) { ... } - -Iterate the names and values of strings in the bundle. - - - -@class -The `StringBundle` object represents a string bundle. - -@constructor -Creates a StringBundle object that gives you access to a string bundle. -@param url {string} the URL of the string bundle -@returns {StringBundle} the string bundle - - -@method Get the value of the string with the given name. -@param [name] {string} the name of the string to get -@param [args] {array} (optional) strings that replace placeholders in the string -@returns {string} the value of the string - - diff --git a/packages/api-utils/docs/collection.md b/packages/api-utils/docs/collection.md deleted file mode 100644 index 469e95ec..00000000 --- a/packages/api-utils/docs/collection.md +++ /dev/null @@ -1,71 +0,0 @@ - - - -The `collection` module provides a simple list-like class and utilities for -using it. A collection is ordered, like an array, but its items are unique, -like a set. - - -@class -A collection object provides for...in-loop iteration. Items are yielded in the -order they were added. For example, the following code... - - var collection = require("collection"); - var c = new collection.Collection(); - c.add(1); - c.add(2); - c.add(3); - for (item in c) - console.log(item); - -... would print this to the console: - - 1 - 2 - 3 - -Iteration proceeds over a copy of the collection made before iteration begins, -so it is safe to mutate the collection during iteration; doing so does not -affect the results of the iteration. - - -@constructor -Creates a new collection. The collection is backed by an array. -@param [array] {array} -If *array* is given, it will be used as the backing array. This way the caller -can fully control the collection. Otherwise a new empty array will be used, and -no one but the collection will have access to it. - - -@property {number} -The number of items in the collection array. - - -@method -Adds a single item or an array of items to the collection. Any items already -contained in the collection are ignored. -@param itemOrItems {object} An item or array of items. -@returns {Collection} The Collection. - - -@method -Removes a single item or an array of items from the collection. Any items not -contained in the collection are ignored. -@param itemOrItems {object} An item or array of items. -@returns {Collection} The Collection. - - - - -@function -Adds a collection property to the given object. Setting the property to a -scalar value empties the collection and adds the value. Setting it to an array -empties the collection and adds all the items in the array. -@param object {object} -The property will be defined on this object. -@param propName {string} -The name of the property. -@param [backingArray] {array} -If given, this will be used as the collection's backing array. - - diff --git a/packages/api-utils/docs/content.md b/packages/api-utils/docs/content.md deleted file mode 100644 index a02cc7d8..00000000 --- a/packages/api-utils/docs/content.md +++ /dev/null @@ -1,11 +0,0 @@ - - -The `content` module exports three different traits [Loader], [Worker] and -[Symbiont]. None of this traits is intended to be used directly by programs. -Rather, they are intended to be used by other modules that provide high -level APIs to programs or libraries. - -[Loader]:#module/api-utils/content/loader -[Worker]:#module/api-utils/content/worker -[Symbiont]:#module/api-utils/content/symbiont - diff --git a/packages/api-utils/docs/content/loader.md b/packages/api-utils/docs/content/loader.md deleted file mode 100644 index ccfbcc06..00000000 --- a/packages/api-utils/docs/content/loader.md +++ /dev/null @@ -1,79 +0,0 @@ - - -Loader ------- - -Loader is base trait and it provides set of core properties and associated -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] trait, therefore instances -of Loader and their descendants expose all the public properties -exposed by EventEmitter along with additional public properties: - -Value changes on all of the above mentioned properties emit `propertyChange` -events on an instances. - -**Example:** - -The following code creates a wrapper on hidden frame that reloads a web page -in frame every time `contentURL` property is changed: - - const hiddenFrames = require("hidden-frame"); - const { Loader } = require("content"); - const PageLoader = Loader.compose({ - constructor: function PageLoader(options) { - options = options || {}; - if (options.contentURL) - this.contentURL = options.contentURL; - this.on('propertyChange', this._onChange = this._onChange.bind(this)); - let self = this; - hiddenFrames.add(hiddenFrames.HiddenFrame({ - onReady: function onReady() { - let frame = self._frame = this.element; - self._emit('propertyChange', { contentURL: self.contentURL }); - } - })); - }, - _onChange: function _onChange(e) { - if ('contentURL' in e) - this._frame.setAttribute('src', this._contentURL); - } - }); - - -@class - -@property {array} -The local file URLs of content scripts to load. Content scripts specified by -this property are loaded *before* those specified by the `contentScript` -property. - - - -@property {array} -The texts of content scripts to load. Content scripts specified by this -property are loaded *after* those specified by the `contentScriptFile` property. - - - -@property {string} -When to load the content scripts. -Possible values are "start" (default), which loads them as soon as -the window object for the page has been created, and "ready", which loads -them once the DOM content of the page has been loaded. - - - -@property {string} -The URL of the content loaded. - - - -@property {object} -Permissions for the content, with the following keys: -@prop script {boolean} - Whether or not to execute script in the content. Defaults to true. - - - diff --git a/packages/api-utils/docs/content/symbiont.md b/packages/api-utils/docs/content/symbiont.md deleted file mode 100644 index 67bac89c..00000000 --- a/packages/api-utils/docs/content/symbiont.md +++ /dev/null @@ -1,110 +0,0 @@ - - - - -This module is not intended to be used directly by programs. Rather, it is -intended to be used by other modules that provide APIs to programs. - - -This module exports `Symbiont` trait that can be used for creating JavaScript -contexts that can access web content in host application frames (i.e. XUL -`