6

I'm working on porting an extension from Chrome to Firefox. The popup has several different sized elements which can be shown. The issue that I'm running into is when the elements are changed or the body is resized the 'window' that the popup is displayed in does not resize.

This issue doesn't seem to exist in chrome, does anyone know what I'm doing wrong or is this a bug in Firefox? I've included the code which changes the size of the body below, this works in chrome, but does not seem to work in Firefox.

$('body').ready(function(){
  $('body').animate({
    'width':500,
    'height':500
  },500); 
});

I've also tried this with $('body').css() in case animate() was the issue, neither work.

Additionally, if I add a background to the body and shrink it, then the background can be seen changing size without the containing window changing size.

Edit: Adding more information to clarify the issue

The extension is a WebExtension add-on (https://developer.mozilla.org/en-US/Add-ons/WebExtensions)

manifest.json

{
  "manifest_version": 2,
  "browser_action": {
    "default_popup": "popup.htm"
  },
  "description": "Example extension",
  "icons": {
    "128": "example.png"
  },
  "name": "Example Extension",
  "version": "1",
  "applications":{
    "gecko":{
      "id":"example@example.com"
    }
  }
}

popup.htm

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type=text/javascript src="js/jquery.js"></script>
    <script type=text/javascript src="js/popup.js"></script>
</head>
<style>
body{
  width:200px;
  height:200px;

  border:1px solid black;
}
</style>
<body>
  <button id=reset type=button>200x200px</button>
  <button id=shrink type=button>100x100px</button>
</body>
</html>

js/popup.js

$('body').ready(function (){
  $('#reset').bind('click',function(){
    $('body').css({
      width:200,
      height:200
    });
  });
  $('#shrink').bind('click',function(){
    $('body').css({
      width:100,
      height:100
    });
  });
});

When the above extension is loaded, the popup shows correctly with its initial size (200x200). However, when the body is resized, the popup's size is not updated. This same extension works as expected (popup resizes) within Chrome.

Makyen
  • 31,849
  • 12
  • 86
  • 121
Patrick
  • 143
  • 2
  • 8
  • Are you using WebExtensions? – Noitidart Mar 17 '16 at 20:45
  • We need a full [mcve], not just the jQuerry code you are using to perform the resize. We need to see how the popup was created. We need to know what [type of Firefox extension](https://developer.mozilla.org/en-US/Add-ons) you are developing. – Makyen Mar 17 '16 at 21:07
  • I've added a more complete example that should help make my issue clearer. – Patrick Mar 18 '16 at 13:56
  • Are you **sure** that this is a [Bootstrapped/restartless extension](https://developer.mozilla.org/en-US/Add-ons/Bootstrapped_extensions)? The existence of a [*manifest.json*](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Your_first_WebExtension#manifest.json) file would imply that it is a [WebExtensions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions) add-on, not what would be termed a Bootstrapped add-on. Bootstrapped add-ons *do not* have *manifest.json* files unless you have created one for your own specific non-standard purpose. – Makyen Mar 18 '16 at 15:22
  • There may be some confusion because both [WebExtensions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions) and [Add-on SDK](https://developer.mozilla.org/en-US/Add-ons/SDK) extensions are functionally restartles (they do not require restart). However, they are not termed [Bootstrapped or Restartless extensions](https://developer.mozilla.org/en-US/Add-ons/Bootstrapped_extensions). Yes, Mozilla could have done a better job at picking names for their different types of add-ons. They are this way because they developed over time, one after the other. – Makyen Mar 18 '16 at 15:25
  • Oh yeah, you're right. I had too many tabs open when I was looking at the different types. Good call – Patrick Mar 18 '16 at 15:26
  • You should strongly keep in mind that ["**WebExtensions are currently in an experimental alpha state**."](https://developer.mozilla.org/en-US/Add-ons/WebExtensions) That means a lot of things don't work, or don't work correctly yet. – Makyen Mar 18 '16 at 15:32

1 Answers1

4

Well it looks like this is actually bug within Firefox which is being addressed

https://bugzilla.mozilla.org/show_bug.cgi?id=1215025

Patrick
  • 143
  • 2
  • 8