Bug 554279 - Defer toolbar initialization to get XUL overlays for the toolbar palette loaded. r=enn a=b

This commit is contained in:
Dão Gottwald 2010-12-15 20:03:00 +01:00
Родитель caaa659aea
Коммит c0baf91127
4 изменённых файлов: 80 добавлений и 16 удалений

Просмотреть файл

@ -51,6 +51,7 @@ _TEST_FILES = test_bug360220.xul \
test_bug457632.xul \
test_bug460942.xul \
test_bug509732.xul \
test_bug554279.xul \
test_bug557987.xul\
test_bug562554.xul \
test_button.xul \

Просмотреть файл

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<window title="Toolbar" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="startTest();">
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<toolbox>
<toolbarpalette id="palette"/>
<toolbar id="tb1" currentset="p1"/>
</toolbox>
<!-- test resuls are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml"
style="height: 300px; overflow: auto;"/>
<!-- test code goes here -->
<script type="text/javascript"><![CDATA[
var toolbar = $("tb1");
ok(toolbar, "got the toolbar, triggering the xbl constructor");
var palette = $("palette");
ok(palette, "palette is still in the document");
var button = document.createElement("p1");
button.id = button.label = "p1";
palette.appendChild(button);
SimpleTest.waitForExplicitFinish();
function startTest() {
is(button.parentNode, toolbar, "button has been added to the toolbar");
SimpleTest.finish();
}
]]></script>
</window>

Просмотреть файл

@ -2,7 +2,8 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<window title="Toolbar" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<window title="Toolbar" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="startTest();">
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
@ -204,21 +205,24 @@
}
}
test_defaultSet();
test_currentSet($("tb-test"));
test_currentSet($("tb-test2"));
test_currentSet_nonremovable();
SimpleTest.waitForExplicitFinish();
function startTest() {
test_defaultSet();
test_currentSet($("tb-test"));
test_currentSet($("tb-test2"));
test_currentSet_nonremovable();
var toolbox = $("toolbox");
var toolbars = document.getElementsByTagName("toolbar");
for (var t = 0; t < toolbars.length; t++) {
var toolbar = toolbars[t];
is(toolbar.toolbox, toolbar.id == "notoolbox" ? null : toolbox,
"toolbar " + toolbar.id + " has correct toolbox");
var toolbox = $("toolbox");
var toolbars = document.getElementsByTagName("toolbar");
for (var t = 0; t < toolbars.length; t++) {
var toolbar = toolbars[t];
is(toolbar.toolbox, toolbar.id == "notoolbox" ? null : toolbox,
"toolbar " + toolbar.id + " has correct toolbox");
}
$("tb1").toolbox = document.documentElement;
is($("tb1").toolbox, toolbox, "toolbox still correct after set");
SimpleTest.finish();
}
$("tb1").toolbox = document.documentElement;
is($("tb1").toolbox, toolbox, "toolbox still correct after set");
]]></script>
</window>

Просмотреть файл

@ -122,6 +122,24 @@
</property>
<constructor>
<![CDATA[
if (document.readyState == "complete") {
this._init();
} else {
// Need to wait until XUL overlays are loaded. See bug 554279.
let self = this;
document.addEventListener("readystatechange", function (event) {
if (document.readyState != "complete")
return;
document.removeEventListener("readystatechange", arguments.callee, false);
self._init();
}, false);
}
]]>
</constructor>
<method name="_init">
<body>
<![CDATA[
// Searching for the toolbox palette in the toolbar binding because
// toolbars are constructed first.
@ -153,7 +171,8 @@
if (currentSet)
this.currentSet = currentSet;
]]>
</constructor>
</body>
</method>
<method name="_idFromNode">
<parameter name="aNode"/>