browser/devtools/tilt/test/browser_tilt_02_notifications-seq.js

branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
equal deleted inserted replaced
-1:000000000000 0:6ea4112b33c3
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3 "use strict";
4
5 let tabEvents = "";
6
7 function test() {
8 if (!isTiltEnabled()) {
9 info("Skipping notifications test because Tilt isn't enabled.");
10 return;
11 }
12 if (!isWebGLSupported()) {
13 info("Skipping notifications test because WebGL isn't supported.");
14 return;
15 }
16
17 requestLongerTimeout(10);
18 waitForExplicitFinish();
19
20 createTab(function() {
21 Services.obs.addObserver(finalize, DESTROYED, false);
22 Services.obs.addObserver(obs_STARTUP, STARTUP, false);
23 Services.obs.addObserver(obs_INITIALIZING, INITIALIZING, false);
24 Services.obs.addObserver(obs_INITIALIZED, INITIALIZED, false);
25 Services.obs.addObserver(obs_DESTROYING, DESTROYING, false);
26 Services.obs.addObserver(obs_BEFORE_DESTROYED, BEFORE_DESTROYED, false);
27 Services.obs.addObserver(obs_DESTROYED, DESTROYED, false);
28
29 info("Starting up the Tilt notifications test.");
30 createTilt({}, false, function suddenDeath()
31 {
32 info("Tilt could not be initialized properly.");
33 cleanup();
34 });
35 });
36 }
37
38 function obs_STARTUP(win) {
39 info("Handling the STARTUP notification.");
40 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
41 tabEvents += "STARTUP;";
42 }
43
44 function obs_INITIALIZING(win) {
45 info("Handling the INITIALIZING notification.");
46 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
47 tabEvents += "INITIALIZING;";
48 }
49
50 function obs_INITIALIZED(win) {
51 info("Handling the INITIALIZED notification.");
52 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
53 tabEvents += "INITIALIZED;";
54
55 Tilt.destroy(Tilt.currentWindowId, true);
56 }
57
58 function obs_DESTROYING(win) {
59 info("Handling the DESTROYING( notification.");
60 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
61 tabEvents += "DESTROYING;";
62 }
63
64 function obs_BEFORE_DESTROYED(win) {
65 info("Handling the BEFORE_DESTROYED notification.");
66 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
67 tabEvents += "BEFORE_DESTROYED;";
68 }
69
70 function obs_DESTROYED(win) {
71 info("Handling the DESTROYED notification.");
72 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
73 tabEvents += "DESTROYED;";
74 }
75
76 function finalize(win) {
77 if (!tabEvents) {
78 return;
79 }
80
81 is(win, gBrowser.selectedBrowser.contentWindow, "Saw the correct window");
82 is(tabEvents, "STARTUP;INITIALIZING;INITIALIZED;DESTROYING;BEFORE_DESTROYED;DESTROYED;",
83 "The notifications weren't fired in the correct order.");
84
85 cleanup();
86 }
87
88 function cleanup() {
89 info("Cleaning up the notifications test.");
90
91 Services.obs.removeObserver(finalize, DESTROYED);
92 Services.obs.removeObserver(obs_INITIALIZING, INITIALIZING);
93 Services.obs.removeObserver(obs_INITIALIZED, INITIALIZED);
94 Services.obs.removeObserver(obs_DESTROYING, DESTROYING);
95 Services.obs.removeObserver(obs_BEFORE_DESTROYED, BEFORE_DESTROYED);
96 Services.obs.removeObserver(obs_DESTROYED, DESTROYED);
97 Services.obs.removeObserver(obs_STARTUP, STARTUP);
98
99 gBrowser.removeCurrentTab();
100 finish();
101 }

mercurial