5 test_featurep_1: function () {
6 assert(! featurep("non-existent module"));
8 test_featurep_2: function () {
9 assert(featurep("conkeror"));
11 test_call_after_load_1: function () {
13 call_after_load("conkeror", function () { a = 1; });
20 suite_setup: function () {
21 this._load_paths = load_paths;
22 this._loading_paths = loading_paths;
23 this._loading_urls = loading_urls;
24 this._loading_features = loading_features;
25 this._pending_loads = pending_loads;
26 this._features = features;
27 this._after_load_functions = after_load_functions;
28 this._load_url = load_url;
30 load_url = function (url) {
31 suite.ob.push(url); //initialized for each test in suite.setup
32 throw "Error opening input stream (invalid filename?)";
35 suite_teardown: function () {
36 load_paths = this._load_paths;
37 load_url = this._load_url;
38 loading_paths = this._loading_paths;
39 loading_urls = this._loading_urls;
40 loading_features = this._loading_features;
41 pending_loads = this._pending_loads;
42 features = this._features;
43 after_load_functions = this._after_load_functions;
49 test_load_search_1__sans_extension: function () {
50 load_paths = ["chrome://conkeror/content/",
51 "chrome://conkeror/content/extensions",
52 "chrome://conkeror/content/page-modes"];
58 ["chrome://conkeror/content/foo",
59 "chrome://conkeror/content/foo.js",
60 "chrome://conkeror/content/extensions/foo",
61 "chrome://conkeror/content/extensions/foo.js",
62 "chrome://conkeror/content/page-modes/foo",
63 "chrome://conkeror/content/page-modes/foo.js"],
66 test_load_search_2__with_extension: function () {
67 load_paths = ["chrome://conkeror/content/",
68 "chrome://conkeror/content/extensions",
69 "chrome://conkeror/content/page-modes"];
75 ["chrome://conkeror/content/foo.js",
76 "chrome://conkeror/content/extensions/foo.js",
77 "chrome://conkeror/content/page-modes/foo.js"],
80 test_load_search_3__load_path_dups: function () {
81 load_paths = ["chrome://conkeror/content/",
82 "chrome://conkeror/content/extensions",
83 "chrome://conkeror/content/extensions/",
84 "chrome://conkeror/content/page-modes"];
90 ["chrome://conkeror/content/foo.js",
91 "chrome://conkeror/content/extensions/foo.js",
92 "chrome://conkeror/content/page-modes/foo.js"],
95 test_load_search_4__require_skips_cur_dir: function () {
96 loading_paths = ["file:///foo/bar/baz/"];
97 load_paths = ["chrome://conkeror/content/"];
102 assert_objects_equal(
103 ["chrome://conkeror/content/foo.js"],
106 test_load_search_5__relative_path: function () {
107 load_paths = ["chrome://conkeror/content/",
108 "chrome://conkeror/content/extensions",
109 "chrome://conkeror/content/page-modes"];
111 load("page-modes/foo");
114 assert_objects_equal(
116 ["chrome://conkeror/content/page-modes/foo",
117 "chrome://conkeror/content/page-modes/foo.js",
118 "chrome://conkeror/content/extensions/page-modes/foo",
119 "chrome://conkeror/content/extensions/page-modes/foo.js",
120 "chrome://conkeror/content/page-modes/page-modes/foo",
121 "chrome://conkeror/content/page-modes/page-modes/foo.js"]);
127 suite_setup: function () {
128 this._load_paths = load_paths;
129 this._loading_paths = loading_paths;
130 this._loading_urls = loading_urls;
131 this._loading_features = loading_features;
132 this._pending_loads = pending_loads;
133 this._features = features;
134 this._after_load_functions = after_load_functions;
135 this._load_url = load_url;
137 teardown: function () {
138 load_paths = this._load_paths;
139 load_url = this._load_url;
140 loading_paths = this._loading_paths;
141 loading_urls = this._loading_urls;
142 loading_features = this._loading_features;
143 pending_loads = this._pending_loads;
144 features = this._features;
145 after_load_functions = this._after_load_functions;
147 test_load__circular_load_is_error: function () {
148 load_url = function () {
149 load(make_uri("chrome://conkeror/content/foo.js"));
151 assert_error(function () {
152 load(make_uri("chrome://conkeror/content/foo.js"));
155 test_load__not_found_is_error: function () {
159 loading_features = [];
161 assert_error(function () load("foo"));
163 test_require_later_1: function () {
167 function mock_foo () {
169 require_later("bar");
173 function mock_bar () {
178 assert_equals(ob, "abc");
180 test_require_later_2: function () {
183 loading_features = [];
185 after_load_functions = [];
191 require_later("baz");
201 require_later("quux");
209 load_url = function (url) {
210 var module = url.substr(url.lastIndexOf('/')+1);
211 mock_modules[module]();
214 assert_objects_equal(ob, ["foo", "bar", "baz", "quux"]);
216 test_provide__load_order: function () {
217 // want to make sure that after_load_functions only get called
218 // after the completion of the load which provided the feature.
221 loading_features = [];
223 after_load_functions = [];
231 assert_not(featurep("foo"));
234 load_url = function (url) {
235 var module = url.substr(url.lastIndexOf('/')+1);
236 mock_modules[module]();
240 assert(featurep("foo"));
242 test_provide: function () {
245 loading_features = [];
247 after_load_functions = [];
250 assert(featurep("foo"));
252 test_load_relative_of_nsIURI: function () {
254 load_url = function (url) {
255 if (url == "chrome://conkeror/content/foo.js") {
261 load(make_uri("chrome://conkeror/content/foo.js"));
262 assert_equals(tried, "chrome://conkeror/content/bar.js");