use cloneInto when passing objects from content_script to page

This commit is contained in:
tg(x) 2016-10-05 02:10:56 +02:00
parent 5bea586218
commit 39b3fd7fc6

View File

@ -22,7 +22,9 @@
* @author Florian Dold * @author Florian Dold
*/ */
"use strict";
declare var cloneInto: any;
function subst(url: string, H_contract: string) { function subst(url: string, H_contract: string) {
url = url.replace("${H_contract}", H_contract); url = url.replace("${H_contract}", H_contract);
@ -122,13 +124,17 @@ export function fetchPayment(H_contract: any, offering_url: any) {
// We have the details for then payment, the merchant page // We have the details for then payment, the merchant page
// is responsible to give it to the merchant. // is responsible to give it to the merchant.
let evt = new CustomEvent("taler-notify-payment", { let opts = {
detail: { detail: {
H_contract: H_contract, H_contract: H_contract,
contract: resp.contract, contract: resp.contract,
payment: resp.payReq, payment: resp.payReq,
} }
}); };
if ("function" == typeof cloneInto) {
opts = cloneInto(opts, document.defaultView);
}
let evt = new CustomEvent("taler-notify-payment", opts);
document.dispatchEvent(evt); document.dispatchEvent(evt);
}); });
} }
@ -166,4 +172,4 @@ function offerContractFrom(url: string) {
+ contract_request.statusText); + contract_request.statusText);
}; };
contract_request.send(); contract_request.send();
} }