summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/markup/test/browser_markup_events_react_production_16.2.0_jsx.js
blob: 4aedb216e23eef1a3e34bfae2f85bd123e4afaf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";

requestLongerTimeout(4);

// Test that markup view event bubbles show the correct event info for React
// events (React production version 16.2.0) using JSX.

const TEST_LIB = URL_ROOT_SSL + "lib_react_dom_16.2.0_min.js";
const TEST_LIB_BABEL = URL_ROOT_SSL + "lib_babel_6.21.0_min.js";
const TEST_EXTERNAL_LISTENERS = URL_ROOT_SSL + "react_external_listeners.js";
const TEST_URL =
  URL_ROOT_SSL + "doc_markup_events_react_production_16.2.0_jsx.html";

loadHelperScript("helper_events_test_runner.js");

/*eslint-disable */
const TEST_DATA = [
  {
    selector: "#inlinejsx",
    expected: [
      {
        type: "click",
        filename: TEST_LIB + ":93:417",
        attributes: ["Bubbling"],
        handler: `function() {}`,
      },
      {
        type: "onClick",
        filename: TEST_LIB_BABEL + ":26:34",
        attributes: ["React", "Bubbling"],
        handler: `
          function inlineFunction() {
            alert("inlineFunction");
          }`,
      },
    ],
  },
  {
    selector: "#externaljsx",
    expected: [
      {
        type: "click",
        filename: TEST_LIB + ":93:417",
        attributes: ["Bubbling"],
        handler: `function() {}`,
      },
      {
        type: "onClick",
        filename: TEST_EXTERNAL_LISTENERS + ":4:25",
        attributes: ["React", "Bubbling"],
        handler: `
          function externalFunction() {
            alert("externalFunction");
          }`,
      },
    ],
  },
  {
    selector: "#externalinlinejsx",
    expected: [
      {
        type: "click",
        filename: TEST_LIB + ":93:417",
        attributes: ["Bubbling"],
        handler: `function() {}`,
      },
      {
        type: "onClick",
        filename: TEST_EXTERNAL_LISTENERS + ":4:25",
        attributes: ["React", "Bubbling"],
        handler: `
          function externalFunction() {
            alert("externalFunction");
          }`,
      },
      {
        type: "onMouseUp",
        filename: TEST_LIB_BABEL + ":26:34",
        attributes: ["React", "Bubbling"],
        handler: `
          function inlineFunction() {
            alert("inlineFunction");
          }`,
      },
    ],
  },
  {
    selector: "#externalcapturingjsx",
    expected: [
      {
        type: "onClickCapture",
        filename: TEST_EXTERNAL_LISTENERS + ":8:34",
        attributes: ["React", "Capturing"],
        handler: `
          function externalCapturingFunction() {
            alert("externalCapturingFunction");
          }`,
      },
    ],
  },
];
/* eslint-enable */

add_task(async function () {
  info(
    "Switch to 2 pane inspector to avoid sidebar width issues with opening events"
  );
  await pushPref("devtools.inspector.three-pane-enabled", false);
  await pushPref("devtools.toolsidebar-width.inspector", 350);
  await runEventPopupTests(TEST_URL, TEST_DATA);
});