| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="resources/jquery-1.11.3.min.js"></script> |
| 4 <script> | 5 <script> |
| 6 var initialize_AdditionalPreload = function() { |
| 7 InspectorTest.preloadModule("frameworks_support"); |
| 8 } |
| 9 |
| 5 function test() | 10 function test() |
| 6 { | 11 { |
| 7 var windowObject; | 12 var windowObject; |
| 8 var divWithHandlers; | 13 var divWithHandlers; |
| 9 var divWithoutHandlers; | 14 var divWithoutHandlers; |
| 10 | 15 var divWithJQueryHandlers; |
| 11 function dumpListeners(next, listeners) | |
| 12 { | |
| 13 for (var i = 0; i < listeners.length; ++i) { | |
| 14 delete listeners[i]._location.scriptId; | |
| 15 var sourceName = listeners[i]._sourceName; | |
| 16 sourceName = sourceName.substr(sourceName.lastIndexOf('/') + 1); | |
| 17 listeners[i]._sourceName = sourceName; | |
| 18 | |
| 19 InspectorTest.addResult("type: " + listeners[i].type()); | |
| 20 InspectorTest.addResult("useCapture: " + listeners[i].useCapture()); | |
| 21 InspectorTest.addResult("location: " + listeners[i].location().colum
nNumber + ", " + listeners[i].location().lineNumber); | |
| 22 InspectorTest.addResult("handler: " + listeners[i].handler().descrip
tion); | |
| 23 InspectorTest.addResult("sourceName: " + listeners[i].sourceName()); | |
| 24 InspectorTest.addResult(""); | |
| 25 } | |
| 26 next(); | |
| 27 } | |
| 28 | 16 |
| 29 InspectorTest.runTestSuite([ | 17 InspectorTest.runTestSuite([ |
| 30 function testSetUp(next) | 18 function testSetUp(next) |
| 31 { | 19 { |
| 32 InspectorTest.RuntimeAgent.evaluate("window", "get-event-listeners-t
est", step1); | 20 InspectorTest.RuntimeAgent.evaluate(WebInspector.FrameworksSupport.e
ventListenersSetupFunction(), step1); |
| 33 | 21 |
| 34 function step1(error, result, wasThrown) | 22 function step1() |
| 35 { | 23 { |
| 36 windowObject = InspectorTest.runtimeModel.createRemoteObject(res
ult); | 24 InspectorTest.RuntimeAgent.evaluate("window", "get-event-listene
rs-test", step2); |
| 37 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"w
ith-handlers\")", "get-event-listeners-test", step2); | |
| 38 } | 25 } |
| 39 | 26 |
| 40 function step2(error, result, wasThrown) | 27 function step2(error, result, wasThrown) |
| 41 { | 28 { |
| 42 divWithHandlers = InspectorTest.runtimeModel.createRemoteObject(
result); | 29 windowObject = InspectorTest.runtimeModel.createRemoteObject(res
ult); |
| 43 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"w
ithout-handlers\")", "get-event-listeners-test", step3); | 30 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"w
ith-handlers\")", "get-event-listeners-test", step3); |
| 44 } | 31 } |
| 45 | 32 |
| 46 function step3(error, result, wasThrown) | 33 function step3(error, result, wasThrown) |
| 47 { | 34 { |
| 35 divWithHandlers = InspectorTest.runtimeModel.createRemoteObject(
result); |
| 36 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"w
ithout-handlers\")", "get-event-listeners-test", step4); |
| 37 } |
| 38 |
| 39 function step4(error, result, wasThrown) |
| 40 { |
| 48 divWithoutHandlers = InspectorTest.runtimeModel.createRemoteObje
ct(result); | 41 divWithoutHandlers = InspectorTest.runtimeModel.createRemoteObje
ct(result); |
| 42 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"j
query-handlers\")", "get-event-listeners-test", step5); |
| 43 } |
| 44 |
| 45 function step5(error, result, wasThrown) |
| 46 { |
| 47 divWithJQueryHandlers = InspectorTest.runtimeModel.createRemoteO
bject(result); |
| 49 next(); | 48 next(); |
| 50 } | 49 } |
| 51 }, | 50 }, |
| 52 | 51 |
| 53 function testWindowEventListeners(next) | 52 function testWindowEventListeners(next) |
| 54 { | 53 { |
| 55 windowObject.eventListeners().then(dumpListeners.bind(this, next)); | 54 windowObject.eventListeners().then(InspectorTest.dumpEventListeners.
bind(this, next)); |
| 56 }, | 55 }, |
| 57 | 56 |
| 58 function testDivEventListeners(next) | 57 function testDivEventListeners(next) |
| 59 { | 58 { |
| 60 divWithHandlers.eventListeners().then(dumpListeners.bind(this, next)
); | 59 divWithHandlers.eventListeners().then(InspectorTest.dumpEventListene
rs.bind(this, next)); |
| 61 }, | 60 }, |
| 62 | 61 |
| 63 function testDivWithoutEventListeners(next) | 62 function testDivWithoutEventListeners(next) |
| 64 { | 63 { |
| 65 divWithoutHandlers.eventListeners().then(dumpListeners.bind(this, ne
xt)); | 64 divWithoutHandlers.eventListeners().then(InspectorTest.dumpEventList
eners.bind(this, next)); |
| 66 } | 65 }, |
| 66 |
| 67 function testDivJQueryResolvedEventListeners(next) |
| 68 { |
| 69 divWithJQueryHandlers.eventListeners().then(InspectorTest.dumpEventL
isteners.bind(this, next)); |
| 70 }, |
| 67 ]); | 71 ]); |
| 68 } | 72 } |
| 69 | 73 |
| 70 </script> | 74 </script> |
| 71 </head> | 75 </head> |
| 72 <body> | 76 <body> |
| 73 <p> | 77 <p> |
| 74 Tests RemoteObject.eventListeners. | 78 Tests RemoteObject.eventListeners. |
| 75 </p> | 79 </p> |
| 76 <div id="with-handlers" onclick="return 42;"></div> | 80 <div id="with-handlers" onclick="return 42;"></div> |
| 77 <div id="without-handlers"></div> | 81 <div id="without-handlers"></div> |
| 82 <div id="jquery-handlers"></div> |
| 78 <script> | 83 <script> |
| 79 function foo() {} | 84 function foo() {} |
| 80 function boo() {} | 85 function boo() {} |
| 81 window.addEventListener("scroll", foo, true); | 86 window.addEventListener("scroll", foo, true); |
| 82 document.getElementById("with-handlers").addEventListener("click", boo, true
); | 87 document.getElementById("with-handlers").addEventListener("click", boo, true
); |
| 83 document.getElementById("with-handlers").addEventListener("mouseout", foo, f
alse); | 88 document.getElementById("with-handlers").addEventListener("mouseout", foo, f
alse); |
| 89 |
| 90 node = $("#jquery-handlers")[0]; |
| 91 $("#jquery-handlers").click(function(){ console.log("first jquery"); }); |
| 92 $("#jquery-handlers").click(function(){ console.log("second jquery"); }); |
| 93 node.addEventListener("click", function() { console.log("addEventListener");
}); |
| 94 node.onclick = function() { console.log("onclick"); }; |
| 95 |
| 84 runTest(); | 96 runTest(); |
| 85 </script> | 97 </script> |
| 86 </body> | 98 </body> |
| 87 </html> | 99 </html> |
| OLD | NEW |