OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-protocol-test.js"></script> | |
4 <script> | |
5 | |
6 function test() | |
7 { | |
8 var objectId; | |
9 InspectorTest.sendCommand("DOM.enable", {}); | |
10 InspectorTest.sendCommand("Runtime.enable", {}); | |
11 InspectorTest.sendCommand("DOMDebugger.enable", {}); | |
12 InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "document
" }) | |
13 .then((result) => { objectId = result.result.result.objectId }) | |
14 .then(() => dumpListeners(objectId)) | |
15 .then(() => dumpListeners(objectId, 1)) | |
16 .then(() => dumpListeners(objectId, 4)) | |
17 .then(() => dumpListeners(objectId, -1)) | |
18 .then(() => dumpListeners(objectId, -1, true)) | |
19 .then(() => InspectorTest.completeTest()); | |
20 | |
21 function dumpListeners(objectId, depth, pierce) { | |
22 var params = {objectId : objectId}; | |
23 if (depth) | |
24 params.depth = depth; | |
25 if (pierce !== undefined) | |
26 params.pierce = pierce; | |
27 InspectorTest.log(`Fetching listeners for depth = ${depth} and pierce =
${pierce}`); | |
28 return InspectorTest.sendCommandPromise("DOMDebugger.getEventListeners",
params).then((result) => logResponse(result.result)); | |
29 } | |
30 | |
31 function stabilize(key, value) { | |
32 var unstableKeys = ["scriptId", "lineNumber", "columnNumber"]; | |
33 if (unstableKeys.indexOf(key) !== -1) | |
34 return "<" + typeof(value) + ">"; | |
35 return value; | |
36 } | |
37 | |
38 function logResponse(response) { | |
39 InspectorTest.log(JSON.stringify(response, stabilize, 2)); | |
40 } | |
41 } | |
42 | |
43 </script> | |
44 <template id="shadow-template" onclick="clickTemplate"> | |
45 <style> | |
46 :host { | |
47 color: red; | |
48 } | |
49 </style> | |
50 <div></div><h1>Hi from a template!</h1></div> | |
51 </template> | |
52 </head> | |
53 <body class="body-class" onload="runTest()"> | |
54 <div id="A"> A | |
55 <div id="B"> B | |
56 <div id="C"> C | |
57 </div> | |
58 </div> | |
59 </div> | |
60 | |
61 <iframe src="../dom/resources/iframe-with-listener.html" width="400" height=
"200"></iframe> | |
62 <div id="shadow-host"></div> | |
63 <script type="text/javascript"> | |
64 var host = document.querySelector("#shadow-host").createShadowRoot(); | |
65 var template = document.querySelector("#shadow-template"); | |
66 host.appendChild(template.content); | |
67 template.remove(); | |
68 document.getElementById("A").addEventListener("listenerA", () => {}); | |
69 document.getElementById("B").addEventListener("listenerB", () => {}); | |
70 document.getElementById("C").addEventListener("listenerC", () => {}); | |
71 document.addEventListener("documentListener", () => {}); | |
72 </script> | |
73 </body> | |
74 </html> | |
OLD | NEW |