fix postMessage crossdomain error

This commit is contained in:
wighawag 2016-05-12 07:13:33 +01:00
parent 4cabf59bba
commit 9332530eed

View File

@ -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","*");
}
</script>