mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
fix postMessage crossdomain error
This commit is contained in:
parent
6c1c5a3987
commit
e928f269fe
1 changed files with 9 additions and 9 deletions
|
|
@ -294,7 +294,7 @@ const AuthorizationHTML = `
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelButton.onclick = function(){
|
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();
|
closeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,7 +317,7 @@ const AuthorizationHTML = `
|
||||||
showMessage("Error unlocking account", "Please retry.", hideWaiting);
|
showMessage("Error unlocking account", "Please retry.", hideWaiting);
|
||||||
}else{
|
}else{
|
||||||
sendAsync(data.url,data.payload,function(error,result){
|
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();
|
closeWindow();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -327,7 +327,7 @@ const AuthorizationHTML = `
|
||||||
if(result && result.error){
|
if(result && result.error){
|
||||||
processMessage(data,sourceWindow);
|
processMessage(data,sourceWindow);
|
||||||
}else{
|
}else{
|
||||||
sourceWindow.postMessage({id:data.id,result:result,error:error},sourceWindow.location.href);
|
sourceWindow.postMessage({id:data.id,result:result,error:error},firstUrl);
|
||||||
closeWindow();
|
closeWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -373,7 +373,7 @@ const AuthorizationHTML = `
|
||||||
try{
|
try{
|
||||||
processMessage(data,event.source);
|
processMessage(data,event.source);
|
||||||
}catch(e){
|
}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(){
|
showMessage("Error","The application has sent invalid data", function(){
|
||||||
closeWindow();
|
closeWindow();
|
||||||
});
|
});
|
||||||
|
|
@ -449,10 +449,10 @@ const AuthorizationHTML = `
|
||||||
if(inIframe){
|
if(inIframe){
|
||||||
if(isMethodAllowed(data.payload.method)){
|
if(isMethodAllowed(data.payload.method)){
|
||||||
sendAsync(data.url,data.payload,function(error,result){
|
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{
|
}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"){
|
}else if(data.payload.method == "eth_sendTransaction"){
|
||||||
var transactionInfo = null;
|
var transactionInfo = null;
|
||||||
|
|
@ -482,11 +482,11 @@ const AuthorizationHTML = `
|
||||||
|
|
||||||
});
|
});
|
||||||
}else{
|
}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();
|
closeWindow();
|
||||||
}
|
}
|
||||||
}else{
|
}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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -501,7 +501,7 @@ const AuthorizationHTML = `
|
||||||
|
|
||||||
window.addEventListener("message", receiveMessage);
|
window.addEventListener("message", receiveMessage);
|
||||||
if(source){
|
if(source){
|
||||||
source.postMessage("ready",source.location.href);
|
source.postMessage("ready","*");
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue