2011-11-10 02:09:18 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/*global ok, is, info, waitForExplicitFinish, finish, gBrowser */
|
|
|
|
/*global isTiltEnabled, isWebGLSupported, createTab, createTilt */
|
|
|
|
/*global Tilt, TiltUtils, TiltVisualizer */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
if (!isTiltEnabled()) {
|
|
|
|
info("Skipping initialization test because Tilt isn't enabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isWebGLSupported()) {
|
|
|
|
info("Skipping initialization test because WebGL isn't supported.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
createTab(function() {
|
|
|
|
let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow);
|
2011-12-16 00:28:46 -08:00
|
|
|
let initialActiveElement;
|
2011-11-10 02:09:18 -08:00
|
|
|
|
|
|
|
is(id, Tilt.currentWindowId,
|
|
|
|
"The unique window identifiers should match for the same window.");
|
|
|
|
|
|
|
|
createTilt({
|
|
|
|
onInspectorOpen: function() {
|
2011-12-16 00:28:46 -08:00
|
|
|
initialActiveElement = document.activeElement;
|
|
|
|
|
2011-11-10 02:09:18 -08:00
|
|
|
is(Tilt.visualizers[id], null,
|
|
|
|
"A instance of the visualizer shouldn't be initialized yet.");
|
|
|
|
|
|
|
|
is(typeof TiltVisualizer.Prefs.enabled, "boolean",
|
|
|
|
"The 'enabled' pref should have been loaded by now.");
|
|
|
|
is(typeof TiltVisualizer.Prefs.forceEnabled, "boolean",
|
|
|
|
"The 'force-enabled' pref should have been loaded by now.");
|
|
|
|
},
|
2011-12-16 00:28:46 -08:00
|
|
|
onTiltOpen: function(instance)
|
2011-11-10 02:09:18 -08:00
|
|
|
{
|
2011-12-16 00:28:46 -08:00
|
|
|
is(document.activeElement, instance.presenter.canvas,
|
|
|
|
"The visualizer canvas should be focused on initialization.");
|
|
|
|
|
2011-11-10 02:09:18 -08:00
|
|
|
ok(Tilt.visualizers[id] instanceof TiltVisualizer,
|
|
|
|
"A new instance of the visualizer wasn't created properly.");
|
|
|
|
ok(Tilt.visualizers[id].isInitialized(),
|
|
|
|
"The new instance of the visualizer wasn't initialized properly.");
|
|
|
|
},
|
|
|
|
onTiltClose: function()
|
|
|
|
{
|
2011-12-16 00:28:46 -08:00
|
|
|
is(document.activeElement, initialActiveElement,
|
|
|
|
"The focus wasn't correctly given back to the initial element.");
|
|
|
|
|
2011-11-10 02:09:18 -08:00
|
|
|
is(Tilt.visualizers[id], null,
|
|
|
|
"The current instance of the visualizer wasn't destroyed properly.");
|
|
|
|
},
|
|
|
|
onEnd: function()
|
|
|
|
{
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
});
|
|
|
|
}
|