browser/devtools/debugger/test/browser_dbg_break-on-dom-03.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 event listeners are properly displayed in the view.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_event-listeners-02.html";
    10 function test() {
    11   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    12     let gDebugger = aPanel.panelWin;
    13     let gView = gDebugger.DebuggerView;
    14     let gEvents = gView.EventListeners;
    16     Task.spawn(function() {
    17       yield waitForSourceShown(aPanel, ".html");
    19       let fetched = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_LISTENERS_FETCHED);
    20       gView.toggleInstrumentsPane({ visible: true, animated: false }, 1);
    21       yield fetched;
    23       is(gEvents.widget._parent.querySelectorAll(".side-menu-widget-group").length, 3,
    24         "There should be 3 groups shown in the view.");
    25       is(gEvents.widget._parent.querySelectorAll(".side-menu-widget-group-checkbox").length, 3,
    26         "There should be a checkbox for each group shown in the view.");
    28       is(gEvents.widget._parent.querySelectorAll(".side-menu-widget-item").length, 4,
    29         "There should be 4 items shown in the view.");
    30       is(gEvents.widget._parent.querySelectorAll(".side-menu-widget-item-checkbox").length, 4,
    31         "There should be a checkbox for each item shown in the view.");
    33       testEventItem(0, "doc_event-listeners-02.html", "keydown", ["window", "body"], false);
    34       testEventItem(1, "doc_event-listeners-02.html", "click", ["body > button:nth-child(1)"], false);
    35       testEventItem(2, "doc_event-listeners-02.html", "change", ["body > input:nth-child(2)"], false);
    36       testEventItem(3, "doc_event-listeners-02.html", "keyup", ["body > input:nth-child(2)"], false);
    38       testEventGroup("interactionEvents", false);
    39       testEventGroup("keyboardEvents", false);
    40       testEventGroup("mouseEvents", false);
    42       is(gEvents.getAllEvents().toString(), "keydown,click,change,keyup",
    43         "The getAllEvents() method returns the correct stuff.");
    44       is(gEvents.getCheckedEvents().toString(), "",
    45         "The getCheckedEvents() method returns the correct stuff.");
    47       yield ensureThreadClientState(aPanel, "resumed");
    48       yield closeDebuggerAndFinish(aPanel);
    49     });
    51     function testEventItem(index, label, type, selectors, checked) {
    52       let item = gEvents.items[index];
    53       let node = item.target;
    55       ok(item.attachment.url.contains(label),
    56         "The event at index " + index + " has the correct url.");
    57       is(item.attachment.type, type,
    58         "The event at index " + index + " has the correct type.");
    59       is(item.attachment.selectors.toString(), selectors,
    60         "The event at index " + index + " has the correct selectors.");
    61       is(item.attachment.checkboxState, checked,
    62         "The event at index " + index + " has the correct checkbox state.");
    64       let targets = selectors.length > 1
    65         ? gDebugger.L10N.getFormatStr("eventNodes", selectors.length)
    66         : selectors.toString();
    68       is(node.querySelector(".dbg-event-listener-type").getAttribute("value"), type,
    69         "The correct type is shown for this event.");
    70       is(node.querySelector(".dbg-event-listener-targets").getAttribute("value"), targets,
    71         "The correct target is shown for this event.");
    72       is(node.querySelector(".dbg-event-listener-location").getAttribute("value"), label,
    73         "The correct location is shown for this event.");
    74       is(node.parentNode.querySelector(".side-menu-widget-item-checkbox").checked, checked,
    75         "The correct checkbox state is shown for this event.");
    76     }
    78     function testEventGroup(string, checked) {
    79       let name = gDebugger.L10N.getStr(string);
    80       let group = gEvents.widget._parent
    81         .querySelector(".side-menu-widget-group[name=" + name + "]");
    83       is(group.querySelector(".side-menu-widget-group-title > .name").value, name,
    84         "The correct label is shown for the group named " + name + ".");
    85       is(group.querySelector(".side-menu-widget-group-checkbox").checked, checked,
    86         "The correct checkbox state is shown for the group named " + name + ".");
    87     }
    88   });
    89 }

mercurial