1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/test/browser_sdk_loader_js_modules.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +function test () { 1.5 + let loader = makeLoader(); 1.6 + let module = Module("./main", gTestPath); 1.7 + let require = Require(loader, module); 1.8 + 1.9 + try { 1.10 + let Model = require("./cant-find-me"); 1.11 + ok(false, "requiring a JS module that doesn't exist should throw"); 1.12 + } 1.13 + catch (e) { 1.14 + ok(e, "requiring a JS module that doesn't exist should throw"); 1.15 + } 1.16 + 1.17 + 1.18 + /* 1.19 + * Relative resource:// URI of JS 1.20 + */ 1.21 + 1.22 + let { square } = require("./math"); 1.23 + is(square(5), 25, "loads relative URI of JS"); 1.24 + 1.25 + /* 1.26 + * Absolute resource:// URI of JS 1.27 + */ 1.28 + 1.29 + let { has } = require("resource://gre/modules/commonjs/sdk/util/array"); 1.30 + let testArray = ['rock', 'paper', 'scissors']; 1.31 + 1.32 + ok(has(testArray, 'rock'), "loads absolute resource:// URI of JS"); 1.33 + ok(!has(testArray, 'dragon'), "loads absolute resource:// URI of JS"); 1.34 + 1.35 + finish(); 1.36 +}