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;
|
|
|
|
let testStep = -1;
|
|
|
|
let tabEvents = "";
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
if (!isTiltEnabled()) {
|
|
|
|
info("Skipping notifications test because Tilt isn't enabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isWebGLSupported()) {
|
|
|
|
info("Skipping notifications test because WebGL isn't supported.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-19 07:48:22 -08:00
|
|
|
requestLongerTimeout(10);
|
2011-11-10 02:09:18 -08:00
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
gBrowser.tabContainer.addEventListener("TabSelect", tabSelect, false);
|
|
|
|
createNewTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
function createNewTab() {
|
|
|
|
tab0 = gBrowser.selectedTab;
|
|
|
|
|
|
|
|
tab1 = createTab(function() {
|
2012-06-03 10:15:41 -07:00
|
|
|
Services.obs.addObserver(finalize, DESTROYED, false);
|
2013-04-09 16:05:09 -07:00
|
|
|
Services.obs.addObserver(tab_STARTUP, STARTUP, false);
|
2012-01-19 07:48:22 -08:00
|
|
|
Services.obs.addObserver(tab_INITIALIZING, INITIALIZING, false);
|
|
|
|
Services.obs.addObserver(tab_DESTROYING, DESTROYING, false);
|
|
|
|
Services.obs.addObserver(tab_SHOWN, SHOWN, false);
|
|
|
|
Services.obs.addObserver(tab_HIDDEN, HIDDEN, false);
|
|
|
|
|
|
|
|
info("Starting up the Tilt notifications test.");
|
2011-11-10 02:09:18 -08:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-04-09 16:05:09 -07:00
|
|
|
function tab_STARTUP(win) {
|
|
|
|
info("Handling the STARTUP notification.");
|
|
|
|
is(win, tab1.linkedBrowser.contentWindow, "Saw the correct window");
|
|
|
|
tabEvents += "STARTUP;";
|
|
|
|
}
|
|
|
|
|
|
|
|
function tab_INITIALIZING(win) {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Handling the INITIALIZING notification.");
|
2013-04-09 16:05:09 -07:00
|
|
|
is(win, tab1.linkedBrowser.contentWindow, "Saw the correct window");
|
2012-01-19 07:48:22 -08:00
|
|
|
tabEvents += "INITIALIZING;";
|
2011-11-10 02:09:18 -08:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:05:09 -07:00
|
|
|
function tab_DESTROYING(win) {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Handling the DESTROYING notification.");
|
2013-04-09 16:05:09 -07:00
|
|
|
is(win, tab1.linkedBrowser.contentWindow, "Saw the correct window");
|
2012-01-19 07:48:22 -08:00
|
|
|
tabEvents += "DESTROYING;";
|
2011-11-10 02:09:18 -08:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:05:09 -07:00
|
|
|
function tab_SHOWN(win) {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Handling the SHOWN notification.");
|
2013-04-09 16:05:09 -07:00
|
|
|
is(win, tab1.linkedBrowser.contentWindow, "Saw the correct window");
|
2012-01-19 07:48:22 -08:00
|
|
|
tabEvents += "SHOWN;";
|
2011-11-10 02:09:18 -08:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:05:09 -07:00
|
|
|
function tab_HIDDEN(win) {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Handling the HIDDEN notification.");
|
2013-04-09 16:05:09 -07:00
|
|
|
is(win, tab1.linkedBrowser.contentWindow, "Saw the correct window");
|
2012-01-19 07:48:22 -08:00
|
|
|
tabEvents += "HIDDEN;";
|
2011-11-10 02:09:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
let testSteps = [
|
|
|
|
function step0() {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Selecting tab0.");
|
2011-11-10 02:09:18 -08:00
|
|
|
gBrowser.selectedTab = tab0;
|
|
|
|
},
|
|
|
|
function step1() {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Selecting tab1.");
|
2011-11-10 02:09:18 -08:00
|
|
|
gBrowser.selectedTab = tab1;
|
|
|
|
},
|
|
|
|
function step2() {
|
2012-01-19 07:48:22 -08:00
|
|
|
info("Killing it.");
|
|
|
|
Tilt.destroy(Tilt.currentWindowId, true);
|
2012-01-15 23:00:56 -08:00
|
|
|
}
|
|
|
|
];
|
2011-11-10 02:09:18 -08:00
|
|
|
|
2013-04-09 16:05:09 -07:00
|
|
|
function finalize(win) {
|
2012-06-03 10:15:41 -07:00
|
|
|
if (!tabEvents) {
|
|
|
|
return;
|
|
|
|
}
|
2012-01-19 07:48:22 -08:00
|
|
|
|
2013-04-09 16:05:09 -07:00
|
|
|
is(win, tab1.linkedBrowser.contentWindow, "Saw the correct window");
|
|
|
|
|
|
|
|
is(tabEvents, "STARTUP;INITIALIZING;HIDDEN;SHOWN;DESTROYING;",
|
2012-01-15 23:00:56 -08:00
|
|
|
"The notifications weren't fired in the correct order.");
|
2011-11-10 02:09:18 -08:00
|
|
|
|
2012-06-03 10:15:41 -07:00
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanup() {
|
|
|
|
info("Cleaning up the notifications test.");
|
|
|
|
|
2012-01-15 23:00:56 -08:00
|
|
|
tab0 = null;
|
|
|
|
tab1 = null;
|
2011-11-10 02:09:18 -08:00
|
|
|
|
2012-06-03 10:15:41 -07:00
|
|
|
Services.obs.removeObserver(finalize, DESTROYED);
|
|
|
|
Services.obs.removeObserver(tab_INITIALIZING, INITIALIZING);
|
|
|
|
Services.obs.removeObserver(tab_DESTROYING, DESTROYING);
|
|
|
|
Services.obs.removeObserver(tab_SHOWN, SHOWN);
|
|
|
|
Services.obs.removeObserver(tab_HIDDEN, HIDDEN);
|
2013-10-14 02:54:46 -07:00
|
|
|
Services.obs.removeObserver(tab_STARTUP, STARTUP);
|
2012-01-15 23:00:56 -08:00
|
|
|
|
2012-06-03 10:15:41 -07:00
|
|
|
gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect);
|
2012-01-15 23:00:56 -08:00
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|
2011-11-10 02:09:18 -08:00
|
|
|
|
|
|
|
function tabSelect() {
|
|
|
|
if (testStep !== -1) {
|
|
|
|
executeSoon(testSteps[testStep]);
|
|
|
|
testStep++;
|
|
|
|
}
|
|
|
|
}
|