Content script creates object and clone it to window to be accessible from page script code.
Cloned content script object has a method which is asynchronous call and I want to return Promise to page script. Xray vision prevent returning object to page script.
The only way I found to inform page script from content script about state of async method is Window.postMessage.
Are there any other solution to implement in more elegant way to using Promise style in calling content script object from page script code?
Here is sample code which is disallowed from Xray vision to return promise .
You may have to use exportFunction or something on the argument to Promise. Also, make sure you are aware of all the security implications of what you are doing.
I have tried with window.wrappedJSObect bet get an error Error: Permission denied to access object. exportFunction is not applicable to Permission object.
// content script
//...
return new window.wrappedJSObject.Promise(
function (resolve, reject) {
// calling async print ...
if (some_condition)
resolve(res);
else
reject(err);
}
);
}
//...