2011-11-10 02:09:18 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
let tab0, tab1, tab2;
|
|
|
|
let testStep = -1;
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
if (!isTiltEnabled()) {
|
|
|
|
info("Skipping tab switch test because Tilt isn't enabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isWebGLSupported()) {
|
|
|
|
info("Skipping tab switch test because WebGL isn't supported.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
gBrowser.tabContainer.addEventListener("TabSelect", tabSelect, false);
|
|
|
|
createTab1();
|
|
|
|
}
|
|
|
|
|
|
|
|
function createTab1() {
|
|
|
|
tab0 = gBrowser.selectedTab;
|
|
|
|
|
|
|
|
tab1 = createTab(function() {
|
|
|
|
createTilt({
|
|
|
|
onTiltOpen: function()
|
|
|
|
{
|
|
|
|
createTab2();
|
|
|
|
}
|
2012-06-03 10:15:41 -07:00
|
|
|
}, false, function suddenDeath()
|
|
|
|
{
|
|
|
|
info("Tilt could not be initialized properly.");
|
|
|
|
cleanup();
|
2011-11-10 02:09:18 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function createTab2() {
|
|
|
|
tab2 = createTab(function() {
|
|
|
|
|
|
|
|
createTilt({
|
|
|
|
onTiltOpen: function()
|
|
|
|
{
|
|
|
|
testStep = 0;
|
|
|
|
tabSelect();
|
|
|
|
}
|
2012-06-03 10:15:41 -07:00
|
|
|
}, false, function suddenDeath()
|
|
|
|
{
|
|
|
|
info("Tilt could not be initialized properly.");
|
|
|
|
cleanup();
|
2011-11-10 02:09:18 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
let testSteps = [
|
|
|
|
function step0() {
|
|
|
|
gBrowser.selectedTab = tab1;
|
|
|
|
},
|
|
|
|
function step1() {
|
|
|
|
gBrowser.selectedTab = tab0;
|
|
|
|
},
|
|
|
|
function step2() {
|
|
|
|
gBrowser.selectedTab = tab1;
|
|
|
|
},
|
|
|
|
function step3() {
|
|
|
|
gBrowser.selectedTab = tab2;
|
|
|
|
},
|
|
|
|
function step4() {
|
|
|
|
Tilt.destroy(Tilt.currentWindowId);
|
|
|
|
gBrowser.removeCurrentTab();
|
2012-06-03 10:15:41 -07:00
|
|
|
tab2 = null;
|
2011-11-10 02:09:18 -08:00
|
|
|
},
|
|
|
|
function step5() {
|
|
|
|
Tilt.destroy(Tilt.currentWindowId);
|
|
|
|
gBrowser.removeCurrentTab();
|
2012-06-03 10:15:41 -07:00
|
|
|
tab1 = null;
|
2011-11-10 02:09:18 -08:00
|
|
|
},
|
|
|
|
function step6_cleanup() {
|
2012-06-03 10:15:41 -07:00
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
];
|
2011-11-10 02:09:18 -08:00
|
|
|
|
2012-06-03 10:15:41 -07:00
|
|
|
function cleanup() {
|
|
|
|
gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false);
|
|
|
|
|
|
|
|
if (tab1) {
|
|
|
|
gBrowser.removeTab(tab1);
|
2011-11-10 02:09:18 -08:00
|
|
|
tab1 = null;
|
2012-06-03 10:15:41 -07:00
|
|
|
}
|
|
|
|
if (tab2) {
|
|
|
|
gBrowser.removeTab(tab2);
|
2011-11-10 02:09:18 -08:00
|
|
|
tab2 = null;
|
|
|
|
}
|
2012-06-03 10:15:41 -07:00
|
|
|
|
|
|
|
finish();
|
|
|
|
}
|
2011-11-10 02:09:18 -08:00
|
|
|
|
|
|
|
function tabSelect() {
|
|
|
|
if (testStep !== -1) {
|
|
|
|
executeSoon(testSteps[testStep]);
|
|
|
|
testStep++;
|
|
|
|
}
|
|
|
|
}
|