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_modules = loading_modules;
25 this._loading_features = loading_features;
26 this._pending_loads = pending_loads;
27 this._features = features;
28 this._after_load_functions = after_load_functions;
29 this._load_url = load_url;
31 load_url = function (url) {
32 suite.ob.push(url); //initialized for each test in suite.setup
33 throw "Error opening input stream (invalid filename?)";
36 suite_teardown: function () {
37 load_paths = this._load_paths;
38 load_url = this._load_url;
39 loading_paths = this._loading_paths;
40 loading_urls = this._loading_urls;
41 loading_modules = this._loading_modules;
42 loading_features = this._loading_features;
43 pending_loads = this._pending_loads;
44 features = this._features;
45 after_load_functions = this._after_load_functions;
51 test_load_search_1__sans_extension: function () {
52 load_paths = ["chrome://conkeror/content/",
53 "chrome://conkeror/content/extensions",
54 "chrome://conkeror/content/page-modes"];
60 ["chrome://conkeror/content/foo",
61 "chrome://conkeror/content/foo.js",
62 "chrome://conkeror/content/extensions/foo",
63 "chrome://conkeror/content/extensions/foo.js",
64 "chrome://conkeror/content/page-modes/foo",
65 "chrome://conkeror/content/page-modes/foo.js"],
68 test_load_search_2__with_extension: function () {
69 load_paths = ["chrome://conkeror/content/",
70 "chrome://conkeror/content/extensions",
71 "chrome://conkeror/content/page-modes"];
77 ["chrome://conkeror/content/foo.js",
78 "chrome://conkeror/content/extensions/foo.js",
79 "chrome://conkeror/content/page-modes/foo.js"],
82 test_load_search_3__load_path_dups: function () {
83 load_paths = ["chrome://conkeror/content/",
84 "chrome://conkeror/content/extensions",
85 "chrome://conkeror/content/extensions/",
86 "chrome://conkeror/content/page-modes"];
92 ["chrome://conkeror/content/foo.js",
93 "chrome://conkeror/content/extensions/foo.js",
94 "chrome://conkeror/content/page-modes/foo.js"],
97 test_load_search_4__require_skips_cur_dir: function () {
98 loading_paths = ["file:///foo/bar/baz/"];
99 load_paths = ["chrome://conkeror/content/"];
104 assert_objects_equal(
105 ["chrome://conkeror/content/foo.js"],
108 test_load_search_5__relative_path: function () {
109 load_paths = ["chrome://conkeror/content/",
110 "chrome://conkeror/content/extensions",
111 "chrome://conkeror/content/page-modes"];
113 load("page-modes/foo");
116 assert_objects_equal(
118 ["chrome://conkeror/content/page-modes/foo",
119 "chrome://conkeror/content/page-modes/foo.js",
120 "chrome://conkeror/content/extensions/page-modes/foo",
121 "chrome://conkeror/content/extensions/page-modes/foo.js",
122 "chrome://conkeror/content/page-modes/page-modes/foo",
123 "chrome://conkeror/content/page-modes/page-modes/foo.js"]);
129 suite_setup: function () {
130 this._load_paths = load_paths;
131 this._loading_paths = loading_paths;
132 this._loading_urls = loading_urls;
133 this._loading_modules = loading_modules;
134 this._loading_features = loading_features;
135 this._pending_loads = pending_loads;
136 this._features = features;
137 this._after_load_functions = after_load_functions;
138 this._load_url = load_url;
140 teardown: function () {
141 load_paths = this._load_paths;
142 load_url = this._load_url;
143 loading_paths = this._loading_paths;
144 loading_urls = this._loading_urls;
145 loading_modules = this._loading_modules;
146 loading_features = this._loading_features;
147 pending_loads = this._pending_loads;
148 features = this._features;
149 after_load_functions = this._after_load_functions;
151 test_load__in_module_conflict_1: function () {
152 load_url = function () {
162 assert(err instanceof module_assert_conflict_error);
164 test_load__in_module_conflict_2: function () {
165 load_url = function () {
171 load(make_uri("chrome://conkeror/content/foo.js"));
175 assert(err instanceof module_assert_conflict_error);
177 test_load__circular_load_is_error: function () {
178 load_url = function () {
179 load(make_uri("chrome://conkeror/content/foo.js"));
181 assert_error(function () {
182 load(make_uri("chrome://conkeror/content/foo.js"));
185 test_load__not_found_is_error: function () {
189 loading_modules = [];
190 loading_features = [];
192 assert_error(function () load("foo"));
194 test_require_later_1: function () {
198 function mock_foo () {
201 require_later("bar");
205 function mock_bar () {
211 assert_equals(ob, "abc");
213 test_require_later_2: function () {
216 loading_modules = [];
217 loading_features = [];
219 after_load_functions = [];
226 require_later("baz");
238 require_later("quux");
247 load_url = function (url) {
248 var module = url.substr(url.lastIndexOf('/')+1);
249 mock_modules[module]();
252 assert_objects_equal(ob, ["foo", "bar", "baz", "quux"]);
254 test_provide__load_order: function () {
255 // want to make sure that after_load_functions only get called
256 // after the completion of the load which provided the feature.
259 loading_modules = [];
260 loading_features = [];
262 after_load_functions = [];
265 var oldfoo = conkeror.foo;
273 assert_not(featurep("foo"));
276 load_url = function (url) {
277 var module = url.substr(url.lastIndexOf('/')+1);
278 mock_modules[module]();
282 assert(featurep("foo"));
284 conkeror.foo = oldfoo;
286 test_call_after_load: function () {
289 loading_modules = [];
290 loading_features = [];
292 after_load_functions = [];
295 var oldfoo = conkeror.foo;
303 load_url = function (url) {
304 var module = url.substr(url.lastIndexOf('/')+1);
305 mock_modules[module]();
307 call_after_load("foo", function () {
313 conkeror.foo = oldfoo;
315 test_provide: function () {
318 loading_modules = [];
319 loading_features = [];
321 after_load_functions = [];
324 assert(featurep("foo"));
326 test_load_relative_of_nsIURI: function () {
328 load_url = function (url) {
329 if (url == "chrome://conkeror/content/foo.js") {
335 load(make_uri("chrome://conkeror/content/foo.js"));
336 assert_equals(tried, "chrome://conkeror/content/bar.js");