@@ -39,7 +39,15 @@ var Prompts = (() => {
3939 this . close ( ) ;
4040
4141 let url = browser . runtime . getURL ( "ui/prompt.html" ) ;
42+
43+ if ( ! ( "windows" in browser ) ) {
44+ // Android, most likely
45+ this . currentTab = await browser . tabs . create ( { url} ) ;
46+ return ;
47+ }
48+
4249 let { width, height, left, top, parent } = data . features ;
50+
4351 let options = {
4452 url,
4553 type : "popup" ,
@@ -53,32 +61,23 @@ var Prompts = (() => {
5361 options . allowScriptsToClose = true ;
5462 }
5563
56- if ( ! ( "windows" in browser ) ) {
57- // Android, most likely
58- this . currentTab = await browser . tabs . create ( { url} ) ;
59- return ;
60- }
61-
62- const centerOnParent = ( dim ) => {
63- const { width, height } = dim ;
64- dim . left =
65- left === undefined
66- ? Math . round ( parent . left + ( parent . width - width ) / 2 )
67- : left ;
68- dim . top =
69- top === undefined
70- ? Math . round ( parent . top + ( parent . height - height ) / 2 )
71- : top ;
72- return dim ;
64+ const centerOnParent = bounds => {
65+ for ( const [ p , s ] of [ [ "left" , "width" ] , [ "top" , "height" ] ] ) {
66+ if ( bounds [ s ] && bounds [ p ] === undefined ) {
67+ bounds [ p ] = Math . round ( parent [ p ] + ( parent [ s ] - bounds [ s ] ) / 2 ) ;
68+ }
69+ }
70+ return bounds ;
7371 } ;
7472
7573 if ( width && height ) {
76- let size = { width, height } ;
77- url += `?size =${ JSON . stringify ( size ) } ` ;
74+ const bounds = { width, height, left , top } ;
75+ url += `?winbounds =${ JSON . stringify ( bounds ) } ` ;
7876 if ( parent ) {
79- ( { left, top } = Object . assign ( options , centerOnParent ( size ) ) ) ;
77+ ( { left, top } = Object . assign ( options , centerOnParent ( bounds ) ) ) ;
8078 }
8179 }
80+
8281 debug ( "Prompt pre-opening options" , options , left , top , width , height ) ; // DEV_ONLY
8382 let popup = ( this . currentWindow = await browser . windows . create ( options ) ) ;
8483
@@ -93,7 +92,7 @@ var Prompts = (() => {
9392 if ( top === undefined ) ( { top } = popup ) ;
9493 }
9594
96- debug ( "Prompt post-opening options" , popup , options , left , top , width , height ) ;
95+ debug ( "Prompt post-opening options" , popup , options , left , top , width , height ) ; // DEV_ONLY
9796
9897 // work around for resistFingerprinting new window rounding (https://bugzilla.mozilla.org/show_bug.cgi?id=1330882)
9998 if (
0 commit comments