Commit 5b5d3a74 authored by aandrey@chromium.org's avatar aandrey@chromium.org

DevTools: Support XHR event listener breakpoints on frontend.

BUG=381470
R=yurys@chromium.org, pfeldman@chromium.org, vsevik, yurys

Review URL: https://codereview.chromium.org/321113005

git-svn-id: svn://svn.chromium.org/blink/trunk@176318 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cfaa5579
Tests event listener breakpoints on XHRs.
Set timer for test function.
Captured call stacks in no particular order:
Call stack:
0) downloadEnd (event-listener-breakpoints-xhr.html:19)
Event target: XMLHttpRequest
Call stack:
0) downloadProgress (event-listener-breakpoints-xhr.html:27)
Event target: XMLHttpRequest
Call stack:
0) loadCallback (event-listener-breakpoints-xhr.html:35)
Event target: XMLHttpRequest
Call stack:
0) uploadEnd (event-listener-breakpoints-xhr.html:23)
Event target: XMLHttpRequestUpload
Call stack:
0) uploadProgress (event-listener-breakpoints-xhr.html:31)
Event target: XMLHttpRequestUpload
Call stack:
0) xhr.onreadystatechange (event-listener-breakpoints-xhr.html:15)
1) sendXHR (event-listener-breakpoints-xhr.html:46)
2) testFunction (event-listener-breakpoints-xhr.html:9)
Event target: XMLHttpRequest
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
sendXHR();
}
function sendXHR()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function()
{
xhr.onreadystatechange = null;
};
function downloadEnd()
{
xhr.removeEventListener("loadend", downloadEnd, false);
}
function uploadEnd()
{
xhr.upload.removeEventListener("loadend", uploadEnd, false);
}
function downloadProgress()
{
xhr.removeEventListener("progress", downloadProgress, false);
}
function uploadProgress()
{
xhr.upload.removeEventListener("progress", uploadProgress, false);
}
function loadCallback()
{
xhr.onload = null;
xhr.onerror = null;
}
xhr.onload = loadCallback;
xhr.onerror = loadCallback;
xhr.addEventListener("loadend", downloadEnd, false);
xhr.addEventListener("progress", downloadProgress, false);
xhr.upload.addEventListener("loadend", uploadEnd, false);
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.open("POST", "http://localhost/?now=" + Date.now(), true);
xhr.send(String(sendXHR));
}
function test()
{
var pane = WebInspector.panels.sources.sidebarPanes.eventListenerBreakpoints;
var xhrTargetNames = ["XMLHttpRequest", "XMLHttpRequestUpload"];
InspectorTest.setQuiet(true);
InspectorTest.startDebuggerTest(step1);
function step1()
{
pane._setBreakpoint("listener:load");
pane._setBreakpoint("listener:error");
pane._setBreakpoint("listener:loadend", xhrTargetNames);
pane._setBreakpoint("listener:progress", xhrTargetNames);
pane._setBreakpoint("listener:readystatechange", xhrTargetNames);
InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
}
var totalBreaks = 6;
var callStacksOutput = [];
function didPause(callFrames, reason, breakpointIds, asyncStackTrace, auxData)
{
--totalBreaks;
auxData = auxData || {};
var result = InspectorTest.captureStackTraceIntoString(callFrames) + "\n";
result += "Event target: " + auxData["targetName"] + "\n";
callStacksOutput.push(result);
if (totalBreaks) {
InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
} else {
InspectorTest.addResult("Captured call stacks in no particular order:");
callStacksOutput.sort();
InspectorTest.addResults(callStacksOutput);
InspectorTest.completeDebuggerTest();
}
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests event listener breakpoints on XHRs.
</p>
</body>
</html>
...@@ -85,8 +85,8 @@ function test() ...@@ -85,8 +85,8 @@ function test()
function testLoadBreakpointOnXHR(next) function testLoadBreakpointOnXHR(next)
{ {
DOMDebuggerAgent.setEventListenerBreakpoint("load", "xmlHTTPrequest"); // test case-insensitive match pane._setBreakpoint("listener:load", ["xmlHTTPrequest"]); // test case-insensitive match
DOMDebuggerAgent.setEventListenerBreakpoint("error", "XMLHttpRequest"); pane._setBreakpoint("listener:error", ["XMLHttpRequest"]);
InspectorTest.waitUntilPaused(paused); InspectorTest.waitUntilPaused(paused);
InspectorTest.evaluateInPageWithTimeout("addLoadListeners()"); InspectorTest.evaluateInPageWithTimeout("addLoadListeners()");
...@@ -94,8 +94,8 @@ function test() ...@@ -94,8 +94,8 @@ function test()
{ {
InspectorTest.captureStackTrace(callFrames); InspectorTest.captureStackTrace(callFrames);
printEventTargetName(auxData); printEventTargetName(auxData);
DOMDebuggerAgent.removeEventListenerBreakpoint("load", "XMLHttpRequest"); pane._removeBreakpoint("listener:load", ["XMLHttpRequest"]);
DOMDebuggerAgent.removeEventListenerBreakpoint("error", "xmlHTTPrequest"); pane._removeBreakpoint("listener:error", ["xmlHTTPrequest"]);
InspectorTest.resumeExecution(resumed); InspectorTest.resumeExecution(resumed);
} }
......
...@@ -277,15 +277,16 @@ WebInspector.SourcesPanel.prototype = { ...@@ -277,15 +277,16 @@ WebInspector.SourcesPanel.prototype = {
WebInspector.domBreakpointsSidebarPane.highlightBreakpoint(details.auxData); WebInspector.domBreakpointsSidebarPane.highlightBreakpoint(details.auxData);
WebInspector.domBreakpointsSidebarPane.createBreakpointHitStatusMessage(details, didCreateBreakpointHitStatusMessage.bind(this)); WebInspector.domBreakpointsSidebarPane.createBreakpointHitStatusMessage(details, didCreateBreakpointHitStatusMessage.bind(this));
} else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventListener) { } else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventListener) {
var eventName = details.auxData.eventName; var eventName = details.auxData["eventName"];
this.sidebarPanes.eventListenerBreakpoints.highlightBreakpoint(details.auxData.eventName); var targetName = details.auxData["targetName"];
this.sidebarPanes.eventListenerBreakpoints.highlightBreakpoint(eventName, targetName);
var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName, details.auxData); var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName, details.auxData);
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" Event Listener.", eventNameForUI)); this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" Event Listener.", eventNameForUI));
} else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) { } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) {
this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]); this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]);
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest.")); this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest."));
} else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception) } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception)
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", details.auxData.description)); this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", details.auxData["description"]));
else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert) else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert)
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion.")); this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));
else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation) else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment