Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Tests that system event listeners don't get duplicated in the view.
6 */
8 function test() {
9 initDebugger("about:blank").then(([aTab, aDebuggee, aPanel]) => {
10 let gDebugger = aPanel.panelWin;
11 let gView = gDebugger.DebuggerView;
12 let gEvents = gView.EventListeners;
13 let gL10N = gDebugger.L10N;
15 is(gEvents.itemCount, 0,
16 "There are no events displayed in the corresponding pane yet.");
18 gEvents.addListener({
19 type: "foo",
20 node: { selector: "#first" },
21 function: { url: null }
22 });
24 is(gEvents.itemCount, 1,
25 "There was a system event listener added in the view.");
26 is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
27 "The correct string is used as the event's url.");
28 is(gEvents.attachments[0].type, "foo",
29 "The correct string is used as the event's type.");
30 is(gEvents.attachments[0].selectors.toString(), "#first",
31 "The correct array of selectors is used as the event's target.");
33 gEvents.addListener({
34 type: "bar",
35 node: { selector: "#second" },
36 function: { url: null }
37 });
39 is(gEvents.itemCount, 2,
40 "There was another system event listener added in the view.");
41 is(gEvents.attachments[1].url, gL10N.getStr("eventNative"),
42 "The correct string is used as the event's url.");
43 is(gEvents.attachments[1].type, "bar",
44 "The correct string is used as the event's type.");
45 is(gEvents.attachments[1].selectors.toString(), "#second",
46 "The correct array of selectors is used as the event's target.");
48 gEvents.addListener({
49 type: "foo",
50 node: { selector: "#first" },
51 function: { url: null }
52 });
54 is(gEvents.itemCount, 2,
55 "There wasn't another system event listener added in the view.");
56 is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
57 "The correct string is used as the event's url.");
58 is(gEvents.attachments[0].type, "foo",
59 "The correct string is used as the event's type.");
60 is(gEvents.attachments[0].selectors.toString(), "#first",
61 "The correct array of selectors is used as the event's target.");
63 gEvents.addListener({
64 type: "foo",
65 node: { selector: "#second" },
66 function: { url: null }
67 });
69 is(gEvents.itemCount, 2,
70 "There still wasn't another system event listener added in the view.");
71 is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
72 "The correct string is used as the event's url.");
73 is(gEvents.attachments[0].type, "foo",
74 "The correct string is used as the event's type.");
75 is(gEvents.attachments[0].selectors.toString(), "#first,#second",
76 "The correct array of selectors is used as the event's target.");
79 gEvents.addListener({
80 type: null,
81 node: { selector: "#bogus" },
82 function: { url: null }
83 });
85 is(gEvents.itemCount, 2,
86 "No bogus system event listener was added in the view.");
88 is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
89 "The correct string is used as the first event's url.");
90 is(gEvents.attachments[0].type, "foo",
91 "The correct string is used as the first event's type.");
92 is(gEvents.attachments[0].selectors.toString(), "#first,#second",
93 "The correct array of selectors is used as the first event's target.");
95 is(gEvents.attachments[1].url, gL10N.getStr("eventNative"),
96 "The correct string is used as the second event's url.");
97 is(gEvents.attachments[1].type, "bar",
98 "The correct string is used as the second event's type.");
99 is(gEvents.attachments[1].selectors.toString(), "#second",
100 "The correct array of selectors is used as the second event's target.");
102 closeDebuggerAndFinish(aPanel);
103 });
104 }