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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-07.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,104 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests that system event listeners don't get duplicated in the view.
     1.9 + */
    1.10 +
    1.11 +function test() {
    1.12 +  initDebugger("about:blank").then(([aTab, aDebuggee, aPanel]) => {
    1.13 +    let gDebugger = aPanel.panelWin;
    1.14 +    let gView = gDebugger.DebuggerView;
    1.15 +    let gEvents = gView.EventListeners;
    1.16 +    let gL10N = gDebugger.L10N;
    1.17 +
    1.18 +    is(gEvents.itemCount, 0,
    1.19 +      "There are no events displayed in the corresponding pane yet.");
    1.20 +
    1.21 +    gEvents.addListener({
    1.22 +      type: "foo",
    1.23 +      node: { selector: "#first" },
    1.24 +      function: { url: null }
    1.25 +    });
    1.26 +
    1.27 +    is(gEvents.itemCount, 1,
    1.28 +      "There was a system event listener added in the view.");
    1.29 +    is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
    1.30 +      "The correct string is used as the event's url.");
    1.31 +    is(gEvents.attachments[0].type, "foo",
    1.32 +      "The correct string is used as the event's type.");
    1.33 +    is(gEvents.attachments[0].selectors.toString(), "#first",
    1.34 +      "The correct array of selectors is used as the event's target.");
    1.35 +
    1.36 +    gEvents.addListener({
    1.37 +      type: "bar",
    1.38 +      node: { selector: "#second" },
    1.39 +      function: { url: null }
    1.40 +    });
    1.41 +
    1.42 +    is(gEvents.itemCount, 2,
    1.43 +      "There was another system event listener added in the view.");
    1.44 +    is(gEvents.attachments[1].url, gL10N.getStr("eventNative"),
    1.45 +      "The correct string is used as the event's url.");
    1.46 +    is(gEvents.attachments[1].type, "bar",
    1.47 +      "The correct string is used as the event's type.");
    1.48 +    is(gEvents.attachments[1].selectors.toString(), "#second",
    1.49 +      "The correct array of selectors is used as the event's target.");
    1.50 +
    1.51 +    gEvents.addListener({
    1.52 +      type: "foo",
    1.53 +      node: { selector: "#first" },
    1.54 +      function: { url: null }
    1.55 +    });
    1.56 +
    1.57 +    is(gEvents.itemCount, 2,
    1.58 +      "There wasn't another system event listener added in the view.");
    1.59 +    is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
    1.60 +      "The correct string is used as the event's url.");
    1.61 +    is(gEvents.attachments[0].type, "foo",
    1.62 +      "The correct string is used as the event's type.");
    1.63 +    is(gEvents.attachments[0].selectors.toString(), "#first",
    1.64 +      "The correct array of selectors is used as the event's target.");
    1.65 +
    1.66 +    gEvents.addListener({
    1.67 +      type: "foo",
    1.68 +      node: { selector: "#second" },
    1.69 +      function: { url: null }
    1.70 +    });
    1.71 +
    1.72 +    is(gEvents.itemCount, 2,
    1.73 +      "There still wasn't another system event listener added in the view.");
    1.74 +    is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
    1.75 +      "The correct string is used as the event's url.");
    1.76 +    is(gEvents.attachments[0].type, "foo",
    1.77 +      "The correct string is used as the event's type.");
    1.78 +    is(gEvents.attachments[0].selectors.toString(), "#first,#second",
    1.79 +      "The correct array of selectors is used as the event's target.");
    1.80 +
    1.81 +
    1.82 +    gEvents.addListener({
    1.83 +      type: null,
    1.84 +      node: { selector: "#bogus" },
    1.85 +      function: { url: null }
    1.86 +    });
    1.87 +
    1.88 +    is(gEvents.itemCount, 2,
    1.89 +      "No bogus system event listener was added in the view.");
    1.90 +
    1.91 +    is(gEvents.attachments[0].url, gL10N.getStr("eventNative"),
    1.92 +      "The correct string is used as the first event's url.");
    1.93 +    is(gEvents.attachments[0].type, "foo",
    1.94 +      "The correct string is used as the first event's type.");
    1.95 +    is(gEvents.attachments[0].selectors.toString(), "#first,#second",
    1.96 +      "The correct array of selectors is used as the first event's target.");
    1.97 +
    1.98 +    is(gEvents.attachments[1].url, gL10N.getStr("eventNative"),
    1.99 +      "The correct string is used as the second event's url.");
   1.100 +    is(gEvents.attachments[1].type, "bar",
   1.101 +      "The correct string is used as the second event's type.");
   1.102 +    is(gEvents.attachments[1].selectors.toString(), "#second",
   1.103 +      "The correct array of selectors is used as the second event's target.");
   1.104 +
   1.105 +    closeDebuggerAndFinish(aPanel);
   1.106 +  });
   1.107 +}

mercurial