Using a non default icon makes persist fail



12 years ago
12 years ago


(Reporter: xverges, Unassigned)





12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070725 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070201 Webrunner/0.5

When an icon different from webrunner is specified as a parameter in the command line or in a webapp file, the window will not keep its size/position after closing and reopening.

The icon is changed using 
document.documentElement.setAttribute("id", params.icon);

That probably means that the new position is saved for "newicon". When the window is reopened, the position is obtained from "webrunner".

Reproducible: Always

Steps to Reproduce:
1. Open a window using "-uri ..." and "-icon gmail.ico" as additional params
2. Change the window's position
3. Close the window
4. Open a window using the same params as in step 1
Actual Results:  
The window's position is the same as in step 1

Expected Results:  
The window's position should be the one set in in step 2

Comment 1

12 years ago
If the line

document.documentElement.setAttribute("id", params.icon);

is called before, outside of startup(), the positions get restored.

Comment 2

12 years ago
If changing the id is the only possible way that XULRunner gives to change the icon, maybe it would be a good thing to add a "persist" flag to the command line/webapp profile, and remove the "persist" attribute in the window definition. Having window positions depend on the icon name is confusing.

Just in case it can be of any use, this code, that I wrote before I learned that moving the setAttribute("id", params.icon) call would be enough, restores the stored windows position:

function restoreWinPositions(id) {
  var rdfService = Components.classes[";1"].
  var rdfLocalStoreDS = Components.classes[";1?name=local-store"].
  var rdfRes = rdfService.GetResource("chrome://webrunner/content/webrunner.xul#" + id);
  var props = {};
  var targets = rdfLocalStoreDS.ArcLabelsOut(rdfRes);
  while (targets.hasMoreElements()){
    var predicate = targets.getNext();
    if (predicate instanceof Components.interfaces.nsIRDFResource){
      var target = rdfLocalStoreDS.GetTarget(rdfRes, predicate, true);
      if (target instanceof Components.interfaces.nsIRDFLiteral){
        props[predicate.Value] = target.Value;
  if ((typeof(props.screenX) != 'undefined') && (typeof(props.screenY) != 'undefined')) {
    window.moveTo(props.screenX, props.screenY);
  if ((typeof(props.width) != 'undefined') && (typeof(props.height) != 'undefined')) {
    window.resizeTo(props.width, props.height);

Comment 3

12 years ago
Where should the call to setAttribute("id", params.icon)  be moved to?

Comment 4

12 years ago
The thing is that my webrunner (as packaged for 0.5) and the webrunner in svn look quite different. The HostUI and the WebRunner objects do not exist in my installed code. 

What fixed the thing for me was having
document.documentElement.setAttribute("id", params.icon);
outside of any function definiton, so it got executed before the "load" event called "startup". 

I'm sorry about not being able to check out the trunk now and give a more precise answer.

Comment 5

12 years ago
Ok, that probably won't work in the current SVN. I'll look for some workaround, or perhaps we should use the code you posted above.
Product: Other Applications → Mozilla Labs
This should be fixed now. We store the window settings in localstore.json and we wait until the icon (window ID) is changed before loading or saving
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.