michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that system event listeners don't get duplicated in the view. michael@0: */ michael@0: michael@0: function test() { michael@0: initDebugger("about:blank").then(([aTab, aDebuggee, aPanel]) => { michael@0: let gDebugger = aPanel.panelWin; michael@0: let gView = gDebugger.DebuggerView; michael@0: let gEvents = gView.EventListeners; michael@0: let gL10N = gDebugger.L10N; michael@0: michael@0: is(gEvents.itemCount, 0, michael@0: "There are no events displayed in the corresponding pane yet."); michael@0: michael@0: gEvents.addListener({ michael@0: type: "foo", michael@0: node: { selector: "#first" }, michael@0: function: { url: null } michael@0: }); michael@0: michael@0: is(gEvents.itemCount, 1, michael@0: "There was a system event listener added in the view."); michael@0: is(gEvents.attachments[0].url, gL10N.getStr("eventNative"), michael@0: "The correct string is used as the event's url."); michael@0: is(gEvents.attachments[0].type, "foo", michael@0: "The correct string is used as the event's type."); michael@0: is(gEvents.attachments[0].selectors.toString(), "#first", michael@0: "The correct array of selectors is used as the event's target."); michael@0: michael@0: gEvents.addListener({ michael@0: type: "bar", michael@0: node: { selector: "#second" }, michael@0: function: { url: null } michael@0: }); michael@0: michael@0: is(gEvents.itemCount, 2, michael@0: "There was another system event listener added in the view."); michael@0: is(gEvents.attachments[1].url, gL10N.getStr("eventNative"), michael@0: "The correct string is used as the event's url."); michael@0: is(gEvents.attachments[1].type, "bar", michael@0: "The correct string is used as the event's type."); michael@0: is(gEvents.attachments[1].selectors.toString(), "#second", michael@0: "The correct array of selectors is used as the event's target."); michael@0: michael@0: gEvents.addListener({ michael@0: type: "foo", michael@0: node: { selector: "#first" }, michael@0: function: { url: null } michael@0: }); michael@0: michael@0: is(gEvents.itemCount, 2, michael@0: "There wasn't another system event listener added in the view."); michael@0: is(gEvents.attachments[0].url, gL10N.getStr("eventNative"), michael@0: "The correct string is used as the event's url."); michael@0: is(gEvents.attachments[0].type, "foo", michael@0: "The correct string is used as the event's type."); michael@0: is(gEvents.attachments[0].selectors.toString(), "#first", michael@0: "The correct array of selectors is used as the event's target."); michael@0: michael@0: gEvents.addListener({ michael@0: type: "foo", michael@0: node: { selector: "#second" }, michael@0: function: { url: null } michael@0: }); michael@0: michael@0: is(gEvents.itemCount, 2, michael@0: "There still wasn't another system event listener added in the view."); michael@0: is(gEvents.attachments[0].url, gL10N.getStr("eventNative"), michael@0: "The correct string is used as the event's url."); michael@0: is(gEvents.attachments[0].type, "foo", michael@0: "The correct string is used as the event's type."); michael@0: is(gEvents.attachments[0].selectors.toString(), "#first,#second", michael@0: "The correct array of selectors is used as the event's target."); michael@0: michael@0: michael@0: gEvents.addListener({ michael@0: type: null, michael@0: node: { selector: "#bogus" }, michael@0: function: { url: null } michael@0: }); michael@0: michael@0: is(gEvents.itemCount, 2, michael@0: "No bogus system event listener was added in the view."); michael@0: michael@0: is(gEvents.attachments[0].url, gL10N.getStr("eventNative"), michael@0: "The correct string is used as the first event's url."); michael@0: is(gEvents.attachments[0].type, "foo", michael@0: "The correct string is used as the first event's type."); michael@0: is(gEvents.attachments[0].selectors.toString(), "#first,#second", michael@0: "The correct array of selectors is used as the first event's target."); michael@0: michael@0: is(gEvents.attachments[1].url, gL10N.getStr("eventNative"), michael@0: "The correct string is used as the second event's url."); michael@0: is(gEvents.attachments[1].type, "bar", michael@0: "The correct string is used as the second event's type."); michael@0: is(gEvents.attachments[1].selectors.toString(), "#second", michael@0: "The correct array of selectors is used as the second event's target."); michael@0: michael@0: closeDebuggerAndFinish(aPanel); michael@0: }); michael@0: }