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