mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Force real origin in postMessage so that use_dynamic_url can be used
Call to postMessage was failing in the zapper when using `use_dynamic_url` in manifest. Manually overwriting the per-session dynamic hostname with the real extension id fixes this.
This commit is contained in:
parent
0c6cbb7fcb
commit
6ffffb7b2b
2 changed files with 7 additions and 4 deletions
|
|
@ -63,7 +63,8 @@
|
||||||
],
|
],
|
||||||
"matches": [
|
"matches": [
|
||||||
"<all_urls>"
|
"<all_urls>"
|
||||||
]
|
],
|
||||||
|
"use_dynamic_url": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,7 @@ const onFrameMessage = function(msg) {
|
||||||
// can remove the iframe.
|
// can remove the iframe.
|
||||||
|
|
||||||
const bootstrap = async ( ) => {
|
const bootstrap = async ( ) => {
|
||||||
const url = new URL(chrome.runtime.getURL('/zapper-ui.html'));
|
const dynamicURL = new URL(chrome.runtime.getURL('/zapper-ui.html'));
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const frame = document.createElement('iframe');
|
const frame = document.createElement('iframe');
|
||||||
frame.setAttribute(zapperSecret, '');
|
frame.setAttribute(zapperSecret, '');
|
||||||
|
|
@ -381,9 +381,11 @@ const bootstrap = async ( ) => {
|
||||||
port.onmessageerror = ( ) => {
|
port.onmessageerror = ( ) => {
|
||||||
quitZapper();
|
quitZapper();
|
||||||
};
|
};
|
||||||
|
const realURL = new URL(dynamicURL);
|
||||||
|
realURL.hostname = chrome.i18n.getMessage('@@extension_id');
|
||||||
frame.contentWindow.postMessage(
|
frame.contentWindow.postMessage(
|
||||||
{ what: 'zapperStart' },
|
{ what: 'zapperStart' },
|
||||||
url.origin,
|
realURL.origin,
|
||||||
[ channel.port2 ]
|
[ channel.port2 ]
|
||||||
);
|
);
|
||||||
frame.contentWindow.focus();
|
frame.contentWindow.focus();
|
||||||
|
|
@ -392,7 +394,7 @@ const bootstrap = async ( ) => {
|
||||||
zapperFramePort: port,
|
zapperFramePort: port,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
frame.contentWindow.location = url.href;
|
frame.contentWindow.location = dynamicURL.href;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue