michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Module used by test_import_module.js michael@0: michael@0: const EXPORTED_SYMBOLS = [ "MODULE_IMPORTED", "MODULE_URI", "SUBMODULE_IMPORTED", "same_scope", "SUBMODULE_IMPORTED_TO_SCOPE" ]; michael@0: michael@0: const MODULE_IMPORTED = true; michael@0: const MODULE_URI = __URI__; michael@0: michael@0: // Will import SUBMODULE_IMPORTED into scope. michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: XPCOMUtils.importRelative(this, "import_sub_module.jsm"); michael@0: michael@0: // Prepare two scopes that we can import the submodule into. michael@0: var scope1 = { __URI__: __URI__ }; michael@0: var scope2 = { __URI__: __URI__ }; michael@0: // First one is the regular path. michael@0: XPCOMUtils.importRelative(scope1, "import_sub_module.jsm"); michael@0: scope1.test_obj.i++; michael@0: // Second one is with a different path (leads to the same file). michael@0: XPCOMUtils.importRelative(scope2, "duh/../import_sub_module.jsm"); michael@0: // test_obj belongs to import_sub_module.jsm and has a mutable field name i, if michael@0: // the two modules are actually the same, then they'll share the same value. michael@0: // We'll leave it up to test_import_module.js to check that this variable is michael@0: // true. michael@0: var same_scope = (scope1.test_obj.i == scope2.test_obj.i); michael@0: michael@0: // Check that importRelative can also import into a given scope michael@0: var testScope = {}; michael@0: XPCOMUtils.importRelative(this, "import_sub_module.jsm", testScope); michael@0: var SUBMODULE_IMPORTED_TO_SCOPE = testScope.SUBMODULE_IMPORTED; michael@0: