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/foo.jsx",
61 "chrome://conkeror/content/extensions/foo",
62 "chrome://conkeror/content/extensions/foo.js",
63 "chrome://conkeror/content/extensions/foo.jsx",
64 "chrome://conkeror/content/page-modes/foo",
65 "chrome://conkeror/content/page-modes/foo.js",
66 "chrome://conkeror/content/page-modes/foo.jsx"],
69 test_load_search_2__with_extension: function () {
70 load_paths = ["chrome://conkeror/content/",
71 "chrome://conkeror/content/extensions",
72 "chrome://conkeror/content/page-modes"];
78 ["chrome://conkeror/content/foo.js",
79 "chrome://conkeror/content/extensions/foo.js",
80 "chrome://conkeror/content/page-modes/foo.js"],
83 test_load_search_3__load_path_dups: function () {
84 load_paths = ["chrome://conkeror/content/",
85 "chrome://conkeror/content/extensions",
86 "chrome://conkeror/content/extensions/",
87 "chrome://conkeror/content/page-modes"];
93 ["chrome://conkeror/content/foo.js",
94 "chrome://conkeror/content/extensions/foo.js",
95 "chrome://conkeror/content/page-modes/foo.js"],
98 test_load_search_4__require_skips_cur_dir: function () {
99 loading_paths = ["file:///foo/bar/baz/"];
100 load_paths = ["chrome://conkeror/content/"];
105 assert_objects_equal(
106 ["chrome://conkeror/content/foo.js"],
109 test_load_search_5__relative_path: function () {
110 load_paths = ["chrome://conkeror/content/",
111 "chrome://conkeror/content/extensions",
112 "chrome://conkeror/content/page-modes"];
114 load("page-modes/foo");
117 assert_objects_equal(
119 ["chrome://conkeror/content/page-modes/foo",
120 "chrome://conkeror/content/page-modes/foo.js",
121 "chrome://conkeror/content/page-modes/foo.jsx",
122 "chrome://conkeror/content/extensions/page-modes/foo",
123 "chrome://conkeror/content/extensions/page-modes/foo.js",
124 "chrome://conkeror/content/extensions/page-modes/foo.jsx",
125 "chrome://conkeror/content/page-modes/page-modes/foo",
126 "chrome://conkeror/content/page-modes/page-modes/foo.js",
127 "chrome://conkeror/content/page-modes/page-modes/foo.jsx"]);
133 suite_setup: function () {
134 this._load_paths = load_paths;
135 this._loading_paths = loading_paths;
136 this._loading_urls = loading_urls;
137 this._loading_features = loading_features;
138 this._pending_loads = pending_loads;
139 this._features = features;
140 this._after_load_functions = after_load_functions;
141 this._load_url = load_url;
143 teardown: function () {
144 load_paths = this._load_paths;
145 load_url = this._load_url;
146 loading_paths = this._loading_paths;
147 loading_urls = this._loading_urls;
148 loading_features = this._loading_features;
149 pending_loads = this._pending_loads;
150 features = this._features;
151 after_load_functions = this._after_load_functions;
153 test_load__circular_load_is_error: function () {
154 load_url = function () {
155 load(make_uri("chrome://conkeror/content/foo.js"));
157 assert_error(function () {
158 load(make_uri("chrome://conkeror/content/foo.js"));
161 test_load__not_found_is_error: function () {
165 loading_features = [];
167 assert_error(function () load("foo"));
169 test_require_later_1: function () {
173 function mock_foo () {
175 require_later("bar");
179 function mock_bar () {
184 assert_equals(ob, "abc");
186 test_require_later_2: function () {
189 loading_features = [];
191 after_load_functions = [];
197 require_later("baz");
207 require_later("quux");
215 load_url = function (url) {
216 var module = url.substr(url.lastIndexOf('/')+1);
217 mock_modules[module]();
220 assert_objects_equal(ob, ["foo", "bar", "baz", "quux"]);
222 test_provide__load_order: function () {
223 // want to make sure that after_load_functions only get called
224 // after the completion of the load which provided the feature.
227 loading_features = [];
229 after_load_functions = [];
237 assert_not(featurep("foo"));
240 load_url = function (url) {
241 var module = url.substr(url.lastIndexOf('/')+1);
242 mock_modules[module]();
246 assert(featurep("foo"));
248 test_provide: function () {
251 loading_features = [];
253 after_load_functions = [];
256 assert(featurep("foo"));
258 test_load_relative_of_nsIURI: function () {
260 load_url = function (url) {
261 if (url == "chrome://conkeror/content/foo.js") {
267 load(make_uri("chrome://conkeror/content/foo.js"));
268 assert_equals(tried, "chrome://conkeror/content/bar.js");
270 test_load_relative_path_nested: function () {
273 loading_features = [];
275 after_load_functions = [];
284 assert(loading_paths[0].indexOf("some-path/deeper") > 0);
288 load_url = function (url) {
289 var module = url.substr(url.lastIndexOf('/')+1);
290 mock_modules[module]();
292 load("some-path/foo");
293 assert(featurep("foo"));
294 assert(featurep("bar"));