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": [
|
||||
"<all_urls>"
|
||||
]
|
||||
],
|
||||
"use_dynamic_url": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ const onFrameMessage = function(msg) {
|
|||
// can remove the iframe.
|
||||
|
||||
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 => {
|
||||
const frame = document.createElement('iframe');
|
||||
frame.setAttribute(zapperSecret, '');
|
||||
|
|
@ -381,9 +381,11 @@ const bootstrap = async ( ) => {
|
|||
port.onmessageerror = ( ) => {
|
||||
quitZapper();
|
||||
};
|
||||
const realURL = new URL(dynamicURL);
|
||||
realURL.hostname = chrome.i18n.getMessage('@@extension_id');
|
||||
frame.contentWindow.postMessage(
|
||||
{ what: 'zapperStart' },
|
||||
url.origin,
|
||||
realURL.origin,
|
||||
[ channel.port2 ]
|
||||
);
|
||||
frame.contentWindow.focus();
|
||||
|
|
@ -392,7 +394,7 @@ const bootstrap = async ( ) => {
|
|||
zapperFramePort: port,
|
||||
});
|
||||
};
|
||||
frame.contentWindow.location = url.href;
|
||||
frame.contentWindow.location = dynamicURL.href;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue