testing/xpcshell/example/unit/test_import_module.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/xpcshell/example/unit/test_import_module.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,22 @@
     1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/**
    1.11 + * Ensures that tests can import a module in the same folder through:
    1.12 + * Components.utils.import("resource://test/module.jsm");
    1.13 + */
    1.14 +
    1.15 +function run_test() {
    1.16 +  do_check_true(typeof(this['MODULE_IMPORTED']) == "undefined");
    1.17 +  do_check_true(typeof(this['MODULE_URI']) == "undefined");
    1.18 +  let uri = "resource://test/import_module.jsm";
    1.19 +  Components.utils.import(uri);
    1.20 +  do_check_true(MODULE_URI == uri);
    1.21 +  do_check_true(MODULE_IMPORTED);
    1.22 +  do_check_true(SUBMODULE_IMPORTED);
    1.23 +  do_check_true(same_scope);
    1.24 +  do_check_true(SUBMODULE_IMPORTED_TO_SCOPE);
    1.25 +}

mercurial