** Description changed:

+ REASON FOR SRU:
+ Polluting the global namespace isn't friendly and will break either the 
globalmenu extension or other extensions that people install.
+ 
+ --------------------------------------------------
+ 
  Binary package hint: firefox
  
  The globalmenu extension overlays browser.xul and loads firefoxMenu.js, 
adding a lot of new variables/functions to the shared scope, at least:
  nsIObserverService !
  uIGlobalMenuLoader
  uIGlobalMenuService
  observer !
  Observer() !
  onLoad() !
  onUnload() !
  PlacesMenuUnityImpl()
  HistoryMenuUnityImpl()
  (! marks names with high chance of conflicts)
  
  This is a problem as the regular browser code, all other extensions 
overlaying the browser window and this extension share the same scope, i.e. the 
same namespace.
  If other extensions happen to define the same scope-global names, then 
conflicts will occur. Whoever loads last wins. Hence there is a high 
probability of heisenbugs (depending on the other extensions a user installs).
  I'm a volunteer addons.mozilla.org editor, performing required code reviews 
an extension, this would be a definite show-stopper bug to any public listing.
  
  You can either "hide" your stuff within a function, use some "namespace" 
variable, or a mixture of both, e.g.:
  if (!com) var com =  {};
  if (!com.canonical) com.canonical =  {};
  (function()  {
-   // local/"hidden" stuff
-   function load()   {
-     removeEventListener("load", load, false);
-     ...
-   }
-   addEventListener("load", load, false);
+   // local/"hidden" stuff
+   function load()   {
+     removeEventListener("load", load, false);
+     ...
+   }
+   addEventListener("load", load, false);
  
-   // globally visible
-   this.Unity = { // |this| is com.canonical
-     PlacesMenuUnityImpl: ...
-   };
+   // globally visible
+   this.Unity = { // |this| is com.canonical
+     PlacesMenuUnityImpl: ...
+   };
  }).call(com.canonical);
  
  (in the xul overlay you would then change all references to
  PlacesMenuUnityImpl to com.canonical.Unity.PlacesMenuUnityImpl)
  
  Also see:
  https://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/767966

Title:
  globalmenu extension pollutes main window javascript scope

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to