Bug 594909 - Intermittent failure in browser/base/content/test/tabview/browser_tabview_launch.js, r=dietrich, a=testfix

This commit is contained in:
Raymond Lee 2010-09-16 15:18:54 +08:00
parent ceb0c9733f
commit 8589db3538

View File

@ -45,26 +45,24 @@ function test() {
if (tabViewShownCount == 1) { if (tabViewShownCount == 1) {
document.getElementById("menu_tabview").doCommand(); document.getElementById("menu_tabview").doCommand();
} else if (tabViewShownCount == 2) { } else if (tabViewShownCount == 2) {
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). let utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils); getInterface(Ci.nsIDOMWindowUtils);
if (utils) { let keyCode = 0;
var keyCode = 0; let charCode;
var charCode; let eventObject;
var eventObject; if (navigator.platform.indexOf("Mac") != -1) {
if (navigator.platform.indexOf("Mac") != -1) { charCode = 160;
charCode = 160; eventObject = { altKey: true };
eventObject = { altKey: true }; } else {
} else { charCode = 32;
charCode = 32; eventObject = { ctrlKey: true };
eventObject = { ctrlKey: true };
}
var modifiers = EventUtils._parseModifiers(eventObject);
var keyDownDefaultHappened =
utils.sendKeyEvent("keydown", keyCode, charCode, modifiers);
utils.sendKeyEvent("keypress", keyCode, charCode, modifiers,
!keyDownDefaultHappened);
utils.sendKeyEvent("keyup", keyCode, charCode, modifiers);
} }
let modifiers = EventUtils._parseModifiers(eventObject);
let keyDownDefaultHappened =
utils.sendKeyEvent("keydown", keyCode, charCode, modifiers);
utils.sendKeyEvent("keypress", keyCode, charCode, modifiers,
!keyDownDefaultHappened);
utils.sendKeyEvent("keyup", keyCode, charCode, modifiers);
} else if (tabViewShownCount == 3) { } else if (tabViewShownCount == 3) {
window.removeEventListener("tabviewshown", onTabViewShown, false); window.removeEventListener("tabviewshown", onTabViewShown, false);
window.removeEventListener("tabviewhidden", onTabViewHidden, false); window.removeEventListener("tabviewhidden", onTabViewHidden, false);
@ -72,9 +70,10 @@ function test() {
} }
} }
let onTabViewShown = function() { let onTabViewShown = function() {
ok(TabView.isVisible(), "Tab View is visible"); // add the count to the message so we can track things more easily.
ok(TabView.isVisible(), "Tab View is visible. Count: " + tabViewShownCount);
tabViewShownCount++ tabViewShownCount++
TabView.toggle(); executeSoon(function() { TabView.toggle(); });
} }
window.addEventListener("tabviewshown", onTabViewShown, false); window.addEventListener("tabviewshown", onTabViewShown, false);
window.addEventListener("tabviewhidden", onTabViewHidden, false); window.addEventListener("tabviewhidden", onTabViewHidden, false);