Skip to content

Commit

Permalink
fix postMessage crossdomain error
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed May 12, 2016
1 parent 4cabf59 commit 9332530
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions EIPS/eip-XXX.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
});
}
Expand All @@ -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();
}
});
Expand Down Expand Up @@ -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();
});
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -604,7 +604,7 @@ That's it
window.addEventListener("message", receiveMessage);
if(source){
source.postMessage("ready",source.location.href);
source.postMessage("ready","*");
}
</script>
Expand Down

0 comments on commit 9332530

Please sign in to comment.