michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; michael@0: michael@0: let subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"] michael@0: .getService(Ci.mozIJSSubScriptLoader); michael@0: michael@0: /** michael@0: * Start a new payment module. michael@0: * michael@0: * @param custom_ns michael@0: * Namespace with symbols to be injected into the new payment module michael@0: * namespace. michael@0: * michael@0: * @return an object that represents the payment module's namespace. michael@0: */ michael@0: function newPaymentModule(custom_ns) { michael@0: let payment_ns = { michael@0: importScripts: function fakeImportScripts() { michael@0: Array.slice(arguments).forEach(function (script) { michael@0: subscriptLoader.loadSubScript("resource://gre/modules/" + script, this); michael@0: }, this); michael@0: }, michael@0: }; michael@0: michael@0: // Copy the custom definitions over. michael@0: for (let key in custom_ns) { michael@0: payment_ns[key] = custom_ns[key]; michael@0: } michael@0: michael@0: // Load the payment module itself. michael@0: payment_ns.importScripts("Payment.jsm"); michael@0: michael@0: return payment_ns; michael@0: }