Commit f759db1d authored by Sven Franck's avatar Sven Franck

replaced sender domain with sending domain in postMessage

parent 1f0e5ce0
...@@ -568,23 +568,19 @@ ...@@ -568,23 +568,19 @@
"type": "reply", "type": "reply",
"result": event.data.result, "result": event.data.result,
"callback": event.data.callbackId, "callback": event.data.callbackId,
}, window.location.href.split("?")[0]); }, event.origin);
}; };
// => run a service and post the result // => run a service and post the result
priv.runService = function (event) { priv.runService = function (event) {
var result = window[event.data.service].apply(this, event.data.parameters), var result = window[event.data.service].apply(this, event.data.parameters);
foreign = priv.isForeignUrl(event.origin);
window.top.postMessage({ window.top.postMessage({
"type": "result", "type": "result",
"result": result, "result": result,
"trackingId" : event.data.trackingId, "trackingId" : event.data.trackingId,
"callbackId": event.data.callbackId, "callbackId": event.data.callbackId,
// "*" is not recommended, but when using localhost, this seems }, event.origin);
// to be the only way to get the message to domain1...?
// make sure this works with window.location.href in production
}, foreign ? "*" : window.location.href.split("?")[0]);
}; };
// => request a service provided by a gadget // => request a service provided by a gadget
...@@ -594,8 +590,7 @@ ...@@ -594,8 +590,7 @@
event.data.type.split("/")[1] event.data.type.split("/")[1]
), ),
selector, selector,
targetWindow, targetWindow;
foreign;
if (callService) { if (callService) {
// services are stored by URL (not id), so we need to find the service // services are stored by URL (not id), so we need to find the service
...@@ -620,7 +615,6 @@ ...@@ -620,7 +615,6 @@
if (selector.length === 0) { if (selector.length === 0) {
targetWindow = window; targetWindow = window;
} else { } else {
foreign = selector[selector.length-1][1];
try { try {
targetWindow = selector.reduce(function(tgt, o) { targetWindow = selector.reduce(function(tgt, o) {
return tgt && o[1] ? return tgt && o[1] ?
...@@ -639,10 +633,7 @@ ...@@ -639,10 +633,7 @@
"callbackId": event.data.callbackId, "callbackId": event.data.callbackId,
"service": event.data.service, "service": event.data.service,
"parameters": event.data.parameters "parameters": event.data.parameters
// "*" is not recommended, but when using localhost, this seems }, event.origin);
// to be the only way to get the message to domain1...?
// make sure this works with window.location.href in production
}, foreign ? "*" : window.location.href);
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment