I stumbled upon an issue - some (not all) persist attributes stop restoring it's persist value if I used document.getElementById("prefwindowID") before onload event was fired.
Example:
Code: Select all
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<prefwindow id="testWindow"
title="testing persist when accessing nodes before onload event"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>
<prefpane>
<checkbox id="testCheckbox"
label="testing persist on checkbox"
onchange="this.setAttribute('checked', this.checked)"
persist="checked"/>
<tabbox id="testTabbox"
selectedIndex="1"
persist="selectedIndex">
<tabs>
<tab label="tab #1" linkedpanel="panel1"/>
<tab label="tab #2" linkedpanel="panel2"/>
<tab label="tab #3" linkedpanel="panel3"/>
</tabs>
<tabpanels>
<tabpanel id="panel1"/>
<tabpanel id="panel2"/>
<tabpanel id="panel3"/>
</tabpanels>
</tabbox>
</prefpane>
<script type="application/javascript"><![CDATA[
/* persist selectedIndex on tabbox will stop working if uncomment next line */
//document.getElementById("testWindow");
]]></script>
</prefwindow>
Now, uncomment document.getElementById("testWindow");
And reopen the window, it will automatically switch to tab #2 regardless which tab was previously opened. Checkbox state however doesn't get affected.
This seems to affect only prefwindow (together with <prefpane>), window and dialog are not affected.
Same issue reproducible if trying access testTabbox instead of testWindow, however accessing testCheckbox works just fine.
I'm looking for a way collect default values of persist'ed attributes, so I could reset them to default when needed.
The only way I could find so far is to read value from these attributes before onload event fired, unfortunately this issue makes it unacceptable.
Do you think this is a bug?