mirror of https://github.com/gorhill/uBlock.git
Fix failure to create popup logger window sometimes
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/2249
This commit is contained in:
parent
924d3b3c4c
commit
c8762945d9
|
@ -433,22 +433,26 @@ vAPI.Tabs = class {
|
||||||
// For some reasons, some platforms do not honor the left,top
|
// For some reasons, some platforms do not honor the left,top
|
||||||
// position when specified. I found that further calling
|
// position when specified. I found that further calling
|
||||||
// windows.update again with the same position _may_ help.
|
// windows.update again with the same position _may_ help.
|
||||||
|
//
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/2249
|
||||||
|
// Mind that the creation of the popup window might fail.
|
||||||
if ( details.popup !== undefined && vAPI.windows instanceof Object ) {
|
if ( details.popup !== undefined && vAPI.windows instanceof Object ) {
|
||||||
const createDetails = {
|
const basicDetails = {
|
||||||
url: details.url,
|
url: details.url,
|
||||||
type: details.popup,
|
type: details.popup,
|
||||||
};
|
};
|
||||||
if ( details.box instanceof Object ) {
|
const shouldRestorePosition = details.box instanceof Object;
|
||||||
Object.assign(createDetails, details.box);
|
const extraDetails = shouldRestorePosition
|
||||||
|
? Object.assign({}, basicDetails, details.box)
|
||||||
|
: basicDetails;
|
||||||
|
const win = await vAPI.windows.create(extraDetails);
|
||||||
|
if ( win === null ) {
|
||||||
|
if ( shouldRestorePosition === false ) { return; }
|
||||||
|
return vAPI.windows.create(basicDetails);
|
||||||
}
|
}
|
||||||
const win = await vAPI.windows.create(createDetails);
|
if ( shouldRestorePosition === false ) { return; }
|
||||||
if ( win === null ) { return; }
|
if ( win.left === details.box.left ) {
|
||||||
if ( details.box instanceof Object === false ) { return; }
|
if ( win.top === details.box.top ) { return; }
|
||||||
if (
|
|
||||||
win.left === details.box.left &&
|
|
||||||
win.top === details.box.top
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
vAPI.windows.update(win.id, {
|
vAPI.windows.update(win.id, {
|
||||||
left: details.box.left,
|
left: details.box.left,
|
||||||
|
|
Loading…
Reference in New Issue