Commit 86e3e3a5 authored by venuatu@gmail.com's avatar venuatu@gmail.com

Break on window close when the inspector is open

BUG=171447

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

git-svn-id: svn://svn.chromium.org/blink/trunk@179121 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 89773f47
CONSOLE MESSAGE: line 1: Starting test
CONSOLE MESSAGE: line 1: Setting breakpoint
CONSOLE MESSAGE: line 1: Calling window.close()
CONSOLE MESSAGE: line 1: Paused in breakpoint
CONSOLE MESSAGE: line 1: 0) doClose (script-window-close-breakpoint.html:10)
FAIL: main window was destroyed
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script>
function doClose()
{
window.close();
}
function onload()
{
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.showWebInspector();
}
runTest();
}
var test = function()
{
// This is needed because Inspector.addResult() uses output() which places elements
// into the <body> which gets disposed along with the window
function log(message) {
InspectorTest.evaluateInPage("console.log(unescape('"+ escape(message) +"'));");
}
log("Starting test");
WebInspector.inspectorView.showPanel("sources");
var pane = WebInspector.panels.sources.sidebarPanes.eventListenerBreakpoints;
InspectorTest.startDebuggerTest(testCloseBreakpoint);
function testCloseBreakpoint(next)
{
log("Setting breakpoint");
pane._setBreakpoint('instrumentation:close');
log("Calling window.close()");
InspectorTest.waitUntilPaused(paused);
InspectorTest.evaluateInPage("doClose()");
function paused(callFrames)
{
log("Paused in breakpoint");
// get the first stack frame
log(InspectorTest.captureStackTraceIntoString(callFrames).split('\n')[1].trim());
pane._removeBreakpoint('instrumentation:close');
InspectorTest.completeDebuggerTest();
// After this point execution will resume and the window will close
}
}
}
</script>
</head>
<body onload="onload()">
<p>Tests the window close breakpoint.
</p>
</body>
</html>
......@@ -992,6 +992,8 @@ void LocalDOMWindow::close(ExecutionContext* context)
if (!m_frame->loader().shouldClose())
return;
InspectorInstrumentation::willCloseWindow(context);
page->chrome().closeWindowSoon();
}
......
......@@ -63,6 +63,7 @@ static const char animationFrameFiredEventName[] = "animationFrameFired";
static const char setTimerEventName[] = "setTimer";
static const char clearTimerEventName[] = "clearTimer";
static const char timerFiredEventName[] = "timerFired";
static const char windowCloseEventName[] = "close";
static const char customElementCallbackName[] = "customElementCallback";
static const char webglErrorFiredEventName[] = "webglErrorFired";
static const char webglWarningFiredEventName[] = "webglWarningFired";
......@@ -493,6 +494,11 @@ void InspectorDOMDebuggerAgent::willHandleEvent(EventTarget* target, Event* even
pauseOnNativeEventIfNeeded(preparePauseOnNativeEventData(event->type(), &targetName), false);
}
void InspectorDOMDebuggerAgent::willCloseWindow()
{
pauseOnNativeEventIfNeeded(preparePauseOnNativeEventData(windowCloseEventName, 0), true);
}
void InspectorDOMDebuggerAgent::willExecuteCustomElementCallback(Element*)
{
pauseOnNativeEventIfNeeded(preparePauseOnNativeEventData(customElementCallbackName, 0), false);
......
......@@ -97,6 +97,7 @@ public:
void didFireWebGLWarning();
void didFireWebGLErrorOrWarning(const String& message);
void willExecuteCustomElementCallback(Element*);
void willCloseWindow();
void didProcessTask();
......
......@@ -70,6 +70,9 @@ interface InspectorInstrumentation {
[Page, Inspector, PageDebugger, PageRuntime]
void didClearDocumentOfWindowObject([Keep] LocalFrame*);
[DOMDebugger, Inline=FastReturn]
void willCloseWindow(ExecutionContext*);
[DOMDebugger, Inline=FastReturn]
void willInsertDOMNode([Keep] Node* parent);
......
......@@ -542,6 +542,7 @@ WebInspector.EventListenerBreakpointsSidebarPane = function()
this._createCategory(WebInspector.UIString("Touch"), ["touchstart", "touchmove", "touchend", "touchcancel"]);
this._createCategory(WebInspector.UIString("XHR"), ["readystatechange", "load", "loadstart", "loadend", "abort", "error", "progress", "timeout"], false, ["XMLHttpRequest", "XMLHttpRequestUpload"]);
this._createCategory(WebInspector.UIString("WebGL"), ["webglErrorFired", "webglWarningFired"], true);
this._createCategory(WebInspector.UIString("Window"), ["close"], true);
this._restoreBreakpoints();
}
......
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