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