I want to avoid postMessage between webextension and tab app in firefox because of low privacy.
But I've encountered permission wall.
// content script in webextension
const obj = new window.Object()
// It's OK
obj.good = exportFunction(() => {
return window.wrappedJSObject.somePromiseFunc();
}, window);
// NG calling then of somePromiseFunc
obj.ng = exportFunction(() => {
return window.wrappedJSObject.somePromiseFunc().then(val => {
val
}) // Uncaught (in promise) Error: Permission denied to access object
})
// NG wrapped by window.Promise either
obj.foo = exportFunction(() => {
return new window.Promise(resolve => {
window.wrappedJSObject.object // It's OK
window.wrappedJSObject.somePromiseFunc().then(val => {
resolve(val)
}) // Uncaught (in promise) Error: Permission denied to access object
})
})
The method for success described Webextension Content script return Promise to page-script in 2017 didn't work either.
The same error:
obj.foo = exportFunction(() => {
return new window.wrappedJSObject.Promise(
exportFunction(function (resolve) {
window.wrappedJSObject.somePromiseFunc().then(val => {
resolve(val)
}) // Uncaught (in promise) Error: Permission denied to access object
}, window.wrappedJSObject)
)
}, window.wrappedJSObject)
I want to call window.wrappedJSObject.somePromiseFunc()
with function passed from content script. Is there any way?