From 4fa077828a87d18fdcb30e6ff5ed3bea8e32d659 Mon Sep 17 00:00:00 2001 From: John Foerch Date: Fri, 19 Mar 2010 14:24:02 -0400 Subject: [PATCH] new module system This commit provides a new module system which, while in the main being backward compatible with the old module system, provides the capability for modules to have their own namespace. The centerpiece of the system is a new function 'load', which is patterned after the function of that name in emacs lisp, plus the added capability of working with modules. Modules now need to have as their first expression an in_module assertion, and as their last expression a 'provide' call. Backward compatibility is provided by "in_module(null);" which causes the module to be loaded into application scope instead of its own namespace. The call_after_load procedure now takes a feature name, not a filename. Feature names are normally the same as the filename, but without a .js extension. This patch fixes a bug in the theme system whereby modules in subdirectories could not be themed. (The theme system depends on feature names being independent of directory structures.) The capability to write namespaced modules is thus provided, but no existing modules are updated in this patch. Those can be done incrementally as deemed useful. --- components/application.js | 273 ++++++++++++++----- contrib/modules/mode-line-buttons.js | 4 + defaults/preferences/default-modules.js | 3 - modules/array.js | 4 + modules/bindings/default/bindings.js | 116 +++++--- modules/bindings/default/caret.js | 2 - modules/bindings/default/content-buffer/anchor.js | 3 - modules/bindings/default/content-buffer/button.js | 5 - .../bindings/default/content-buffer/checkbox.js | 4 - modules/bindings/default/content-buffer/element.js | 1 - modules/bindings/default/content-buffer/form.js | 4 - modules/bindings/default/content-buffer/normal.js | 5 - .../bindings/default/content-buffer/richedit.js | 3 - modules/bindings/default/content-buffer/select.js | 4 - modules/bindings/default/content-buffer/text.js | 3 - .../bindings/default/content-buffer/textarea.js | 3 - modules/bindings/default/content-buffer/zoom.js | 2 - modules/bindings/default/download-buffer.js | 4 - modules/bindings/default/global.js | 7 - modules/bindings/default/help-buffer.js | 4 - modules/bindings/default/hints.js | 3 - modules/bindings/default/isearch.js | 3 - modules/bindings/default/minibuffer.js | 3 - modules/bindings/default/quote.js | 2 - modules/bindings/default/special-buffer.js | 4 - modules/block-content-focus-change.js | 4 + modules/buffer.js | 4 + modules/builtin-commands.js | 4 + modules/cache.js | 3 + modules/caret.js | 4 + modules/casual-spelling.js | 3 + modules/clicks-in-new-buffer.js | 4 + modules/command-line.js | 3 + modules/commands.js | 4 + modules/conkeror.js | 200 +++++++------- modules/content-buffer-input.js | 3 + modules/content-buffer.js | 4 + modules/content-handler.js | 4 +- modules/cookie.js | 4 + modules/coroutine.js | 4 + modules/daemon.js | 6 +- modules/debug.js | 4 + modules/download-manager.js | 3 + modules/element.js | 3 + modules/env.js | 4 + modules/extension.js | 4 + modules/extensions/adblockplus.js | 4 + modules/extensions/dom-inspector.js | 4 + modules/extensions/noscript.js | 4 + modules/extensions/venkman.js | 4 + modules/external-editor.js | 4 + modules/eye-guide.js | 4 + modules/favicon.js | 4 + modules/find.js | 4 + modules/follow-relationship.js | 3 + modules/global-overlay-keymap.js | 4 + modules/help.js | 4 + modules/hints.js | 4 + modules/history.js | 4 + modules/hook.js | 4 + modules/index-webjump.js | 4 + modules/input.js | 4 + modules/interactive.js | 3 + modules/io.js | 4 + modules/keymap.js | 4 + modules/keywords.js | 4 + modules/labels.js | 4 + modules/load-spec.js | 4 + modules/media.js | 3 + modules/mime-type-override.js | 4 + modules/mime.js | 4 + modules/minibuffer-completion.js | 4 + modules/minibuffer-read-file.js | 4 + modules/minibuffer-read-mime-type.js | 4 + modules/minibuffer-read-option.js | 4 + modules/minibuffer-read.js | 4 + modules/minibuffer.js | 4 + modules/mode-line.js | 4 + modules/mode.js | 4 + modules/new-tabs.js | 5 + modules/page-modes/dailymotion.js | 4 + modules/page-modes/gmail.js | 4 + modules/page-modes/gmane.js | 4 + modules/page-modes/google-calendar.js | 4 + modules/page-modes/google-gqueues.js | 4 + modules/page-modes/google-images.js | 4 + modules/page-modes/google-maps.js | 4 + modules/page-modes/google-reader.js | 4 + modules/page-modes/google-search-results.js | 3 + modules/page-modes/google-video.js | 4 + modules/page-modes/google-voice.js | 4 + modules/page-modes/reddit.js | 4 + modules/page-modes/stackoverflow.js | 4 + modules/page-modes/wikipedia.js | 4 + modules/page-modes/xkcd.js | 4 + modules/page-modes/youtube.js | 4 + modules/permission-manager.js | 4 + modules/pref.js | 3 + modules/pretty-print.js | 4 + modules/quote.js | 4 + modules/rc.js | 3 + modules/save.js | 4 + modules/scroll.js | 4 +- modules/search-engine.js | 4 + modules/selectively-unstyle.js | 3 + modules/services.js | 4 + modules/session.js | 4 + modules/source-code.js | 4 + modules/spawn-process.js | 4 + modules/special-buffer.js | 4 + modules/ssl.js | 4 + modules/string.js | 4 + modules/stylesheet.js | 7 +- modules/suggest-file-name.js | 4 + modules/tab-bar.js | 5 + modules/theme.js | 9 +- modules/timer.js | 4 + modules/universal-argument.js | 3 + modules/user-variable.js | 4 + modules/utils.js | 14 +- modules/walnut.js | 3 + modules/webjump.js | 4 + modules/window.js | 4 + modules/zoom.js | 3 + tests/simple/modules.js | 295 +++++++++++++++++++-- 125 files changed, 1056 insertions(+), 306 deletions(-) rewrite modules/bindings/default/bindings.js (86%) rewrite modules/conkeror.js (69%) rewrite tests/simple/modules.js (69%) diff --git a/components/application.js b/components/application.js index ff3577c..43f5cab 100644 --- a/components/application.js +++ b/components/application.js @@ -1,5 +1,5 @@ /** - * (C) Copyright 2007 John J. Foerch + * (C) Copyright 2007,2010 John J. Foerch * (C) Copyright 2007-2008 Jeremy Maitin-Shepard * * Use, modification, and distribution are subject to the terms specified in the @@ -17,14 +17,22 @@ function application () { this.wrappedJSObject = this; this.conkeror = this; - this.loaded_modules = []; + this.load_url = this.subscript_loader.loadSubScript; + this.loading_urls = []; + this.loading_paths = []; this.loading_modules = []; - this.module_after_load_functions = new Object(); + this.loading_features = []; + this.features = {}; + this.load_paths = [this.module_uri_prefix, + this.module_uri_prefix+'extensions', + this.module_uri_prefix+'page-modes']; + this.after_load_functions = {}; this.pending_loads = []; - this.load_paths = [this.module_uri_prefix]; + + this.module_assert_conflict_error.prototype = Error.prototype; try { - this.require("conkeror.js"); + this.require("conkeror.js", null); } catch (e) { this.dumpln("Error initializing."); this.dump_error(e); @@ -63,82 +71,213 @@ application.prototype = { this.dumpln("Error: " + e); } }, - loaded: function (module) { - return (this.loaded_modules.indexOf(module) != -1); - }, - provide: function(module) { - if (this.loaded_modules.indexOf(module) == -1) - this.loaded_modules.push(module); + + make_uri: function (uri, charset, base_uri) { + const io_service = Cc["@mozilla.org/network/io-service;1"] + .getService(Ci.nsIIOService2); + if (uri instanceof Ci.nsIURI) + return uri; + if (uri instanceof Ci.nsIFile) + return io_service.newFileURI(uri); + return io_service.newURI(uri, charset, base_uri); }, - skip_module_load : {}, - load_module: function(module_name) { - if (this.loading_modules.indexOf(module_name) != -1) - throw new Error("Circular module dependency detected: " - + this.loading_modules.join(" -> ") + " -> " + module_name); - this.loading_modules.push(module_name); - try { - let j = 0; - while (true) { - if (j >= this.load_paths.length) - throw new Error("Module not found: " + module_name); - try { - this.subscript_loader.loadSubScript(this.load_paths[j] + module_name, - this); - this.provide(module_name); - let funcs; - if ((funcs = this.module_after_load_functions[module_name]) != null) - { - for (let i = 0; i < funcs.length; ++i) - funcs[i](); - delete this.module_after_load_functions[module_name]; - } + skip_module_load: {}, + load: function (module, as) { + var conkeror = this; + function module_scope () { + this.__proto__ = conkeror; + this.conkeror = conkeror; + } + function load1 (url, scope, path, as) { + var success; + try { + this.loading_paths.unshift(path); + this.loading_urls.unshift(url); + this.loading_modules.unshift(as); + this.loading_features.unshift({}); + if (this.loading_urls.indexOf(url, 1) != -1) + throw new Error("Circular module dependency detected: "+ + this.loading_urls.join(",\n")); + this.load_url(url, scope); + success = true; + if (as) + this[as] = scope; + // call-after-load callbacks + for (let f in this.loading_features[0]) { + this.features[f] = true; + this.run_after_load_functions(f); } - catch (e if e == this.skip_module_load) {} - catch (e) { - if (!(e instanceof Error) && !(e instanceof Ci.nsIException) && - (String(e) == "ContentLength not available (not a local URL?)" || - String(e) == "Error creating channel (invalid URL scheme?)" || - String(e) == "Error opening input stream (invalid filename?)")) { - ++j; - continue; - } - throw e; + } finally { + this.loading_paths.shift(); + this.loading_urls.shift(); + this.loading_modules.shift(); + this.loading_features.shift(); + } + // do pending loads + if (success && this.loading_urls[0] === undefined) { + let pending = this.pending_loads; + this.pending_loads = []; + for (let i = 0, m; m = pending[i]; ++i) { + this.require(m[0], m[1]); } - break; } } - finally { - this.loading_modules.pop(); - } - - if (this.loading_modules.length == 0) - { - while (this.pending_loads.length > 0) - { - this.require(this.pending_loads.pop()); + var scope = as; + if (as == null) + scope = this; + else if (typeof as == 'string') + scope = new module_scope(); + else + as = null; + var path, url; + if (module instanceof Ci.nsIURI) + path = module.path.substr(0, module.path.lastIndexOf('/')+1); + else if (module instanceof Ci.nsIFile) + path = module.parent.path; + var restarted = false; + if (path !== undefined) { + url = this.make_uri(module).spec; + do { + try { + load1.call(this, url, scope, path, as); + return; + } catch (e if e instanceof this.module_assert_error) { + if (restarted) + throw new this.module_assert_conflict_error(url); + as = e.module; + if (e.module) + scope = new module_scope(); + else + scope = this; + restarted = true; + } catch (e if e == this.skip_module_load) { + return; + } + } while (restarted); + } else { + // module name or relative path + var autoext = module.substr(-3) != '.js'; + var suffix = false; + var i = -1; + var tried = {}; + path = this.loading_paths[0]; + if (path === undefined) + path = this.load_paths[++i]; + while (path !== undefined) { + let opath = path; + try { + let sep = path[path.length-1] == '/' ? '' : '/'; + url = path + sep + module + (suffix ? '.js' : ''); + let si = module.lastIndexOf('/'); + if (si > -1) + path += module.substr(0, si); + if (tried[url] !== scope) { + tried[url] = scope; + load1.call(this, url, scope, path, as); + return; + } + } catch (e if e instanceof this.module_assert_error) { + if (restarted) + throw new this.module_assert_conflict_error(url); + as = e.module; + if (e.module) + scope = new module_scope(); + else + scope = this; + path = opath; + restarted = true; + continue; + } catch (e if (typeof e == 'string' && + {"ContentLength not available (not a local URL?)":true, + "Error creating channel (invalid URL scheme?)":true, + "Error opening input stream (invalid filename?)":true} + [e])) { + // null op. (suppress error, try next path) + } catch (e if e == this.skip_module_load) { + return; + } + if (autoext) + suffix = !suffix; + if (! suffix) + path = this.load_paths[++i]; } + throw new Error("Module not found"); } }, - require: function (module) { - if (!this.loaded(module)) - this.load_module(module); + module_assert_error: function (module) { + this.module = module; + }, + module_assert_conflict_error: function (url) { //subclass of Error + this.name = "module_assert_conflict_error"; + this.message = "Conflicting in_module calls"; + this.fileName = url; + this.lineNumber = ''; + }, + in_module: function (module) { + if (module != this.loading_modules[0]) + throw new this.module_assert_error(module); }, - require_later: function (module) { - if (!this.loaded(module) - && this.pending_loads.indexOf(module) == -1) - this.pending_loads.push(module); + provide: function (symbol) { + if (! symbol) + throw new Error("Cannot provide null feature"); + if (this.loading_urls[0] === undefined) { + this.features[symbol] = true; + this.run_after_load_functions(symbol); + } else + this.loading_features[0][symbol] = true; }, - call_after_load: function (module, func) { - if (this.loaded(module)) + featurep: function (symbol) { + return this.features[symbol]; + }, + call_after_load: function (feature, func) { + if (this.featurep(feature)) func(); - else - { - var funcs; - if (!(funcs = this.module_after_load_functions[module])) - funcs = this.module_after_load_functions[module] = []; + else { + var funcs = this.after_load_functions[feature]; + if (! funcs) + funcs = this.after_load_functions[feature] = []; funcs.push(func); } }, + run_after_load_functions: function (symbol) { + var funcs = this.after_load_functions[symbol]; + if (funcs) { + delete this.after_load_functions[symbol]; + for (var i = 0; funcs[i]; ++i) { + try { + funcs[i](); + } catch (e) { + dump_error(e); + } + } + } + }, + require: function (module, as) { + var feature = as; + if (! feature) { + if (module instanceof Ci.nsIURI) + feature = module.spec.substr(module.spec.lastIndexOf('/')+1); + else if (module instanceof Ci.nsIFile) + feature = module.leafName; + else + feature = module.substr(module.lastIndexOf('/')+1); + let dot = feature.indexOf('.'); + if (dot == 0) + return false; + if (dot > 0) + feature = feature.substr(0, dot); + feature = feature.replace('_', '-', 'g'); + } + if (this.featurep(feature)) + return true; + if (as === undefined) + as = feature.replace('-', '_', 'g'); + this.load(module, as); + return true; + }, + require_later: function (module, as) { + this.pending_loads.push([module, as]); + }, /* nsISupports */ QueryInterface: XPCOMUtils.generateQI([]), diff --git a/contrib/modules/mode-line-buttons.js b/contrib/modules/mode-line-buttons.js index 90dafd7..d041774 100644 --- a/contrib/modules/mode-line-buttons.js +++ b/contrib/modules/mode-line-buttons.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("mode-line.js"); function button_widget (window) { @@ -86,3 +88,5 @@ standard_mode_line_buttons = [ ["buffer-next", "go-down"], ["help-page", "help"], ]; + +provide("mode-line-buttons"); diff --git a/defaults/preferences/default-modules.js b/defaults/preferences/default-modules.js index 5205b4b..83be66a 100644 --- a/defaults/preferences/default-modules.js +++ b/defaults/preferences/default-modules.js @@ -42,7 +42,6 @@ pref("conkeror.load.mode-line", 1); pref("conkeror.load.daemon", 1); pref("conkeror.load.favicon", 1); // Enhances tab-bar mode -pref("conkeror.load.tab-bar", 0); // Extension support modules // These modules will automatically skip loading if the associated extension is not enabled. @@ -54,12 +53,10 @@ pref("conkeror.load.extensions/noscript", 1); // Page mode modules pref("conkeror.load.page-modes/youtube", 1); pref("conkeror.load.page-modes/reddit", 1); -pref("conkeror.load.page-modes/google-search-results", 0); pref("conkeror.load.page-modes/google-calendar", 1); pref("conkeror.load.page-modes/google-reader", 1); pref("conkeror.load.page-modes/google-video", 1); pref("conkeror.load.page-modes/google-maps", 1); pref("conkeror.load.page-modes/dailymotion", 1); -pref("conkeror.load.page-modes/gmail", 0); pref("conkeror.load.page-modes/xkcd", 1); pref("conkeror.load.page-modes/stackoverflow", 1); diff --git a/modules/array.js b/modules/array.js index 095b18f..fac4da7 100644 --- a/modules/array.js +++ b/modules/array.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + /** * remove_duplicates_filter returns a function that can be used in * Array.filter. It removes duplicates. Optional argument cmp is a @@ -91,3 +93,5 @@ function splice_range (arr, start, end) { arr.push([start, end]); return arr; } + +provide("array"); diff --git a/modules/bindings/default/bindings.js b/modules/bindings/default/bindings.js dissimilarity index 86% index b96378b..54b69ac 100644 --- a/modules/bindings/default/bindings.js +++ b/modules/bindings/default/bindings.js @@ -1,34 +1,82 @@ -/** - * (C) Copyright 2007-2008 Jeremy Maitin-Shepard - * (C) Copyright 2009 John J. Foerch - * - * Use, modification, and distribution are subject to the terms specified in the - * COPYING file. -**/ - -// Simply load the other modules - -require("bindings/default/content-buffer/normal.js"); -require("bindings/default/content-buffer/anchor.js"); -require("bindings/default/content-buffer/form.js"); -require("bindings/default/content-buffer/text.js"); -require("bindings/default/content-buffer/checkbox.js"); -require("bindings/default/content-buffer/textarea.js"); -require("bindings/default/content-buffer/richedit.js"); -require("bindings/default/content-buffer/select.js"); -require("bindings/default/content-buffer/button.js"); - -require("bindings/default/minibuffer.js"); -require("bindings/default/hints.js"); -require("bindings/default/isearch.js"); -require("bindings/default/universal-argument.js"); - -require("bindings/default/content-buffer/element.js"); -require("bindings/default/content-buffer/zoom.js"); - -require("bindings/default/special-buffer.js"); -require("bindings/default/help-buffer.js"); -require("bindings/default/download-buffer.js"); - -require("bindings/default/caret.js"); -require("bindings/default/quote.js"); +/** + * (C) Copyright 2007-2008 Jeremy Maitin-Shepard + * (C) Copyright 2009-2010 John J. Foerch + * + * Use, modification, and distribution are subject to the terms specified in the + * COPYING file. +**/ + +in_module(null); + +/* + * define keymaps + */ + +define_keymap("sequence_help_keymap"); +define_keymap("sequence_abort_keymap"); + +define_keymap("default_base_keymap"); + +define_keymap("default_help_keymap"); + +define_keymap("default_global_keymap", $parent = default_base_keymap); + +define_keymap("content_buffer_normal_keymap", $parent = default_global_keymap); +define_keymap("content_buffer_form_keymap"); +define_keymap("content_buffer_anchor_keymap"); +define_keymap("content_buffer_button_keymap"); +define_keymap("content_buffer_checkbox_keymap"); +define_keymap("content_buffer_select_keymap"); +define_keymap("content_buffer_text_keymap"); +define_keymap("content_buffer_textarea_keymap", $parent = content_buffer_text_keymap); +define_keymap("content_buffer_richedit_keymap", $parent = content_buffer_textarea_keymap); + +define_keymap("special_buffer_keymap", $parent = default_global_keymap); +define_keymap("download_buffer_keymap", $parent = special_buffer_keymap); +define_keymap("help_buffer_keymap", $parent = special_buffer_keymap); + +define_keymap("minibuffer_base_keymap", $parent = default_base_keymap); +define_keymap("hint_keymap", $parent = default_base_keymap); +define_keymap("isearch_keymap", $parent = default_base_keymap); + +define_keymap("caret_keymap"); + +define_keymap("quote_next_keymap"); +define_keymap("quote_keymap"); + + +/* + * load bindings + */ + +load("basic-commands.js"); + +load("global.js"); + +load("content-buffer/normal.js"); +load("content-buffer/anchor.js"); +load("content-buffer/form.js"); +load("content-buffer/text.js"); +load("content-buffer/checkbox.js"); +load("content-buffer/textarea.js"); +load("content-buffer/richedit.js"); +load("content-buffer/select.js"); +load("content-buffer/button.js"); + +load("minibuffer.js"); +load("hints.js"); +load("isearch.js"); +load("universal-argument.js"); + +load("content-buffer/element.js"); +load("content-buffer/zoom.js"); + +load("special-buffer.js"); +load("help-buffer.js"); +load("download-buffer.js"); + +load("caret.js"); +load("quote.js"); + + +provide("bindings"); diff --git a/modules/bindings/default/caret.js b/modules/bindings/default/caret.js index 99bb6cb..40bf289 100644 --- a/modules/bindings/default/caret.js +++ b/modules/bindings/default/caret.js @@ -6,8 +6,6 @@ * COPYING file. **/ -define_keymap("caret_keymap"); - define_key(caret_keymap, "C-a", "caret-beginning-of-line"); define_key(caret_keymap, "C-e", "caret-end-of-line"); define_key(caret_keymap, "C-b", "caret-backward-char"); diff --git a/modules/bindings/default/content-buffer/anchor.js b/modules/bindings/default/content-buffer/anchor.js index a5b5914..85b5cf4 100644 --- a/modules/bindings/default/content-buffer/anchor.js +++ b/modules/bindings/default/content-buffer/anchor.js @@ -5,9 +5,6 @@ * COPYING file. **/ -/* Keymap for hyperlink anchors */ -define_keymap("content_buffer_anchor_keymap"); - define_key(content_buffer_anchor_keymap, "return", "follow", $browser_object = browser_object_focused_element); define_key(content_buffer_anchor_keymap, "o", "follow-new-buffer", diff --git a/modules/bindings/default/content-buffer/button.js b/modules/bindings/default/content-buffer/button.js index ee29656..c2e9807 100644 --- a/modules/bindings/default/content-buffer/button.js +++ b/modules/bindings/default/content-buffer/button.js @@ -5,11 +5,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/form.js"); - -/* Keymap for form buttons */ -define_keymap("content_buffer_button_keymap"); - define_key(content_buffer_button_keymap, "space", "follow", $browser_object = browser_object_focused_element); define_key(content_buffer_button_keymap, "return", "follow", diff --git a/modules/bindings/default/content-buffer/checkbox.js b/modules/bindings/default/content-buffer/checkbox.js index b6591a9..5a4b606 100644 --- a/modules/bindings/default/content-buffer/checkbox.js +++ b/modules/bindings/default/content-buffer/checkbox.js @@ -5,10 +5,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/form.js"); - -/* Keymap for checkboxes and radiobuttons */ -define_keymap("content_buffer_checkbox_keymap"); define_fallthrough(content_buffer_checkbox_keymap, match_checkbox_keys); define_key(content_buffer_checkbox_keymap, "space", null, $fallthrough); diff --git a/modules/bindings/default/content-buffer/element.js b/modules/bindings/default/content-buffer/element.js index 6915131..446abb8 100644 --- a/modules/bindings/default/content-buffer/element.js +++ b/modules/bindings/default/content-buffer/element.js @@ -6,7 +6,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/normal.js"); require("element.js"); define_key(content_buffer_normal_keymap, "i", "browser-object-images"); diff --git a/modules/bindings/default/content-buffer/form.js b/modules/bindings/default/content-buffer/form.js index b85da43..f06dbdd 100644 --- a/modules/bindings/default/content-buffer/form.js +++ b/modules/bindings/default/content-buffer/form.js @@ -5,10 +5,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/normal.js"); - -define_keymap("content_buffer_form_keymap"); - define_key(content_buffer_form_keymap, "return", null, $fallthrough); define_key(content_buffer_form_keymap, "C-c C-c", "submit-form"); diff --git a/modules/bindings/default/content-buffer/normal.js b/modules/bindings/default/content-buffer/normal.js index 1019634..8df04a2 100644 --- a/modules/bindings/default/content-buffer/normal.js +++ b/modules/bindings/default/content-buffer/normal.js @@ -7,11 +7,6 @@ * COPYING file. **/ -require("bindings/default/global.js"); -require("bindings/default/basic-commands.js"); - -define_keymap("content_buffer_normal_keymap", $parent = default_global_keymap); - bind_scroll_keys(content_buffer_normal_keymap); bind_selection_keys(content_buffer_normal_keymap); diff --git a/modules/bindings/default/content-buffer/richedit.js b/modules/bindings/default/content-buffer/richedit.js index c78f9fd..7319ec2 100644 --- a/modules/bindings/default/content-buffer/richedit.js +++ b/modules/bindings/default/content-buffer/richedit.js @@ -6,7 +6,4 @@ * COPYING file. **/ -require("bindings/default/content-buffer/textarea.js"); - -define_keymap("content_buffer_richedit_keymap", $parent = content_buffer_textarea_keymap); define_fallthrough(content_buffer_richedit_keymap, match_text_keys); diff --git a/modules/bindings/default/content-buffer/select.js b/modules/bindings/default/content-buffer/select.js index a085331..2e678dd 100644 --- a/modules/bindings/default/content-buffer/select.js +++ b/modules/bindings/default/content-buffer/select.js @@ -5,10 +5,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/form.js"); - -define_keymap("content_buffer_select_keymap"); - define_key(content_buffer_select_keymap, "up", null, $fallthrough); define_key(content_buffer_select_keymap, "down", null, $fallthrough); define_key(content_buffer_select_keymap, "left", null, $fallthrough); diff --git a/modules/bindings/default/content-buffer/text.js b/modules/bindings/default/content-buffer/text.js index 20ffdd1..5b65598 100644 --- a/modules/bindings/default/content-buffer/text.js +++ b/modules/bindings/default/content-buffer/text.js @@ -8,9 +8,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/form.js"); - -define_keymap("content_buffer_text_keymap"); define_fallthrough(content_buffer_text_keymap, match_text_keys); define_key(content_buffer_text_keymap, match_text_keys, null, $fallthrough); diff --git a/modules/bindings/default/content-buffer/textarea.js b/modules/bindings/default/content-buffer/textarea.js index 6346400..dd508a1 100644 --- a/modules/bindings/default/content-buffer/textarea.js +++ b/modules/bindings/default/content-buffer/textarea.js @@ -7,9 +7,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/text.js"); - -define_keymap("content_buffer_textarea_keymap", $parent = content_buffer_text_keymap); define_fallthrough(content_buffer_textarea_keymap, match_text_keys); // textarea keys diff --git a/modules/bindings/default/content-buffer/zoom.js b/modules/bindings/default/content-buffer/zoom.js index b7a02d5..81dd4b0 100644 --- a/modules/bindings/default/content-buffer/zoom.js +++ b/modules/bindings/default/content-buffer/zoom.js @@ -5,8 +5,6 @@ * COPYING file. **/ -require("bindings/default/content-buffer/normal.js"); - define_key(content_buffer_normal_keymap, "+", "zoom-in-text"); define_key(content_buffer_normal_keymap, "=", "zoom-reset-text"); define_key(content_buffer_normal_keymap, "-", "zoom-out-text"); diff --git a/modules/bindings/default/download-buffer.js b/modules/bindings/default/download-buffer.js index db63e59..94a96ca 100644 --- a/modules/bindings/default/download-buffer.js +++ b/modules/bindings/default/download-buffer.js @@ -6,10 +6,6 @@ * COPYING file. **/ -require("bindings/default/special-buffer.js"); - -define_keymap("download_buffer_keymap", $parent = special_buffer_keymap); - define_key(download_buffer_keymap, "d", "download-cancel"); define_key(download_buffer_keymap, "r", "download-retry-or-resume"); define_key(download_buffer_keymap, "p", "download-pause-or-resume"); diff --git a/modules/bindings/default/global.js b/modules/bindings/default/global.js index b390bd4..aac9612 100644 --- a/modules/bindings/default/global.js +++ b/modules/bindings/default/global.js @@ -7,10 +7,6 @@ * COPYING file. **/ -define_keymap("default_base_keymap"); - - -define_keymap("default_help_keymap"); define_key(default_help_keymap, "a", "apropos-command"); define_key(default_help_keymap, "b", "describe-bindings"); define_key(default_help_keymap, "f", "describe-command"); @@ -25,18 +21,15 @@ define_key(default_help_keymap, "w", "where-is"); define_key(default_base_keymap, "C-h", default_help_keymap); -define_keymap("sequence_help_keymap"); define_key(sequence_help_keymap, "C-h", "describe-active-bindings"); -define_keymap("sequence_abort_keymap"); define_key(sequence_abort_keymap, "C-g", "sequence-abort"); /** * Note: Most buffer keymaps should set this as the parent. */ -define_keymap("default_global_keymap", $parent = default_base_keymap); define_key(default_global_keymap, "M-x", "execute-extended-command"); define_key(default_global_keymap, "M-:", "eval-expression"); define_key(default_global_keymap, "M-!", "shell-command"); diff --git a/modules/bindings/default/help-buffer.js b/modules/bindings/default/help-buffer.js index 168aa60..b1c3151 100644 --- a/modules/bindings/default/help-buffer.js +++ b/modules/bindings/default/help-buffer.js @@ -6,8 +6,4 @@ * COPYING file. **/ -require("bindings/default/special-buffer.js"); - -define_keymap("help_buffer_keymap", $parent = special_buffer_keymap); - define_key(help_buffer_keymap, "\\", "view-referenced-source-code"); diff --git a/modules/bindings/default/hints.js b/modules/bindings/default/hints.js index 0644f1c..6647990 100644 --- a/modules/bindings/default/hints.js +++ b/modules/bindings/default/hints.js @@ -6,9 +6,6 @@ * COPYING file. **/ -require("bindings/default/global.js"); - -define_keymap("hint_keymap", $parent = default_base_keymap); define_fallthrough(hint_keymap, match_any_unmodified_character); define_key(hint_keymap, match_any_unmodified_character, null, $fallthrough); diff --git a/modules/bindings/default/isearch.js b/modules/bindings/default/isearch.js index 5260f60..884dacb 100644 --- a/modules/bindings/default/isearch.js +++ b/modules/bindings/default/isearch.js @@ -7,9 +7,6 @@ * COPYING file. **/ -require("bindings/default/global.js"); - -define_keymap("isearch_keymap", $parent = default_base_keymap); define_fallthrough(isearch_keymap, match_any_unmodified_character); define_key(isearch_keymap, match_any_unmodified_character, null, $fallthrough); diff --git a/modules/bindings/default/minibuffer.js b/modules/bindings/default/minibuffer.js index 00ba456..ee1d5ee 100644 --- a/modules/bindings/default/minibuffer.js +++ b/modules/bindings/default/minibuffer.js @@ -7,9 +7,6 @@ * COPYING file. **/ -require("bindings/default/global.js"); - -define_keymap("minibuffer_base_keymap", $parent = default_base_keymap); define_fallthrough(minibuffer_base_keymap, match_any_unmodified_character); define_key(minibuffer_base_keymap, match_any_unmodified_character, null, $fallthrough); diff --git a/modules/bindings/default/quote.js b/modules/bindings/default/quote.js index 2dc3d42..57d2291 100644 --- a/modules/bindings/default/quote.js +++ b/modules/bindings/default/quote.js @@ -6,11 +6,9 @@ * COPYING file. **/ -define_keymap("quote_next_keymap"); define_fallthrough(quote_next_keymap, match_any_key); define_key(quote_next_keymap, match_any_key, "buffer-reset-input-mode", $fallthrough); -define_keymap("quote_keymap"); define_fallthrough(quote_keymap, match_not_escape_key); define_key(quote_keymap, "escape", "quote-mode-disable"); define_key(quote_keymap, "M-escape", "quote-mode-disable"); diff --git a/modules/bindings/default/special-buffer.js b/modules/bindings/default/special-buffer.js index 685d3b3..6436b4d 100644 --- a/modules/bindings/default/special-buffer.js +++ b/modules/bindings/default/special-buffer.js @@ -6,9 +6,5 @@ * COPYING file. **/ -require("bindings/default/global.js"); - -define_keymap("special_buffer_keymap", $parent = default_global_keymap); - bind_scroll_keys(special_buffer_keymap); bind_selection_keys(special_buffer_keymap); diff --git a/modules/block-content-focus-change.js b/modules/block-content-focus-change.js index c00d84d..7efb341 100644 --- a/modules/block-content-focus-change.js +++ b/modules/block-content-focus-change.js @@ -11,6 +11,8 @@ * rude websites from changing the element focus via javascript. */ +in_module(null); + define_variable("block_content_focus_change_duration", 20, "Duration (in milliseconds) during which an element is "+ "allowed to gain focus following a mouse click or key press, "+ @@ -93,3 +95,5 @@ let (foo = browser_set_element_focus) { } block_content_focus_change_mode(true); + +provide("block-content-focus-change"); diff --git a/modules/buffer.js b/modules/buffer.js index 440878d..ff60850 100644 --- a/modules/buffer.js +++ b/modules/buffer.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + var define_buffer_local_hook = local_hook_definer("window"); function define_current_buffer_hook (hook_name, existing_hook) { @@ -942,3 +944,5 @@ minibuffer_input_mode_indicator.prototype = { define_global_window_mode("minibuffer_input_mode_indicator", "window_initialize_hook"); minibuffer_input_mode_indicator_mode(true); + +provide("buffer"); diff --git a/modules/builtin-commands.js b/modules/builtin-commands.js index ca89ba9..04d9b30 100644 --- a/modules/builtin-commands.js +++ b/modules/builtin-commands.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + function define_builtin_commands (prefix, do_command_function, toggle_mark, mark_active_predicate, mode) { // Specify a docstring @@ -218,3 +220,5 @@ function define_builtin_commands (prefix, do_command_function, toggle_mark, mark } } } + +provide("builtin-commands"); diff --git a/modules/cache.js b/modules/cache.js index 6196caf..2034667 100644 --- a/modules/cache.js +++ b/modules/cache.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + const cache_service = Cc["@mozilla.org/network/cache-service;1"] .getService(Ci.nsICacheService); @@ -86,3 +88,4 @@ function cache_enable (cache_type) { throw new Error("Invalid cache type"); } +provide("cache"); diff --git a/modules/caret.js b/modules/caret.js index 34b33b6..478a516 100644 --- a/modules/caret.js +++ b/modules/caret.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + function caret_modality (buffer, elem) { return caret_keymap; } @@ -49,3 +51,5 @@ watch_pref('accessibility.browsewithcaret', remove_hook('create_buffer_hook', caret_mode_enable); } }); + +provide("caret"); diff --git a/modules/casual-spelling.js b/modules/casual-spelling.js index a2bea86..9a3bacb 100644 --- a/modules/casual-spelling.js +++ b/modules/casual-spelling.js @@ -19,6 +19,8 @@ such as accented letters and ligatures. */ +in_module(null); + function casual_spelling_entry_features (entry) { var ret = { ligatures: false, multiples: false }; if (typeof entry == "object") { @@ -303,3 +305,4 @@ var casual_spelling_ligatures = casual_spelling_from_range_table( casual_spelling_table_add(casual_spelling_accents); casual_spelling_table_add(casual_spelling_ligatures); +provide("casual-spelling"); diff --git a/modules/clicks-in-new-buffer.js b/modules/clicks-in-new-buffer.js index 64b1c93..f262f73 100644 --- a/modules/clicks-in-new-buffer.js +++ b/modules/clicks-in-new-buffer.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + define_variable("clicks_in_new_buffer_button", 1, "Which mouse button should open links in a new buffer. " + "0 = left, 1 = middle, 2 = right. Default is 1."); @@ -87,3 +89,5 @@ define_global_mode("clicks_in_new_buffer_mode", clicks_in_new_buffer_mode_disable); clicks_in_new_buffer_mode(true); + +provide("clicks-in-new-buffer"); diff --git a/modules/command-line.js b/modules/command-line.js index bc6b204..b13ac08 100644 --- a/modules/command-line.js +++ b/modules/command-line.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + var command_line_handlers = []; define_variable("conkeror_started", false, @@ -227,3 +229,4 @@ function handle_command_line (cmdline) { conkeror_started = true; } +provide("command-line"); diff --git a/modules/commands.js b/modules/commands.js index 0349d4c..83d191d 100644 --- a/modules/commands.js +++ b/modules/commands.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + define_coroutine_hook("before_quit_hook", RUN_HOOK_UNTIL_FAILURE); define_hook("quit_hook"); @@ -858,3 +860,5 @@ interactive("kill-ring-save", I.buffer.mark_active = false; I.buffer.do_command("cmd_copy"); }); + +provide("commands"); diff --git a/modules/conkeror.js b/modules/conkeror.js dissimilarity index 69% index f6124f9..9419076 100644 --- a/modules/conkeror.js +++ b/modules/conkeror.js @@ -1,98 +1,102 @@ -/** - * (C) Copyright 2007-2008 Jeremy Maitin-Shepard - * (C) Copyright 2009 John J. Foerch - * - * Use, modification, and distribution are subject to the terms specified in the - * COPYING file. -**/ - -var start_time = Date.now(); - -require("keywords.js"); -require("labels.js"); -require("coroutine.js"); -require("debug.js"); -require("hook.js"); -require("timer.js"); -require("pretty-print.js"); -require("services.js"); - -require("string.js"); -require("pref.js"); -require("env.js"); -require("source-code.js"); -require("user-variable.js"); -require("stylesheet.js"); -require("extension.js"); -require("array.js"); -require("builtin-commands.js"); - -require("utils.js"); -require("interactive.js"); -require("minibuffer.js"); -require("minibuffer-read.js"); -require("minibuffer-read-option.js"); -require("minibuffer-completion.js"); -require("minibuffer-read-file.js"); -require("spawn-process.js"); -require("mime.js"); -require("keymap.js"); -require("input.js"); -require("buffer.js"); -require("window.js"); -require("content-handler.js"); -require("download-manager.js"); - -require("element.js"); - -require("buffer.js") -require("content-buffer.js"); -require("content-buffer-input.js"); -require("quote.js"); -require("caret.js"); - -require("universal-argument.js"); -require("commands.js"); -require("webjump.js"); -require("history.js"); -require("scroll.js"); - -require("save.js"); - -require("zoom.js"); -require("follow-relationship.js"); - -require("find.js"); - -require("hints.js"); - -require("help.js"); - -require("rc.js"); - -require("ssl.js"); - -require("media.js"); - -require("command-line.js"); - -require("search-engine.js"); - -require("permission-manager.js"); -require("cookie.js"); -require("cache.js"); - -require("theme.js"); - - -define_variable("cwd", get_home_directory(), - "Current working directory, also known as your default download "+ - "and shell-command directory. It will often have a buffer-local "+ - "value."); - - -/* Re-define load_paths as a user variable. */ -define_variable("load_paths", load_paths, - "Array of URL prefixes searched in order when loading a module.\n"+ - "Each entry must end in a slash, and should begin with file:// or "+ - "chrome://."); +/** + * (C) Copyright 2007-2008 Jeremy Maitin-Shepard + * (C) Copyright 2009-2010 John J. Foerch + * + * Use, modification, and distribution are subject to the terms specified in the + * COPYING file. +**/ + +in_module(null); + +var start_time = Date.now(); + +require("keywords.js", null); +require("labels.js", null); +require("coroutine.js", null); +require("debug.js", null); +require("hook.js", null); +require("timer.js", null); +require("pretty-print.js", null); +require("services.js", null); + +require("string.js", null); +require("pref.js", null); +require("env.js", null); +require("source-code.js", null); +require("user-variable.js", null); +require("stylesheet.js", null); +require("extension.js", null); +require("array.js", null); +require("builtin-commands.js", null); + +require("utils.js", null); +require("interactive.js", null); +require("minibuffer.js", null); +require("minibuffer-read.js", null); +require("minibuffer-read-option.js", null); +require("minibuffer-completion.js", null); +require("minibuffer-read-file.js", null); +require("spawn-process.js", null); +require("mime.js", null); +require("keymap.js", null); +require("input.js", null); +require("buffer.js", null); +require("window.js", null); +require("content-handler.js", null); +require("download-manager.js", null); + +require("element.js", null); + +require("buffer.js", null) +require("content-buffer.js", null); +require("content-buffer-input.js", null); +require("quote.js", null); +require("caret.js", null); + +require("universal-argument.js", null); +require("commands.js", null); +require("webjump.js", null); +require("history.js", null); +require("scroll.js", null); + +require("save.js", null); + +require("zoom.js", null); +require("follow-relationship.js", null); + +require("find.js", null); + +require("hints.js", null); + +require("help.js", null); + +require("rc.js", null); + +require("ssl.js", null); + +require("media.js", null); + +require("command-line.js", null); + +require("search-engine.js", null); + +require("permission-manager.js", null); +require("cookie.js", null); +require("cache.js", null); + +require("theme.js", null); + + +define_variable("cwd", get_home_directory(), + "Current working directory, also known as your default download "+ + "and shell-command directory. It will often have a buffer-local "+ + "value."); + + +/* Re-define load_paths as a user variable. */ +define_variable("load_paths", load_paths, + "Array of URL prefixes searched in order when loading a module.\n"+ + "Each entry must end in a slash, and should begin with file:// or "+ + "chrome://."); + +provide("conkeror"); diff --git a/modules/content-buffer-input.js b/modules/content-buffer-input.js index ac36b2c..7dfa107 100644 --- a/modules/content-buffer-input.js +++ b/modules/content-buffer-input.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -270,3 +272,4 @@ interactive("capitalize-word", "Capitalize the following word (or arg words), moving over.", capitalize_word); +provide("content-buffer-input"); diff --git a/modules/content-buffer.js b/modules/content-buffer.js index d1729e3..e2c848e 100644 --- a/modules/content-buffer.js +++ b/modules/content-buffer.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + require("buffer.js"); require("load-spec.js"); @@ -669,3 +671,5 @@ function page_mode_auto_update (buffer) { } add_hook("content_buffer_location_change_hook", page_mode_auto_update); + +provide("content-buffer"); diff --git a/modules/content-handler.js b/modules/content-handler.js index 522cc9d..ca4f85e 100644 --- a/modules/content-handler.js +++ b/modules/content-handler.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("mime-type-override.js"); define_mime_type_table("content_handlers", {}, @@ -211,4 +213,4 @@ download_helper.prototype = { } }; - +provide("content-handler"); diff --git a/modules/cookie.js b/modules/cookie.js index 96f3bfc..b93a9b3 100644 --- a/modules/cookie.js +++ b/modules/cookie.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + var cookie_manager = Cc["@mozilla.org/cookiemanager;1"] .getService(Ci.nsICookieManager2); @@ -55,3 +57,5 @@ define_special_variable("cookie_lifetime_policy", } }, "Specifies the default cookie lifetime policy."); + +provide("cookie"); diff --git a/modules/coroutine.js b/modules/coroutine.js index e9187ee..77b83de 100644 --- a/modules/coroutine.js +++ b/modules/coroutine.js @@ -214,6 +214,8 @@ * time, or completes. **/ +in_module(null); + function _return_value (x) { this.value = x; } @@ -430,3 +432,5 @@ function co_call (f) { } return cc; } + +provide("coroutine"); diff --git a/modules/daemon.js b/modules/daemon.js index b62c8c5..a82f55d 100644 --- a/modules/daemon.js +++ b/modules/daemon.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("mode.js"); define_variable("daemon_quit_exits", true, @@ -35,10 +37,12 @@ define_global_mode("daemon_mode", require_later("command-line.js"); -call_after_load("command-line.js", function () { +call_after_load("command-line", function () { command_line_handler("daemon", true, function () { daemon_mode(true); var window = make_chrome_window(conkeror_chrome_uri); window.setTimeout(function () { window.close(); }, 0); }); }); + +provide("daemon"); diff --git a/modules/debug.js b/modules/debug.js index 59fa36b..ee255ef 100644 --- a/modules/debug.js +++ b/modules/debug.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + var MAX_DUMP_DEPTH = 1; function dump_obj_r (obj, name, indent, depth) { if (depth > MAX_DUMP_DEPTH) { @@ -99,3 +101,5 @@ let (console = Cc["@mozilla.org/consoleservice;1"] } }}); } + +provide("debug"); diff --git a/modules/download-manager.js b/modules/download-manager.js index 63eba4b..ca3cd3a 100644 --- a/modules/download-manager.js +++ b/modules/download-manager.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("special-buffer.js"); require("mime-type-override.js"); require("minibuffer-read-mime-type.js"); @@ -922,3 +924,4 @@ interactive("download-show", target); }); +provide("download-manager"); diff --git a/modules/element.js b/modules/element.js index dbdf259..7cc6d92 100644 --- a/modules/element.js +++ b/modules/element.js @@ -9,6 +9,8 @@ * COPYING file. **/ +in_module(null); + require("hints.js"); require("save.js"); require("mime-type-override.js"); @@ -620,3 +622,4 @@ function browser_element_shell_command (buffer, elem, command, cwd) { $shell_command_cwd = cwd); } +provide("element"); diff --git a/modules/env.js b/modules/env.js index 671ad1c..14293f0 100644 --- a/modules/env.js +++ b/modules/env.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + /** * get_os returns a string identifying the current OS. * possible values include 'Darwin', 'Linux' and 'WINNT'. @@ -93,3 +95,5 @@ function get_locale () { const LOCALE_PREF = "general.useragent.locale"; return get_localized_pref(LOCALE_PREF) || get_pref(LOCALE_PREF); } + +provide("env"); diff --git a/modules/extension.js b/modules/extension.js index 6f5c593..8a0beda 100644 --- a/modules/extension.js +++ b/modules/extension.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + const PREFIX_ITEM_URI = "urn:mozilla:item:"; const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#"; @@ -73,3 +75,5 @@ function extension_is_enabled (id) { var info = new extension_info(id); return info.update_item && (info.isDisabled == "false"); } + +provide("extension"); diff --git a/modules/extensions/adblockplus.js b/modules/extensions/adblockplus.js index d304138..affbe53 100644 --- a/modules/extensions/adblockplus.js +++ b/modules/extensions/adblockplus.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("extension.js"); if (!extension_is_enabled("{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}")) @@ -40,3 +42,5 @@ interactive("adblockplus-add", }, $browser_object = browser_object_images, $prompt = "Adblock"); + +provide("adblockplus"); diff --git a/modules/extensions/dom-inspector.js b/modules/extensions/dom-inspector.js index 6b8d862..a818f38 100644 --- a/modules/extensions/dom-inspector.js +++ b/modules/extensions/dom-inspector.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("extension.js"); if (!extension_is_enabled("inspector@mozilla.org")) @@ -51,3 +53,5 @@ interactive("inspect-click", window.addEventListener("click", handler, true); I.minibuffer.message("Click in this window to select the DOM node to inspect."); }); + +provide("dom-inspector"); diff --git a/modules/extensions/noscript.js b/modules/extensions/noscript.js index 270c34d..c98fd5f 100644 --- a/modules/extensions/noscript.js +++ b/modules/extensions/noscript.js @@ -1,4 +1,6 @@ +in_module(null); + require("extension.js"); if (!extension_is_enabled("{73a6fe31-595d-460b-a920-fcc0f8843232}")) @@ -115,3 +117,5 @@ interactive("ns-toggle-temp", "Allow a site temporary access to javascript", f reload(I.buffer, I.P); } }); + +provide("noscript"); diff --git a/modules/extensions/venkman.js b/modules/extensions/venkman.js index 4d1d062..b25d94a 100644 --- a/modules/extensions/venkman.js +++ b/modules/extensions/venkman.js @@ -9,6 +9,8 @@ * glue code between venkman and conkeror */ +in_module(null); + require("extension.js"); if (!extension_is_enabled("{f13b157f-b174-47e7-a34d-4815ddfdfeb8}")) @@ -21,3 +23,5 @@ function open_venkman () { interactive("venkman", "Open the Venkman Javascript Debugger in a new window.", open_venkman); + +provide("venkman"); diff --git a/modules/external-editor.js b/modules/external-editor.js index c14c442..9343c8b 100644 --- a/modules/external-editor.js +++ b/modules/external-editor.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + define_variable("editor_shell_command", getenv("VISUAL") || getenv("EDITOR") || "emacs", "Shell command used to invoke an external editor.\n" + "This defaults to the value of the EDITOR environment variable. If " + @@ -78,3 +80,5 @@ function open_with_external_editor (lspec) { let [file, temp] = yield download_as_temporary(lspec); yield open_file_with_external_editor(file, $line = arguments.$line, $temporary = temp); } + +provide("external-editor"); diff --git a/modules/eye-guide.js b/modules/eye-guide.js index 49353df..8974edc 100644 --- a/modules/eye-guide.js +++ b/modules/eye-guide.js @@ -14,6 +14,8 @@ * */ +in_module(null); + define_variable("eye_guide_interval", 800, "Interval during which the eye guide is visible (in ms). "+ "When 0, the eye guide will remain visible."); @@ -91,3 +93,5 @@ interactive("eye-guide-scroll-up", }, eye_guide_interval); }); + +provide("eye-guide"); diff --git a/modules/favicon.js b/modules/favicon.js index 744538b..245e12a 100644 --- a/modules/favicon.js +++ b/modules/favicon.js @@ -8,6 +8,8 @@ * COPYING file. **/ +in_module(null); + const favicon_service = Cc["@mozilla.org/browser/favicon-service;1"] .getService(Ci.nsIFaviconService); @@ -123,3 +125,5 @@ function favicon_content_buffer_dom_link_added (buffer, event) { } add_hook("content_buffer_dom_link_added_hook", favicon_content_buffer_dom_link_added); + +provide("favicon"); diff --git a/modules/find.js b/modules/find.js index bbec082..407089a 100644 --- a/modules/find.js +++ b/modules/find.js @@ -8,6 +8,8 @@ * COPYING file. **/ +in_module(null); + const CARET_ATTRIBUTE = 'showcaret'; define_variable("isearch_keep_selection", false, @@ -376,3 +378,5 @@ function isearch_done (window, keep_selection) { } interactive("isearch-done", null, function (I) { isearch_done(I.window); }); + +provide("find"); diff --git a/modules/follow-relationship.js b/modules/follow-relationship.js index f8d30c9..6e92701 100644 --- a/modules/follow-relationship.js +++ b/modules/follow-relationship.js @@ -9,6 +9,8 @@ * COPYING file. **/ +in_module(null); + require("element.js"); const RELATIONSHIP_NEXT = 0; @@ -104,3 +106,4 @@ define_browser_object_class("relationship-previous", null, throw interactive_error("No \"previous\" link found."); }); +provide("follow-relationship"); diff --git a/modules/global-overlay-keymap.js b/modules/global-overlay-keymap.js index 5f5f194..ec9a954 100644 --- a/modules/global-overlay-keymap.js +++ b/modules/global-overlay-keymap.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("input.js"); var global_overlay_keymap = new keymap(); @@ -60,3 +62,5 @@ function define_sticky_modifier (typed_key, modifiers) { global_overlay_keymap_mode(true); } ignore_function_for_get_caller_source_code_reference("define_sticky_modifier"); + +provide("global-overlay-keymap"); diff --git a/modules/help.js b/modules/help.js index 0eba877..f69e38c 100644 --- a/modules/help.js +++ b/modules/help.js @@ -8,6 +8,8 @@ * COPYING file. **/ +in_module(null); + require("special-buffer.js"); require("interactive.js"); @@ -754,3 +756,5 @@ function describe_preference_new_window (I) { } interactive("describe-preference", null, alternates(describe_preference_new_buffer, describe_preference_new_window)); + +provide("help"); diff --git a/modules/hints.js b/modules/hints.js index b3a5f9c..8496cb0 100644 --- a/modules/hints.js +++ b/modules/hints.js @@ -9,6 +9,8 @@ * COPYING file. **/ +in_module(null); + define_variable("active_img_hint_background_color", "#88FF00", "Color for the active image hint background."); @@ -604,3 +606,5 @@ minibuffer.prototype.read_hinted_element = function () { var result = yield SUSPEND; yield co_return(result); }; + +provide("hints"); diff --git a/modules/history.js b/modules/history.js index dfebf4e..4febf10 100644 --- a/modules/history.js +++ b/modules/history.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + define_keywords("$use_webjumps", "$use_history", "$use_bookmarks", "$match_required"); function history_completer () { @@ -65,3 +67,5 @@ function add_bookmark(url, title) { nav_bookmarks_service.insertBookmark(nav_bookmarks_service.unfiledBookmarksFolder, make_uri(url), -1, title); } + +provide("history"); diff --git a/modules/hook.js b/modules/hook.js index e3669f3..c43767d 100644 --- a/modules/hook.js +++ b/modules/hook.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("coroutine.js"); /* Adds the specified function to the specified hook. To add a local @@ -302,3 +304,5 @@ function remove_hook (hook_name, func) { if (hook && (index = hook.indexOf(func)) != -1) hook.splice(index, 1); } + +provide("hook"); diff --git a/modules/index-webjump.js b/modules/index-webjump.js index cc7ea51..83485ad 100644 --- a/modules/index-webjump.js +++ b/modules/index-webjump.js @@ -10,6 +10,8 @@ * pages. **/ +in_module(null); + require("webjump.js"); /* Objects with completion data for index webjumps. */ @@ -313,3 +315,5 @@ function define_gitweb_summary_webjump(key, base_url) { $alternative = alternative, $description = arguments.$description); } + +provide("index-webjump"); diff --git a/modules/input.js b/modules/input.js index 40da9ff..68f17c9 100644 --- a/modules/input.js +++ b/modules/input.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + require("window.js"); require("keymap.js"); require("interactive.js"); @@ -339,3 +341,5 @@ add_hook("window_initialize_hook", input_initialize_window); interactive("sequence-abort", "Abort an ongoing key sequence.", function (I) { I.minibuffer.message("abort sequence"); }); + +provide("input"); diff --git a/modules/interactive.js b/modules/interactive.js index f5c3dd9..ebdd45c 100644 --- a/modules/interactive.js +++ b/modules/interactive.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("utils.js"); var interactive_commands = new string_hashmap(); @@ -177,3 +179,4 @@ function set_default_browser_object (name, browser_object) { cmd.browser_object = browser_object; } +provide("interactive"); diff --git a/modules/io.js b/modules/io.js index 68f0ebe..b2fbcd2 100644 --- a/modules/io.js +++ b/modules/io.js @@ -9,6 +9,8 @@ * COPYING file. **/ +in_module(null); + const PERM_IWOTH = 00002; /* write permission, others */ const PERM_IWGRP = 00020; /* write permission, group */ @@ -228,3 +230,5 @@ function mime_input_stream(stream, headers) { mime_stream.setData(stream); return mime_stream; } + +provide("io"); diff --git a/modules/keymap.js b/modules/keymap.js index de54c9c..a7b8318 100644 --- a/modules/keymap.js +++ b/modules/keymap.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + /* Generate vk name table */ var keycode_to_vk_name = []; var vk_name_to_keycode = {}; @@ -594,3 +596,5 @@ minibuffer.prototype.read_key_binding = function () { var result = yield SUSPEND; yield co_return(result); }; + +provide("keymap"); diff --git a/modules/keywords.js b/modules/keywords.js index 7602aeb..3cb75bb 100644 --- a/modules/keywords.js +++ b/modules/keywords.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + { let _keyword_argument_list = []; let _get_keyword_argument_setter = function _get_keyword_argument_setter (name) { @@ -73,3 +75,5 @@ return new keyword_argument_forwarder(arguments); } } + +provide("keywords"); diff --git a/modules/labels.js b/modules/labels.js index 3edf427..aa2c219 100644 --- a/modules/labels.js +++ b/modules/labels.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("pretty-print.js"); /** @@ -82,3 +84,5 @@ function label_id (value) { return null; return value._id; } + +provide("labels"); diff --git a/modules/load-spec.js b/modules/load-spec.js index 42168c1..6b9fdc3 100644 --- a/modules/load-spec.js +++ b/modules/load-spec.js @@ -52,6 +52,8 @@ * Defaults to true. */ +in_module(null); + require("webjump.js"); function page_fragment_load_spec (elem) { @@ -350,3 +352,5 @@ function apply_load_spec (target, spec) { } } } + +provide("load-spec"); diff --git a/modules/media.js b/modules/media.js index 6f27392..41f8d09 100644 --- a/modules/media.js +++ b/modules/media.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + /** * Default media scraper * @@ -108,3 +110,4 @@ function media_setup_local_object_classes (buffer) { browser_object_media; } +provide("media"); diff --git a/modules/mime-type-override.js b/modules/mime-type-override.js index e447eec..16beba5 100644 --- a/modules/mime-type-override.js +++ b/modules/mime-type-override.js @@ -23,6 +23,8 @@ * **/ +in_module(null); + let EXAMINE_TOPIC = "http-on-examine-response"; let EXAMINE_MERGED_TOPIC = "http-on-examine-merged-response"; @@ -97,3 +99,5 @@ function override_mime_type_for_next_load(uri, mime_type) { } table.put(uri.spec, obj); } + +provide("mime-type-override"); diff --git a/modules/mime.js b/modules/mime.js index 89db7b8..4e67c5d 100644 --- a/modules/mime.js +++ b/modules/mime.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + const mime_service = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); /** @@ -109,3 +111,5 @@ function mime_info_from_mime_type (type) { return null; } } + +provide("mime"); diff --git a/modules/minibuffer-completion.js b/modules/minibuffer-completion.js index ff453de..b32cf69 100644 --- a/modules/minibuffer-completion.js +++ b/modules/minibuffer-completion.js @@ -9,6 +9,8 @@ * COPYING file. **/ +in_module(null); + require("minibuffer.js"); /** @@ -362,3 +364,5 @@ function completer_with_mappings(options, query) { ) ); } + +provide("minibuffer-completion"); diff --git a/modules/minibuffer-read-file.js b/modules/minibuffer-read-file.js index c2425d3..3895497 100644 --- a/modules/minibuffer-read-file.js +++ b/modules/minibuffer-read-file.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("io.js"); require("minibuffer-completion.js"); @@ -81,3 +83,5 @@ minibuffer.prototype.read_file_check_overwrite = function () { yield co_return(file); } while (true); }; + +provide("minibuffer-read-file"); diff --git a/modules/minibuffer-read-mime-type.js b/modules/minibuffer-read-mime-type.js index 374d19b..6032b18 100644 --- a/modules/minibuffer-read-mime-type.js +++ b/modules/minibuffer-read-mime-type.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("minibuffer-read.js"); let _viewable_mime_type_list = null; @@ -35,3 +37,5 @@ minibuffer.prototype.read_viewable_mime_type = function () { $completions = viewable_mime_type_list)); yield co_return(result); }; + +provide("minibuffer-read-mime-type"); diff --git a/modules/minibuffer-read-option.js b/modules/minibuffer-read-option.js index 9fdc2f3..ac80878 100644 --- a/modules/minibuffer-read-option.js +++ b/modules/minibuffer-read-option.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("minibuffer-read.js"); define_keywords("$options"); @@ -76,3 +78,5 @@ minibuffer.prototype.read_single_character_option = function () { var result = yield SUSPEND; yield co_return(result); }; + +provide("minibuffer-read-options"); diff --git a/modules/minibuffer-read.js b/modules/minibuffer-read.js index 6d96cb4..53ba739 100644 --- a/modules/minibuffer-read.js +++ b/modules/minibuffer-read.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + define_variable("default_minibuffer_auto_complete_delay", 150, "Delay (in milliseconds) after the most recent key-stroke "+ "before auto-completing."); @@ -555,3 +557,5 @@ minibuffer.prototype.read_preference = function minibuffer__read_preference () { var result = yield this.read(forward_keywords(arguments)); yield co_return(result); }; + +provide("minibuffer-read"); diff --git a/modules/minibuffer.js b/modules/minibuffer.js index db05c41..6564be3 100644 --- a/modules/minibuffer.js +++ b/modules/minibuffer.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + // This should only be used for minibuffer states where it makes // sense. In particular, it should not be used if additional cleanup // must be done. @@ -448,3 +450,5 @@ minibuffer.prototype.wait_for = function (message, coroutine) { } yield co_return(result); }; + +provide("minibuffer"); diff --git a/modules/mode-line.js b/modules/mode-line.js index 9757a68..0300c37 100644 --- a/modules/mode-line.js +++ b/modules/mode-line.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("mode.js"); define_window_local_hook("mode_line_hook"); @@ -244,3 +246,5 @@ add_hook("mode_line_hook", mode_line_adder(clock_widget)); add_hook("mode_line_hook", mode_line_adder(current_buffer_scroll_position_widget)); mode_line_mode(true); + +provide("mode-line"); diff --git a/modules/mode.js b/modules/mode.js index 927abe2..009946d 100644 --- a/modules/mode.js +++ b/modules/mode.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("interactive.js"); function define_global_mode (name, enable, disable) { @@ -37,3 +39,5 @@ function define_global_mode (name, enable, disable) { }); } ignore_function_for_get_caller_source_code_reference("define_global_mode"); + +provide("mode"); diff --git a/modules/new-tabs.js b/modules/new-tabs.js index b3925be..de9a4dd 100644 --- a/modules/new-tabs.js +++ b/modules/new-tabs.js @@ -11,6 +11,8 @@ * simply override these defaults by normal CSS. **/ +in_module(null); + require("mode.js"); define_variable("tab_bar_button_select", 0, @@ -209,3 +211,6 @@ define_global_mode("tab_bar_mode", }); tab_bar_mode(true); + +provide("tab-bar"); +provide("new-tabs"); diff --git a/modules/page-modes/dailymotion.js b/modules/page-modes/dailymotion.js index ec4e580..e7a0c16 100644 --- a/modules/page-modes/dailymotion.js +++ b/modules/page-modes/dailymotion.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); require("media.js"); @@ -45,3 +47,5 @@ define_page_mode("dailymotion_mode", var dailymotion_re = build_url_regex($domain = /(?:[^\/]*\.)?dailymotion/); auto_mode_list.push([dailymotion_re, dailymotion_mode]); media_scrapers.unshift([dailymotion_re, media_scrape_dailymotion]); + +provide("dailymotion"); diff --git a/modules/page-modes/gmail.js b/modules/page-modes/gmail.js index 8060c7c..c5fefb9 100644 --- a/modules/page-modes/gmail.js +++ b/modules/page-modes/gmail.js @@ -8,6 +8,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -110,3 +112,5 @@ define_page_mode("gmail_mode", var gmail_re = build_url_regex($domain = "mail.google", $path = new RegExp('(?!support)')); auto_mode_list.push([gmail_re, gmail_mode]); + +provide("gmail"); diff --git a/modules/page-modes/gmane.js b/modules/page-modes/gmane.js index 48e01fc..144eb3e 100644 --- a/modules/page-modes/gmane.js +++ b/modules/page-modes/gmane.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); define_keymap("gmane_keymap"); @@ -98,3 +100,5 @@ define_page_mode("gmane_mode", let (re = build_url_regex($domain = /(news|thread)\.gmane/, $tlds = ["org"])) { auto_mode_list.push([re, gmane_mode]); } + +provide("gmane"); diff --git a/modules/page-modes/google-calendar.js b/modules/page-modes/google-calendar.js index 0fd85ef..411716f 100644 --- a/modules/page-modes/google-calendar.js +++ b/modules/page-modes/google-calendar.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); define_keymap("google_calendar_keymap"); @@ -58,3 +60,5 @@ let (re = build_url_regex($domain = "google", $allow_www = true)) { auto_mode_list.push([re, google_calendar_mode]); } + +provide("google-calendar"); diff --git a/modules/page-modes/google-gqueues.js b/modules/page-modes/google-gqueues.js index 695d521..30ee341 100644 --- a/modules/page-modes/google-gqueues.js +++ b/modules/page-modes/google-gqueues.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -60,3 +62,5 @@ var google_gqueues_re = build_url_regex($domain = "gqueues", $allow_www = true, $path = "main"); auto_mode_list.push([google_gqueues_re, google_gqueues_mode]); + +provide("google-gqueues"); diff --git a/modules/page-modes/google-images.js b/modules/page-modes/google-images.js index 60a9965..37566e9 100644 --- a/modules/page-modes/google-images.js +++ b/modules/page-modes/google-images.js @@ -14,6 +14,8 @@ * annoying frameset page from google again! */ +in_module(null); + define_variable('google_images_imgrefurl_commands', ["follow", "follow-new-buffer", "follow-new-buffer-background", @@ -69,3 +71,5 @@ let (rx = build_url_regex($domain = "images.google", $path = "images")) { auto_mode_list.push([rx, google_images_mode]); }; + +provide("google-images"); diff --git a/modules/page-modes/google-maps.js b/modules/page-modes/google-maps.js index 41cc063..fa23b9d 100644 --- a/modules/page-modes/google-maps.js +++ b/modules/page-modes/google-maps.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -62,3 +64,5 @@ define_page_mode("google_maps_mode", var google_maps_re = build_url_regex($domain = "maps.google"); auto_mode_list.push([google_maps_re, google_maps_mode]); + +provide("google-maps"); diff --git a/modules/page-modes/google-reader.js b/modules/page-modes/google-reader.js index 6eb44aa..76ee79b 100644 --- a/modules/page-modes/google-reader.js +++ b/modules/page-modes/google-reader.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -73,3 +75,5 @@ var google_reader_re = build_url_regex($domain = "google", $allow_www = true, $path = "reader/"); auto_mode_list.push([google_reader_re, google_reader_mode]); + +provide("google-reader"); diff --git a/modules/page-modes/google-search-results.js b/modules/page-modes/google-search-results.js index d0bf819..d2be612 100644 --- a/modules/page-modes/google-search-results.js +++ b/modules/page-modes/google-search-results.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -87,3 +89,4 @@ let (google_search_re = build_url_regex( auto_mode_list.push([google_search_re, google_search_results_mode]); }; +provide("google-search-results"); diff --git a/modules/page-modes/google-video.js b/modules/page-modes/google-video.js index 295ba9d..004ad26 100644 --- a/modules/page-modes/google-video.js +++ b/modules/page-modes/google-video.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); require("media.js"); @@ -55,3 +57,5 @@ define_page_mode("google_video_mode", var google_video_re = build_url_regex($domain = "video.google"); auto_mode_list.push([google_video_re, google_video_mode]); + +provide("google-video"); diff --git a/modules/page-modes/google-voice.js b/modules/page-modes/google-voice.js index 726eb73..3d4c69a 100644 --- a/modules/page-modes/google-voice.js +++ b/modules/page-modes/google-voice.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); @@ -59,3 +61,5 @@ var google_voice_re = build_url_regex($domain = "google", $allow_www = true, $path = "voice"); auto_mode_list.push([google_voice_re, google_voice_mode]); + +provide("google-voice"); diff --git a/modules/page-modes/reddit.js b/modules/page-modes/reddit.js index c0491b0..24019d7 100644 --- a/modules/page-modes/reddit.js +++ b/modules/page-modes/reddit.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); define_variable("reddit_end_behavior", "stop", @@ -287,3 +289,5 @@ define_page_mode("reddit_mode", let (re = build_url_regex($domain = /([a-zA-Z0-9\-]*\.)*reddit/)) { auto_mode_list.push([re, reddit_mode]); }; + +provide("reddit"); diff --git a/modules/page-modes/stackoverflow.js b/modules/page-modes/stackoverflow.js index 62a09f6..2139029 100644 --- a/modules/page-modes/stackoverflow.js +++ b/modules/page-modes/stackoverflow.js @@ -10,6 +10,8 @@ * having to grab the mouse. */ +in_module(null); + /** * browser_object_class that finds the vote images */ @@ -48,3 +50,5 @@ define_page_mode("stackoverflow_mode", auto_mode_list.push([/^https?:\/\/(?:www.|meta.)?(stackoverflow|serverfault|superuser)\.(?:com)\//, stackoverflow_mode]); + +provide("stackoverflow"); diff --git a/modules/page-modes/wikipedia.js b/modules/page-modes/wikipedia.js index 48bd36d..51701b8 100644 --- a/modules/page-modes/wikipedia.js +++ b/modules/page-modes/wikipedia.js @@ -14,6 +14,8 @@ * - Probably more to come. **/ +in_module(null); + require("minibuffer-completion.js"); @@ -416,3 +418,5 @@ define_variable("wikipedia_versions", { // TODO: zh-min-nan - Min Nan "zu" : { language: "Zulu", search: "Special:Search?search=%s&go=Go" } }, "Wikipedia version information. The key is the language code for the Wikipedia."); + +provide("wikipedia"); diff --git a/modules/page-modes/xkcd.js b/modules/page-modes/xkcd.js index 8b6ad8b..ecc861a 100644 --- a/modules/page-modes/xkcd.js +++ b/modules/page-modes/xkcd.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); define_variable('xkcd_add_title', false, @@ -70,3 +72,5 @@ let (re = build_url_regex($domain = "xkcd", $path = /(\d+\/)?/)) { auto_mode_list.push([re, xkcd_mode]); } + +provide("xkcd"); diff --git a/modules/page-modes/youtube.js b/modules/page-modes/youtube.js index 2f8f24b..f3d12c8 100644 --- a/modules/page-modes/youtube.js +++ b/modules/page-modes/youtube.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); require("media.js"); @@ -193,3 +195,5 @@ let media_youtube_uri_test_regexp = build_url_regex($domain = /(?:[a-z]+\.)?yout media_scrapers.unshift([/.*/, media_scrape_embedded_youtube]); media_scrapers.unshift([media_youtube_uri_test_regexp, media_scrape_youtube]); auto_mode_list.push([media_youtube_uri_test_regexp, youtube_mode]); + +provide("youtube"); diff --git a/modules/permission-manager.js b/modules/permission-manager.js index ac6c5e8..3676709 100644 --- a/modules/permission-manager.js +++ b/modules/permission-manager.js @@ -10,6 +10,8 @@ * blocking whitelist, among other things. */ +in_module(null); + let permission_manager = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager); let permission_types = { @@ -278,3 +280,5 @@ interactive("permission-manager", "View or edit the host-specific " file.remove(false); } }); + +provide("permission-manager"); diff --git a/modules/pref.js b/modules/pref.js index 79133dd..17926b7 100644 --- a/modules/pref.js +++ b/modules/pref.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + function set_branch_pref (branch, name, value) { if (typeof(value) == "string") { branch.setCharPref(name, value); @@ -96,3 +98,4 @@ function watch_pref (pref, hook) { branch.addObserver("", observer, false); } +provide("pref"); diff --git a/modules/pretty-print.js b/modules/pretty-print.js index 26d4b2d..49acef6 100644 --- a/modules/pretty-print.js +++ b/modules/pretty-print.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + function pretty_print_value (value) { if (value === undefined) return "undefined"; @@ -77,3 +79,5 @@ function pretty_print_time (val) { return parts.join(", "); } + +provide("pretty-print"); diff --git a/modules/quote.js b/modules/quote.js index 0a42c1c..67bf30a 100644 --- a/modules/quote.js +++ b/modules/quote.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + define_input_mode("quote_next", "quote_next_keymap", $display_name = "input:QUOTE(next)", $doc = "This input mode sends the next key combo to the buffer, "+ @@ -44,3 +46,5 @@ define_key_match_predicate('match_not_escape_key', 'any key but escape', event.metaKey || // M-escape can also leave this mode, so we need to use an accurate determination of whether the "M" modifier was pressed, which is not necessarily the same as event.metaKey. event.ctrlKey; }); + +provide("quote"); diff --git a/modules/rc.js b/modules/rc.js index 882d6e9..4971063 100644 --- a/modules/rc.js +++ b/modules/rc.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + function load_rc_file (file) { try { var prefix = "file://"; @@ -112,3 +114,4 @@ function load_rc (path, resolve) { return path; } +provide("rc"); diff --git a/modules/save.js b/modules/save.js index f69ac2b..e71f051 100644 --- a/modules/save.js +++ b/modules/save.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + require("content-buffer.js"); require("load-spec.js"); require("suggest-file-name.js"); @@ -279,3 +281,5 @@ function download_as_temporary (lspec) { var result = yield SUSPEND; yield co_return(result); } + +provide("save"); diff --git a/modules/scroll.js b/modules/scroll.js index a8a32ef..f982978 100644 --- a/modules/scroll.js +++ b/modules/scroll.js @@ -7,6 +7,8 @@ **/ +in_module(null); + define_variable("headings_xpath", "//h1 | //h2 | //h3 | //h4 | //h5 | //h6 | //xhtml:h1 | "+ "//xhtml:h2 | //xhtml:h3 | //xhtml:h4 | //xhtml:h5 | //xhtml:h6", @@ -93,4 +95,4 @@ interactive("scroll", "if possible.", scroll); - +provide("scroll"); diff --git a/modules/search-engine.js b/modules/search-engine.js index f5f7328..a22a7f3 100644 --- a/modules/search-engine.js +++ b/modules/search-engine.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("utils.js"); var search_engines = new string_hashmap(); @@ -349,3 +351,5 @@ define_search_engine_webjump("answers.xml", "answers"); define_search_engine_webjump("yahoo.xml", "yahoo"); define_search_engine_webjump("creativecommons.xml", "creativecommons"); define_search_engine_webjump("eBay.xml", "ebay"); + +provide("search-engine"); diff --git a/modules/selectively-unstyle.js b/modules/selectively-unstyle.js index 28ee465..6ca95da 100644 --- a/modules/selectively-unstyle.js +++ b/modules/selectively-unstyle.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + define_variable('selectively_unstyle_alist', [], "Alist mapping url-matching regular expressions to predicates to "+ "selectively disable stylesheets. All predicates corresponding to "+ @@ -27,3 +29,4 @@ function selectively_unstyle (buffer) { add_hook("buffer_loaded_hook", selectively_unstyle); +provide("selectively-unstyle"); diff --git a/modules/services.js b/modules/services.js index dd9c86b..cd18768 100644 --- a/modules/services.js +++ b/modules/services.js @@ -13,6 +13,8 @@ * best, because it keeps all the code in one place. */ +in_module(null); + const file_locator_service = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIProperties); @@ -24,3 +26,5 @@ const nav_history_service = Cc["@mozilla.org/browser/nav-history-service;1"] const observer_service = Cc["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService); + +provide("services"); diff --git a/modules/session.js b/modules/session.js index 63a7dba..4801a45 100644 --- a/modules/session.js +++ b/modules/session.js @@ -32,6 +32,8 @@ * fail and return without telling the user why we are doing so. */ +in_module(null); + { //// Manual sessions. //// @@ -433,3 +435,5 @@ session_auto_save_mode(true); } + +provide("session"); diff --git a/modules/source-code.js b/modules/source-code.js index 42129b3..63d8faf 100644 --- a/modules/source-code.js +++ b/modules/source-code.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + require_later("external-editor.js"); var conkeror_source_code_path = null; @@ -69,3 +71,5 @@ function get_caller_source_code_reference (extra_frames_back) { function ignore_function_for_get_caller_source_code_reference (func_name) { get_caller_source_code_reference_ignored_functions[func_name] = 1; } + +provide("source-code"); diff --git a/modules/spawn-process.js b/modules/spawn-process.js index 8862cd1..0710a8d 100644 --- a/modules/spawn-process.js +++ b/modules/spawn-process.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("interactive.js"); require("io.js"); @@ -637,3 +639,5 @@ function shell_command (command) { function shell_command_with_argument (command, arg) { yield co_return((yield shell_command(substitute_shell_command_argument(command, arg), forward_keywords(arguments)))); } + +provide("spawn-process"); diff --git a/modules/special-buffer.js b/modules/special-buffer.js index 158b6d1..3b29dbd 100644 --- a/modules/special-buffer.js +++ b/modules/special-buffer.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("buffer.js"); function special_buffer (window, element) { @@ -26,3 +28,5 @@ function special_buffer (window, element) { special_buffer.prototype.__proto__ = buffer.prototype; // Sub-classes must define a generate method + +provide("special-buffer"); diff --git a/modules/ssl.js b/modules/ssl.js index d5dc641..e2a96bb 100644 --- a/modules/ssl.js +++ b/modules/ssl.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + function ssl_add_exception(buffer) { /* FIXME: A user preference variable should specify whether to * pre-fill location and furthermore (dependent on pre-filling the @@ -33,3 +35,5 @@ interactive("ssl-certificate-manager", "The certificate manager can be used to view, import, and export certificates" + " for Certificate Authorities (CA) as well as web sites.", ssl_certificate_manager); + +provide("ssl"); diff --git a/modules/string.js b/modules/string.js index 1c3d15b..9dc8b0d 100644 --- a/modules/string.js +++ b/modules/string.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + /** * trim_whitespace removes whitespace from the beginning and end of the * given string. @@ -134,3 +136,5 @@ function or_string (options) { return options.slice(0,options.length-1) .join(", ") + " or " + options[options.length - 1]; } + +provide("string"); diff --git a/modules/stylesheet.js b/modules/stylesheet.js index 7e82d6c..4230fdb 100644 --- a/modules/stylesheet.js +++ b/modules/stylesheet.js @@ -7,9 +7,8 @@ * COPYING file. **/ -/* - * Stylesheets - */ +in_module(null); + function register_user_stylesheet (url) { var uri = make_uri(url); var sss = Cc["@mozilla.org/content/style-sheet-service;1"] @@ -53,3 +52,5 @@ function user_stylesheet_registered_p (url) { .getService(Ci.nsIStyleSheetService); return sss.sheetRegistered(uri, sss.USER_SHEET); } + +provide("stylesheet"); diff --git a/modules/suggest-file-name.js b/modules/suggest-file-name.js index 6d85060..e957b59 100644 --- a/modules/suggest-file-name.js +++ b/modules/suggest-file-name.js @@ -9,6 +9,8 @@ * COPYING file. **/ +in_module(null); + /* maybe_get_filename_extension * * file_name_s: string filename, may be null. @@ -274,3 +276,5 @@ function suggest_save_path_from_file_name (file_name, buffer) { file.append(file_name); return file.path; } + +provide("suggest-file-name"); diff --git a/modules/tab-bar.js b/modules/tab-bar.js index 1ae5305..592c214 100644 --- a/modules/tab-bar.js +++ b/modules/tab-bar.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + require("mode.js"); function tab_bar (window) { @@ -139,3 +141,6 @@ define_global_mode("tab_bar_mode", }); tab_bar_mode(true); + +provide("new-tabs"); +provide("tab-bar.js"); diff --git a/modules/theme.js b/modules/theme.js index 81a01c8..af7d1da 100644 --- a/modules/theme.js +++ b/modules/theme.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + { let themes = {}; let loaded_themes = {}; @@ -75,8 +77,8 @@ let module = theme_cssfile_module(cssfile); if (! themes[module]) { themes[module] = {}; - if (! loaded(module+".js")) - call_after_load(module+".js", + if (! featurep(module)) + call_after_load(module, function () { theme_module(module); }); } if (! themes[module][cssfile]) @@ -84,7 +86,7 @@ if (themes[module][cssfile].length > 0) themes[module][cssfile][0].unregister(cssfile); themes[module][cssfile].unshift(th); - if (loaded(module+".js")) + if (featurep(module)) th.register(cssfile); } } @@ -114,3 +116,4 @@ theme_load("default"); +provide("theme"); diff --git a/modules/timer.js b/modules/timer.js index 06c3db0..9f0d5ac 100644 --- a/modules/timer.js +++ b/modules/timer.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + function timer_callback (callback) { this.callback = callback; } @@ -37,3 +39,5 @@ function call_at_precise_interval (callback, interval) { function timer_cancel (timer) { timer.cancel(); } + +provide("timer"); diff --git a/modules/universal-argument.js b/modules/universal-argument.js index 2ebcd95..82a6e5f 100644 --- a/modules/universal-argument.js +++ b/modules/universal-argument.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + define_keymap("universal_argument_keymap"); interactive("universal-argument", @@ -51,3 +53,4 @@ interactive("universal-negate", }, $prefix = true); +provide("universal-argument"); diff --git a/modules/user-variable.js b/modules/user-variable.js index 3f6c4b0..97ca174 100644 --- a/modules/user-variable.js +++ b/modules/user-variable.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + require("source-code.js"); var user_variables = {}; @@ -31,3 +33,5 @@ function define_special_variable (name, getter, setter, doc) { source_code_reference: get_caller_source_code_reference() }; } + +provide("user-variable"); diff --git a/modules/utils.js b/modules/utils.js index a4c662b..6225c91 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + function string_hashset () {} string_hashset.prototype = { @@ -125,16 +127,6 @@ function make_file (path) { } -function make_uri (uri, charset, base_uri) { - const io_service = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService2); - if (uri instanceof Ci.nsIURI) - return uri; - if (uri instanceof Ci.nsIFile) - return io_service.newFileURI(uri); - return io_service.newURI(uri, charset, base_uri); -} - function make_file_from_chrome (url) { var crs = Cc['@mozilla.org/chrome/chrome-registry;1'] .getService(Ci.nsIChromeRegistry); @@ -886,3 +878,5 @@ function do_when (hook, buffer, fun) { else fun(buffer); } + +provide("utils"); diff --git a/modules/walnut.js b/modules/walnut.js index 8cb3048..078d19b 100644 --- a/modules/walnut.js +++ b/modules/walnut.js @@ -5,6 +5,8 @@ * COPYING file. **/ +in_module(null); + function assert (got) { if (! got) throw new Error("expected a true value, got <"+got+">."); @@ -87,3 +89,4 @@ function walnut_run (suite) { return results; } +provide("walnut"); diff --git a/modules/webjump.js b/modules/webjump.js index 0e71c04..959ba2a 100644 --- a/modules/webjump.js +++ b/modules/webjump.js @@ -7,6 +7,8 @@ * COPYING file. **/ +in_module(null); + var webjumps = {}; define_keywords("$completer", "$description", "$argument", "$alternative"); @@ -209,3 +211,5 @@ function webjump_completer () { yield co_return(base_completer(input, pos, conservative)); }; } + +provide("webjump"); diff --git a/modules/window.js b/modules/window.js index 8c7fc46..397c7a4 100644 --- a/modules/window.js +++ b/modules/window.js @@ -6,6 +6,8 @@ * COPYING file. **/ +in_module(null); + require("mode.js"); var define_window_local_hook = simple_local_hook_definer(); @@ -269,3 +271,5 @@ function init_window_title () { } init_window_title(); + +provide("window"); diff --git a/modules/zoom.js b/modules/zoom.js index e7de245..9f50c63 100644 --- a/modules/zoom.js +++ b/modules/zoom.js @@ -12,6 +12,7 @@ * Text and full-page zoom */ +in_module(null); var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100, 120, 150, 200, 300, 500, 1000, 2000 ]; @@ -70,3 +71,5 @@ interactive("zoom-out-full", null, function (I) {browser_zoom_change(I.buffer, t interactive("zoom-in-full-more", null, function (I) {browser_zoom_change(I.buffer, true /* full zoom */, I.p * 3);}); interactive("zoom-out-full-more", null, function (I) {browser_zoom_change(I.buffer, true /* full zoom */, -I.p * 3);}); interactive("zoom-reset-full", null, function (I) {browser_zoom_set(I.buffer, true /* full zoom */, I.p = 100);}); + +provide("zoom"); diff --git a/tests/simple/modules.js b/tests/simple/modules.js dissimilarity index 69% index 1cb87f2..87545d5 100644 --- a/tests/simple/modules.js +++ b/tests/simple/modules.js @@ -1,16 +1,279 @@ - -require('walnut.js'); - -walnut_run({ - test_module_loaded_1: function () { - assert(! loaded("non-existent module")); - }, - test_module_loaded_2: function () { - assert(loaded("buffer.js")); - }, - test_call_after_load_1: function () { - let a = 0; - call_after_load("buffer.js", function () { a = 1; }); - assert_equals(a, 1, "call_after_load 1"); - } -}); + +require('walnut.js'); + +walnut_run({ + test_featurep_1: function () { + assert(! featurep("non-existent module")); + }, + test_featurep_2: function () { + assert(featurep("conkeror")); + }, + test_call_after_load_1: function () { + let a = 0; + call_after_load("conkeror", function () { a = 1; }); + assert_equals(a, 1); + } +}); + + +walnut_run({ + suite_setup: function () { + this._load_paths = load_paths; + this._load_url = load_url; + var suite = this; + load_url = function (url) { + suite.ob.push(url); //initialized for each test in suite.setup + throw "Error opening input stream (invalid filename?)"; + }; + }, + suite_teardown: function () { + load_paths = this._load_paths; + load_url = this._load_url; + }, + setup: function () { + this.ob = []; + }, + test_load_search_1__sans_extension: function () { + load_paths = ["chrome://conkeror/content/", + "chrome://conkeror/content/extensions", + "chrome://conkeror/content/page-modes"]; + try { + load("foo"); + } catch (e) { + } + assert_objects_equal( + ["chrome://conkeror/content/foo", + "chrome://conkeror/content/foo.js", + "chrome://conkeror/content/extensions/foo", + "chrome://conkeror/content/extensions/foo.js", + "chrome://conkeror/content/page-modes/foo", + "chrome://conkeror/content/page-modes/foo.js"], + this.ob.slice(-6)); + }, + test_load_search_2__with_extension: function () { + load_paths = ["chrome://conkeror/content/", + "chrome://conkeror/content/extensions", + "chrome://conkeror/content/page-modes"]; + try { + load("foo.js"); + } catch (e) { + } + assert_objects_equal( + ["chrome://conkeror/content/foo.js", + "chrome://conkeror/content/extensions/foo.js", + "chrome://conkeror/content/page-modes/foo.js"], + this.ob.slice(-3)); + }, + test_load_search_3__load_path_dups: function () { + load_paths = ["chrome://conkeror/content/", + "chrome://conkeror/content/extensions", + "chrome://conkeror/content/extensions/", + "chrome://conkeror/content/page-modes"]; + try { + load("foo.js"); + } catch (e) { + } + assert_objects_equal( + ["chrome://conkeror/content/foo.js", + "chrome://conkeror/content/extensions/foo.js", + "chrome://conkeror/content/page-modes/foo.js"], + this.ob.slice(-3)); + } +}); + + +walnut_run({ + suite_setup: function () { + this._load_paths = load_paths; + this._loading_paths = loading_paths; + this._loading_urls = loading_urls; + this._loading_modules = loading_modules; + this._loading_features = loading_features; + this._pending_loads = pending_loads; + this._features = features; + this._after_load_functions = after_load_functions; + }, + teardown: function () { + load_paths = this._load_paths; + loading_paths = this._loading_paths; + loading_urls = this._loading_urls; + loading_modules = this._loading_modules; + loading_features = this._loading_features; + pending_loads = this._pending_loads; + features = this._features; + after_load_functions = this._after_load_functions; + }, + test_load__in_module_conflict_1: function () { + load_url = function () { + in_module(null); + in_module("bar"); + }; + var err; + try { + load("foo"); + } catch (e) { + err = e; + } + assert(err instanceof module_assert_conflict_error); + }, + test_load__in_module_conflict_2: function () { + load_url = function () { + in_module(null); + in_module("bar"); + }; + var err; + try { + load(make_uri("chrome://conkeror/content/foo.js")); + } catch (e) { + err = e; + } + assert(err instanceof module_assert_conflict_error); + }, + test_load__circular_load_is_error: function () { + load_url = function () { + load(make_uri("chrome://conkeror/content/foo.js")); + }; + assert_error(function () { + load(make_uri("chrome://conkeror/content/foo.js")); + }); + }, + test_load__not_found_is_error: function () { + load_paths = []; + loading_paths = []; + loading_urls = []; + loading_modules = []; + loading_features = []; + pending_loads = []; + assert_error(function () load("foo")); + }, + test_require_later_1: function () { + var ob = ""; + function mock_foo () { + in_module(null); + ob += "a"; + require_later("bar"); + ob += "b"; + load_url = mock_bar; + } + function mock_bar () { + in_module(null); + ob += "c"; + } + load_url = mock_foo; + load("foo"); + assert_equals(ob, "abc"); + }, + test_require_later_2: function () { + loading_paths = []; + loading_urls = []; + loading_modules = []; + loading_features = []; + pending_loads = []; + after_load_functions = []; + features = {}; + var ob = []; + var mock_modules = { + foo: function () { + in_module(null); + ob.push("foo"); + require_later("baz"); + require("bar"); + provide("foo"); + }, + bar: function () { + in_module(null); + ob.push("bar"); + provide("bar"); + }, + baz: function () { + in_module(null); + ob.push("baz"); + require_later("quux"); + provide("baz"); + }, + quux: function () { + in_module(null); + ob.push("quux"); + provide("quux"); + } + }; + load_url = function (url) { + var module = url.substr(url.lastIndexOf('/')+1); + mock_modules[module](); + }; + load("foo"); + assert_objects_equal(ob, ["foo", "bar", "baz", "quux"]); + }, + test_provide__load_order: function () { + // want to make sure that after_load_functions only get called + // after the completion of the load which provided the feature. + loading_paths = []; + loading_urls = []; + loading_modules = []; + loading_features = []; + pending_loads = []; + after_load_functions = []; + features = {}; + + var oldfoo = conkeror.foo; + + var called = false; + var mock_modules = { + foo: function () { + in_module("foo"); + called = true; + provide("foo"); + assert_not(featurep("foo")); + } + }; + load_url = function (url) { + var module = url.substr(url.lastIndexOf('/')+1); + mock_modules[module](); + }; + load("foo"); + assert(called); + assert(featurep("foo")); + + conkeror.foo = oldfoo; + }, + test_call_after_load: function () { + loading_paths = []; + loading_urls = []; + loading_modules = []; + loading_features = []; + pending_loads = []; + after_load_functions = []; + features = {}; + + var oldfoo = conkeror.foo; + + var mock_modules = { + foo: function () { + in_module("foo"); + provide("foo"); + } + }; + load_url = function (url) { + var module = url.substr(url.lastIndexOf('/')+1); + mock_modules[module](); + }; + call_after_load("foo", function () { + foo.called = true; + }); + load("foo"); + assert(foo.called); + + conkeror.foo = oldfoo; + }, + test_provide: function () { + loading_paths = []; + loading_urls = []; + loading_modules = []; + loading_features = []; + pending_loads = []; + after_load_functions = []; + features = {}; + provide("foo"); + assert(featurep("foo")); + } +}); -- 2.11.4.GIT