gluon: inject IPC on new execution contexts to improve reliability
This commit is contained in:
parent
d6c4d2769a
commit
fc91501918
@ -39,6 +39,7 @@ export default async ({ browserName, browserPath, dataPath }, { url, windowSize
|
||||
|
||||
if (msg.method === 'Runtime.bindingCalled' && msg.name === 'gluonSend') onWindowMessage(JSON.parse(msg.payload));
|
||||
if (msg.method === 'Page.frameStoppedLoading') pageLoadCallback(msg.params);
|
||||
if (msg.method === 'Runtime.executionContextCreated') injectIPC(); // ensure IPC injection again
|
||||
};
|
||||
|
||||
let msgId = 0;
|
||||
@ -117,7 +118,7 @@ export default async ({ browserName, browserPath, dataPath }, { url, windowSize
|
||||
};
|
||||
|
||||
|
||||
const [ ipcMessageCallback, IPCApi ] = await makeIPCApi({
|
||||
const [ ipcMessageCallback, injectIPC, IPCApi ] = await makeIPCApi({
|
||||
browserName,
|
||||
browserInfo
|
||||
}, {
|
||||
|
@ -111,7 +111,7 @@ user_pref('privacy.window.maxInnerHeight', ${windowSize[1]}); */
|
||||
name: '_gluonSend'
|
||||
}); */
|
||||
|
||||
const [ ipcMessageCallback, IPCApi ] = await makeIPCApi({
|
||||
const [ ipcMessageCallback, injectIPC, IPCApi ] = await makeIPCApi({
|
||||
browserName,
|
||||
browserInfo
|
||||
}, {
|
||||
|
@ -1,5 +1,6 @@
|
||||
export default ({ browserName, browserInfo }, { evaluate, addScriptToEvaluateOnNewDocument, pageLoadPromise }) => {
|
||||
const injection = `(() => {
|
||||
if (window.Gluon) return;
|
||||
let onIPCReply = {}, ipcListeners = {};
|
||||
window.Gluon = {
|
||||
versions: {
|
||||
@ -129,7 +130,9 @@ delete window._gluonSend;
|
||||
sendToWindow('pong', {}, id); // send simple pong to confirm
|
||||
};
|
||||
|
||||
return [ onWindowMessage, {
|
||||
return [ onWindowMessage, () => evaluate({
|
||||
expression: injection
|
||||
}), {
|
||||
on: (type, cb) => {
|
||||
if (!ipcListeners[type]) ipcListeners[type] = [];
|
||||
ipcListeners[type].push(cb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user