Fix: dead object
This commit is contained in:
parent
5ae95a1ad9
commit
f6ce78f55b
|
@ -10,7 +10,8 @@ const msg = (() => {
|
||||||
window._msg = {
|
window._msg = {
|
||||||
id: 1,
|
id: 1,
|
||||||
storage: new Map(),
|
storage: new Map(),
|
||||||
handler: null
|
handler: null,
|
||||||
|
clone: deepCopy
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const runtimeSend = promisify(chrome.runtime.sendMessage.bind(chrome.runtime));
|
const runtimeSend = promisify(chrome.runtime.sendMessage.bind(chrome.runtime));
|
||||||
|
@ -77,8 +78,9 @@ const msg = (() => {
|
||||||
throw new Error('there is no bg handler');
|
throw new Error('there is no bg handler');
|
||||||
}
|
}
|
||||||
const handlers = bg._msg.handler.extension.concat(bg._msg.handler.both);
|
const handlers = bg._msg.handler.extension.concat(bg._msg.handler.both);
|
||||||
// FIXME: do we want to deepCopy `data`?
|
// in FF, the object would become a dead object when the window
|
||||||
return Promise.resolve(executeCallbacks(handlers, data, {url: location.href}))
|
// is closed, so we have to clone the object into background.
|
||||||
|
return Promise.resolve(executeCallbacks(handlers, bg._msg.clone(data), {url: location.href}))
|
||||||
.then(deepCopy);
|
.then(deepCopy);
|
||||||
}
|
}
|
||||||
return send(data);
|
return send(data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user