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 checking/unchecking an event listener in the view correctly |
michael@0 | 6 | * causes the active thread to get updated with the new event breakpoints. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_event-listeners-02.html"; |
michael@0 | 10 | |
michael@0 | 11 | function test() { |
michael@0 | 12 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 13 | let gDebugger = aPanel.panelWin; |
michael@0 | 14 | let gView = gDebugger.DebuggerView; |
michael@0 | 15 | let gController = gDebugger.DebuggerController |
michael@0 | 16 | let gEvents = gView.EventListeners; |
michael@0 | 17 | let gBreakpoints = gController.Breakpoints; |
michael@0 | 18 | |
michael@0 | 19 | Task.spawn(function() { |
michael@0 | 20 | yield waitForSourceShown(aPanel, ".html"); |
michael@0 | 21 | |
michael@0 | 22 | let fetched = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_LISTENERS_FETCHED); |
michael@0 | 23 | gView.toggleInstrumentsPane({ visible: true, animated: false }, 1); |
michael@0 | 24 | yield fetched; |
michael@0 | 25 | |
michael@0 | 26 | testEventItem(0, false); |
michael@0 | 27 | testEventItem(1, false); |
michael@0 | 28 | testEventItem(2, false); |
michael@0 | 29 | testEventItem(3, false); |
michael@0 | 30 | testEventGroup("interactionEvents", false); |
michael@0 | 31 | testEventGroup("keyboardEvents", false); |
michael@0 | 32 | testEventGroup("mouseEvents", false); |
michael@0 | 33 | testEventArrays("keydown,click,change,keyup", ""); |
michael@0 | 34 | |
michael@0 | 35 | let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED); |
michael@0 | 36 | EventUtils.sendMouseEvent({ type: "click" }, getItemCheckboxNode(0), gDebugger); |
michael@0 | 37 | yield updated; |
michael@0 | 38 | |
michael@0 | 39 | testEventItem(0, true); |
michael@0 | 40 | testEventItem(1, false); |
michael@0 | 41 | testEventItem(2, false); |
michael@0 | 42 | testEventItem(3, false); |
michael@0 | 43 | testEventGroup("interactionEvents", false); |
michael@0 | 44 | testEventGroup("keyboardEvents", false); |
michael@0 | 45 | testEventGroup("mouseEvents", false); |
michael@0 | 46 | testEventArrays("keydown,click,change,keyup", "keydown"); |
michael@0 | 47 | |
michael@0 | 48 | let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED); |
michael@0 | 49 | EventUtils.sendMouseEvent({ type: "click" }, getItemCheckboxNode(0), gDebugger); |
michael@0 | 50 | yield updated; |
michael@0 | 51 | |
michael@0 | 52 | testEventItem(0, false); |
michael@0 | 53 | testEventItem(1, false); |
michael@0 | 54 | testEventItem(2, false); |
michael@0 | 55 | testEventItem(3, false); |
michael@0 | 56 | testEventGroup("interactionEvents", false); |
michael@0 | 57 | testEventGroup("keyboardEvents", false); |
michael@0 | 58 | testEventGroup("mouseEvents", false); |
michael@0 | 59 | testEventArrays("keydown,click,change,keyup", ""); |
michael@0 | 60 | |
michael@0 | 61 | yield ensureThreadClientState(aPanel, "resumed"); |
michael@0 | 62 | yield closeDebuggerAndFinish(aPanel); |
michael@0 | 63 | }); |
michael@0 | 64 | |
michael@0 | 65 | function getItemCheckboxNode(index) { |
michael@0 | 66 | return gEvents.items[index].target.parentNode |
michael@0 | 67 | .querySelector(".side-menu-widget-item-checkbox"); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | function getGroupCheckboxNode(string) { |
michael@0 | 71 | return gEvents.widget._parent |
michael@0 | 72 | .querySelector(".side-menu-widget-group[name=" + gDebugger.L10N.getStr(string) + "]") |
michael@0 | 73 | .querySelector(".side-menu-widget-group-checkbox"); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | function testEventItem(index, checked) { |
michael@0 | 77 | is(gEvents.attachments[index].checkboxState, checked, |
michael@0 | 78 | "The event at index " + index + " has the correct checkbox state."); |
michael@0 | 79 | is(getItemCheckboxNode(index).checked, checked, |
michael@0 | 80 | "The correct checkbox state is shown for this event."); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function testEventGroup(string, checked) { |
michael@0 | 84 | is(getGroupCheckboxNode(string).checked, checked, |
michael@0 | 85 | "The correct checkbox state is shown for the group " + string + "."); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function testEventArrays(all, checked) { |
michael@0 | 89 | is(gEvents.getAllEvents().toString(), all, |
michael@0 | 90 | "The getAllEvents() method returns the correct stuff."); |
michael@0 | 91 | is(gEvents.getCheckedEvents().toString(), checked, |
michael@0 | 92 | "The getCheckedEvents() method returns the correct stuff."); |
michael@0 | 93 | is(gBreakpoints.DOM.activeEventNames.toString(), checked, |
michael@0 | 94 | "The correct event names are listed as being active breakpoints."); |
michael@0 | 95 | } |
michael@0 | 96 | }); |
michael@0 | 97 | } |