Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / event-listener-breakpoints.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script>
6
7 function testElementClicked()
8 {
9     return 0;
10 }
11
12 function addListenerAndClick()
13 {
14     var element = document.getElementById("test");
15     element.addEventListener("click", testElementClicked, true);
16     element.click();
17 }
18
19 function timerFired()
20 {
21     return 0;
22 }
23
24 function addLoadListeners()
25 {
26     var xhr = new XMLHttpRequest();
27     xhr.onload = loadCallback;
28     xhr.onerror = loadCallback;
29     xhr.open("GET", "http://localhost/", true);
30
31     var img = new Image();
32     img.onload = sendXHR;
33     img.onerror = sendXHR;
34     img.src = "foo/bar/dummy";
35
36     function sendXHR()
37     {
38         xhr.send();
39     }
40 }
41
42 function loadCallback()
43 {
44     return 0;
45 }
46
47 function playVideo()
48 {
49     var video = document.getElementById("video");
50     video.addEventListener("play", onVideoPlay, false);
51     video.play();
52 }
53
54 function onVideoPlay()
55 {
56     return 0;
57 }
58
59 function test()
60 {
61     WebInspector.inspectorView.showPanel("sources");
62     var pane = WebInspector.panels.sources.sidebarPanes.eventListenerBreakpoints;
63     InspectorTest.runDebuggerTestSuite([
64         function testClickBreakpoint(next)
65         {
66             pane._setBreakpoint("listener:click");
67             InspectorTest.waitUntilPaused(paused);
68             InspectorTest.evaluateInPageWithTimeout("addListenerAndClick()");
69
70             function paused(callFrames, reason, breakpointIds, asyncStackTrace, auxData)
71             {
72                 InspectorTest.captureStackTrace(callFrames);
73                 printEventTargetName(auxData);
74                 pane._removeBreakpoint("listener:click");
75                 InspectorTest.resumeExecution(resumed);
76             }
77
78             function resumed()
79             {
80                 InspectorTest.evaluateInPage("addListenerAndClick()", next);
81             }
82         },
83
84         function testTimerFiredBreakpoint(next)
85         {
86             pane._setBreakpoint("instrumentation:timerFired");
87             InspectorTest.waitUntilPaused(paused);
88             InspectorTest.evaluateInPage("setTimeout(timerFired, 10)");
89
90             function paused(callFrames)
91             {
92                 InspectorTest.captureStackTrace(callFrames);
93                 pane._removeBreakpoint("instrumentation:timerFired");
94                 InspectorTest.resumeExecution(next);
95             }
96         },
97
98         function testLoadBreakpointOnXHR(next)
99         {
100             pane._setBreakpoint("listener:load", ["xmlHTTPrequest"]); // test case-insensitive match
101             pane._setBreakpoint("listener:error", ["XMLHttpRequest"]);
102             InspectorTest.waitUntilPaused(paused);
103             InspectorTest.evaluateInPageWithTimeout("addLoadListeners()");
104
105             function paused(callFrames, reason, breakpointIds, asyncStackTrace, auxData)
106             {
107                 InspectorTest.captureStackTrace(callFrames);
108                 printEventTargetName(auxData);
109                 pane._removeBreakpoint("listener:load", ["XMLHttpRequest"]);
110                 pane._removeBreakpoint("listener:error", ["xmlHTTPrequest"]);
111                 InspectorTest.resumeExecution(resumed);
112             }
113
114             function resumed()
115             {
116                 InspectorTest.evaluateInPage("addLoadListeners()", next);
117             }
118         },
119
120         function testMediaEventBreakpoint(next)
121         {
122             pane._setBreakpoint("listener:play", ["audio", "video"]);
123             InspectorTest.waitUntilPaused(paused);
124             InspectorTest.evaluateInPageWithTimeout("playVideo()");
125
126             function paused(callFrames, reason, breakpointIds, asyncStackTrace, auxData)
127             {
128                 InspectorTest.captureStackTrace(callFrames);
129                 printEventTargetName(auxData);
130                 pane._removeBreakpoint("listener:play", ["audio", "video"]);
131                 InspectorTest.resumeExecution(next);
132             }
133         }
134     ]);
135
136     function printEventTargetName(auxData)
137     {
138         var targetName = auxData && auxData.targetName;
139         if (targetName)
140             InspectorTest.addResult("Event target: " + targetName);
141         else
142             InspectorTest.addResult("FAIL: No event target name received!");
143     }
144 }
145
146 </script>
147 </head>
148
149 <body onload="runTest()">
150 <p>
151 Tests event listener breakpoints.
152 </p>
153
154 <input type=button id="test"></input>
155 <video id="video" src="../../../media/content/test.ogv"></video>
156
157 </body>
158 </html>