1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
5 // Test some basic functionality of KaiRo.at Mandelbrot.
7 Components.utils.import("resource://gre/modules/Services.jsm");
9 const MBROT_LOADED = "mandelbrot-loaded";
10 const TEST_DONE = "mandelbrot-test-done";
14 // Open KaiRo.at Mandelbrot, testing the menu item.
15 let menuitem = document.getElementById("tasksMenuMandelbrot") ||
16 document.getElementById("menu_openMandelbrot");
23 observe: function(aSubject, aTopic, aData) {
24 if (aTopic == MBROT_LOADED) {
25 Services.obs.removeObserver(testObs, MBROT_LOADED);
26 ok(true, "KaiRo.at Mandelbrot is loaded");
28 win = content.wrappedJSObject;
29 Services.obs.addObserver(testObs, TEST_DONE, false);
30 // Trigger the first test now!
31 Services.obs.notifyObservers(window, TEST_DONE, null);
34 // TEST_DONE triggered, run next test
35 info("run test #" + (testIndex + 1) + " of " + testFuncs.length +
36 " (" + testFuncs[testIndex].name + ")");
37 setTimeout(testFuncs[testIndex++], 0, win);
39 if (testIndex >= testFuncs.length) {
41 Services.obs.removeObserver(testObs, TEST_DONE);
42 Services.cookies.removeAll();
43 gLocSvc.fhist.removeAllEntries();
44 setTimeout(finish, 0);
49 waitForExplicitFinish();
50 Services.obs.addObserver(testObs, MBROT_LOADED, false);
54 function test_open_state(aWin) {
55 is(aWin.document.documentElement.id, "mandelbrot-page",
56 "The active tab is KaiRo.at Mandelbrot");
57 is(aWin.document.getElementById("drawButton").hidden, false,
58 "The draw button is not hidden");
59 Services.obs.notifyObservers(window, TEST_DONE, null);
62 function test_close(aWin) {
63 function dmWindowClosedListener() {
64 aWin.removeEventListener("unload", dmWindowClosedListener, false);
65 isnot(content.document.documentElement.id, "mandelbrot-page",
66 "The active tab is not KaiRo.at Mandelbrot");
67 Services.obs.notifyObservers(window, TEST_DONE, null);
69 aWin.addEventListener("unload", dmWindowClosedListener, false);