dom/payment/tests/unit/header_helper.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:2702b3dc9243
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 "use strict";
5
6 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
7
8 let subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
9 .getService(Ci.mozIJSSubScriptLoader);
10
11 /**
12 * Start a new payment module.
13 *
14 * @param custom_ns
15 * Namespace with symbols to be injected into the new payment module
16 * namespace.
17 *
18 * @return an object that represents the payment module's namespace.
19 */
20 function newPaymentModule(custom_ns) {
21 let payment_ns = {
22 importScripts: function fakeImportScripts() {
23 Array.slice(arguments).forEach(function (script) {
24 subscriptLoader.loadSubScript("resource://gre/modules/" + script, this);
25 }, this);
26 },
27 };
28
29 // Copy the custom definitions over.
30 for (let key in custom_ns) {
31 payment_ns[key] = custom_ns[key];
32 }
33
34 // Load the payment module itself.
35 payment_ns.importScripts("Payment.jsm");
36
37 return payment_ns;
38 }

mercurial