Este site irá ter funcionalidade limitada enquanto fazemos manutenção para melhorar a sua experiência. Se um artigo não resolve o seu problema e quiser colocar uma questão, temos a nossa comunidade de apoio à espera de o ajudar em @FirefoxSupport no Twitter, /r/firefox no Reddit.

Pesquisar no apoio

Evite burlas no apoio. Nunca iremos solicitar que telefone ou envie uma mensagem de texto para um número de telefone ou que partilhe informações pessoais. Por favor, reporte atividades suspeitas utilizando a opção "Reportar abuso".

Saber mais

browser.windows.create - broken with specific height/width on hiDPI screens, macOS

  • 2 respostas
  • 0 têm este problema
  • 2 visualizações
  • Última resposta por squad-clients

more options

I'm seeing an issue in the latest release of Firefox (103.0.2) & Firefox developer edition (104.0b10) when working with a manifest v2 web extension. The issue is not present in Firefox Developer edition (100.0b9) and below.

When calling browser.windows.create() - passing valid options for height & width is resulting in a completely invalid and unexpected size for the resulting window. The code to reproduce the behavior is below.

This is being run in a background script of the extension.

```

 const width = props.width ?? Math.round(window.screen.width * 0.8);
 const height = props.height ?? Math.round(window.screen.height * 0.8);
 // center by default
 const top = props.top ?? Math.round(window.screen.height / 2 - height / 2);
 const left = props.left ?? Math.round(window.screen.width / 2 - width / 2);
 console.log(
   `In openWindow width ${width} height ${height} top ${top} left ${left}`
 );
 const newWindow = await browser.windows.create({
   url: props.url,
   width,
   height,
   top,
   left,
   type: 'popup',
 });

``` The console.log result is ``` In openWindow width 3072 height 1728 top 216 left 384 ``` These are valid numbers for the screen I am working on (standard 4k displays). I am running 3 screens, all hiDPI - two are default 4k external monitors, the third is the built in laptop display.

I have not yet tested the result on other operating systems - however I am running macOS Monteray v12.4.

When running in version 100.0b9 and below, I see a centered screen ~80% of the monitor width and height appear. When I run in the current versions, I see the window briefly flash at full screen, then immediately downsize to a very small window in the upper left corner.

Please see a brief recording of the working version of Firefox Developer Edition compared to the broken version of standard Firefox here: https://monosnap.com/file/80IEHdqgSVND0ZsXKtXkxVPsNINSQd

I am running the exact same extension build in both versions.

I'm seeing an issue in the latest release of Firefox (103.0.2) & Firefox developer edition (104.0b10) when working with a manifest v2 web extension. The issue is not present in Firefox Developer edition (100.0b9) and below. When calling browser.windows.create() - passing valid options for height & width is resulting in a completely invalid and unexpected size for the resulting window. The code to reproduce the behavior is below. This is being run in a background script of the extension. ``` const width = props.width ?? Math.round(window.screen.width * 0.8); const height = props.height ?? Math.round(window.screen.height * 0.8); // center by default const top = props.top ?? Math.round(window.screen.height / 2 - height / 2); const left = props.left ?? Math.round(window.screen.width / 2 - width / 2); console.log( `In openWindow width ${width} height ${height} top ${top} left ${left}` ); const newWindow = await browser.windows.create({ url: props.url, width, height, top, left, type: 'popup', }); ``` The console.log result is ``` In openWindow width 3072 height 1728 top 216 left 384 ``` These are valid numbers for the screen I am working on (standard 4k displays). I am running 3 screens, all hiDPI - two are default 4k external monitors, the third is the built in laptop display. I have not yet tested the result on other operating systems - however I am running macOS Monteray v12.4. When running in version 100.0b9 and below, I see a centered screen ~80% of the monitor width and height appear. When I run in the current versions, I see the window briefly flash at full screen, then immediately downsize to a very small window in the upper left corner. Please see a brief recording of the working version of Firefox Developer Edition compared to the broken version of standard Firefox here: https://monosnap.com/file/80IEHdqgSVND0ZsXKtXkxVPsNINSQd I am running the exact same extension build in both versions.
Capturas de ecrã anexadas

Modificado por squad-clients a

Todas as respostas (2)

more options

There is a forum for Add-on developers where you might re-post this:

https://discourse.mozilla.org/c/add-ons/development/108

This this:

squad-clients said

  const newWindow = await browser.windows.create({
    url: props.url,
    width,
    height,
    top,
    left,
    type: 'popup',
  });

the same as this:

 const newWindow = await browser.windows.create({
   url: props.url,
   width: width,
   height: height,
   top: top,
   left: left,
   type: 'popup',
 });


I'm not sure there is a defined order for the parameters. https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/windows/create

more options

Yes - I'm just using the shorthand assignment when creating the object literal: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#syntax

Your two examples above will be identical.

Thanks for the link to the discourse. I've also posted a bugzilla, since this seems to be a pretty clear regression in between v100 and v103, but I'll add a post in discourse.