1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/payment/tests/unit/header_helper.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; 1.10 + 1.11 +let subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"] 1.12 + .getService(Ci.mozIJSSubScriptLoader); 1.13 + 1.14 +/** 1.15 + * Start a new payment module. 1.16 + * 1.17 + * @param custom_ns 1.18 + * Namespace with symbols to be injected into the new payment module 1.19 + * namespace. 1.20 + * 1.21 + * @return an object that represents the payment module's namespace. 1.22 + */ 1.23 +function newPaymentModule(custom_ns) { 1.24 + let payment_ns = { 1.25 + importScripts: function fakeImportScripts() { 1.26 + Array.slice(arguments).forEach(function (script) { 1.27 + subscriptLoader.loadSubScript("resource://gre/modules/" + script, this); 1.28 + }, this); 1.29 + }, 1.30 + }; 1.31 + 1.32 + // Copy the custom definitions over. 1.33 + for (let key in custom_ns) { 1.34 + payment_ns[key] = custom_ns[key]; 1.35 + } 1.36 + 1.37 + // Load the payment module itself. 1.38 + payment_ns.importScripts("Payment.jsm"); 1.39 + 1.40 + return payment_ns; 1.41 +}