addon-sdk/test/browser_sdk_loader_js_modules.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:6f76e55ce7fd
1 function test () {
2 let loader = makeLoader();
3 let module = Module("./main", gTestPath);
4 let require = Require(loader, module);
5
6 try {
7 let Model = require("./cant-find-me");
8 ok(false, "requiring a JS module that doesn't exist should throw");
9 }
10 catch (e) {
11 ok(e, "requiring a JS module that doesn't exist should throw");
12 }
13
14
15 /*
16 * Relative resource:// URI of JS
17 */
18
19 let { square } = require("./math");
20 is(square(5), 25, "loads relative URI of JS");
21
22 /*
23 * Absolute resource:// URI of JS
24 */
25
26 let { has } = require("resource://gre/modules/commonjs/sdk/util/array");
27 let testArray = ['rock', 'paper', 'scissors'];
28
29 ok(has(testArray, 'rock'), "loads absolute resource:// URI of JS");
30 ok(!has(testArray, 'dragon'), "loads absolute resource:// URI of JS");
31
32 finish();
33 }

mercurial