From 9332530eed71df388e27c66c5679a4d2aa8496d9 Mon Sep 17 00:00:00 2001 From: wighawag Date: Thu, 12 May 2016 07:13:33 +0100 Subject: [PATCH] fix postMessage crossdomain error --- EIPS/eip-XXX.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/EIPS/eip-XXX.md b/EIPS/eip-XXX.md index add296ef502434..ba13a3caeb0ab2 100644 --- a/EIPS/eip-XXX.md +++ b/EIPS/eip-XXX.md @@ -397,7 +397,7 @@ That's it } cancelButton.onclick = function(){ - sourceWindow.postMessage({id:data.id,result:null,error:{message:"Not Authorized"},type:"cancel"},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:null,error:{message:"Not Authorized"},type:"cancel"},firstUrl); closeWindow(); } @@ -420,7 +420,7 @@ That's it showMessage("Error unlocking account", "Please retry.", hideWaiting); }else{ sendAsync(data.url,data.payload,function(error,result){ - sourceWindow.postMessage({id:data.id,result:result,error:error},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:result,error:error},firstUrl); closeWindow(); }); } @@ -430,7 +430,7 @@ That's it if(result && result.error){ processMessage(data,sourceWindow); }else{ - sourceWindow.postMessage({id:data.id,result:result,error:error},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:result,error:error},firstUrl); closeWindow(); } }); @@ -476,7 +476,7 @@ That's it try{ processMessage(data,event.source); }catch(e){ - event.source.postMessage({id:data.id,result:null,error:{message:"Could not process message data"},type:"notValid"},event.source.location.href); + event.source.postMessage({id:data.id,result:null,error:{message:"Could not process message data"},type:"notValid"},firstUrl); showMessage("Error","The application has sent invalid data", function(){ closeWindow(); }); @@ -552,10 +552,10 @@ That's it if(inIframe){ if(isMethodAllowed(data.payload.method)){ sendAsync(data.url,data.payload,function(error,result){ - sourceWindow.postMessage({id:data.id,result:result,error:error},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:result,error:error},firstUrl); }); }else{ - sourceWindow.postMessage({id:data.id,result:null,error:{message:"method (" + data.payload.method + ") not allowed in iframe"},type:"notAllowed"},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:null,error:{message:"method (" + data.payload.method + ") not allowed in iframe"},type:"notAllowed"},firstUrl); } }else if(data.payload.method == "eth_sendTransaction"){ var transactionInfo = null; @@ -585,11 +585,11 @@ That's it }); }else{ - sourceWindow.postMessage({id:data.id,result:null,error:{message:"Need to specify from , to, gas and gasPrice"},type:"notValid"},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:null,error:{message:"Need to specify from , to, gas and gasPrice"},type:"notValid"},firstUrl); closeWindow(); } }else{ - sourceWindow.postMessage({id:data.id,result:null,error:{message:"method (" + data.payload.method + ") not allowed in popup"},type:"notAllowed"},sourceWindow.location.href); + sourceWindow.postMessage({id:data.id,result:null,error:{message:"method (" + data.payload.method + ") not allowed in popup"},type:"notAllowed"},firstUrl); } } @@ -604,7 +604,7 @@ That's it window.addEventListener("message", receiveMessage); if(source){ - source.postMessage("ready",source.location.href); + source.postMessage("ready","*"); }