Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / debugger-test.js
index ed81490..0f2d55a 100644 (file)
@@ -14,7 +14,7 @@ InspectorTest.startDebuggerTest = function(callback, quiet)
 
 InspectorTest.completeDebuggerTest = function()
 {
-    WebInspector.debuggerModel.setBreakpointsActive(true);
+    WebInspector.breakpointManager.setBreakpointsActive(true);
     InspectorTest.resumeExecution(InspectorTest.completeTest.bind(InspectorTest));
 };
 
@@ -159,6 +159,51 @@ InspectorTest.waitUntilPausedAndDumpStackAndResume = function(callback, options)
     }
 };
 
+InspectorTest.waitUntilPausedAndPerformSteppingActions = function(actions, callback)
+{
+    callback = InspectorTest.safeWrap(callback);
+    InspectorTest.waitUntilPaused(didPause);
+
+    function didPause(callFrames, reason, breakpointIds, asyncStackTrace)
+    {
+        var action = actions.shift();
+        if (action === "Print") {
+            InspectorTest.captureStackTrace(callFrames, asyncStackTrace);
+            InspectorTest.addResult("");
+            while (action === "Print")
+                action = actions.shift();
+        }
+
+        if (!action) {
+            callback()
+            return;
+        }
+
+        InspectorTest.addResult("Executing " + action + "...");
+
+        switch (action) {
+        case "StepInto":
+            WebInspector.panels.sources._stepIntoButton.element.click();
+            break;
+        case "StepOver":
+            WebInspector.panels.sources._stepOverButton.element.click();
+            break;
+        case "StepOut":
+            WebInspector.panels.sources._stepOutButton.element.click();
+            break;
+        case "Resume":
+            WebInspector.panels.sources.togglePause();
+            break;
+        default:
+            InspectorTest.addResult("FAIL: Unknown action: " + action);
+            callback()
+            return;
+        }
+
+        InspectorTest.waitUntilResumed(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
+    }
+};
+
 InspectorTest.captureStackTrace = function(callFrames, asyncStackTrace, options)
 {
     InspectorTest.addResult(InspectorTest.captureStackTraceIntoString(callFrames, asyncStackTrace, options));
@@ -175,7 +220,7 @@ InspectorTest.captureStackTraceIntoString = function(callFrames, asyncStackTrace
         for (var i = 0; i < callFrames.length; i++) {
             var frame = callFrames[i];
             var script = WebInspector.debuggerModel.scriptForId(frame.location().scriptId);
-            var isFramework = script.isFramework();
+            var isFramework = WebInspector.BlackboxSupport.isBlackboxedURL(script.sourceURL);
             if (options.dropFrameworkCallFrames && isFramework)
                 continue;
             var url;
@@ -200,7 +245,7 @@ InspectorTest.captureStackTraceIntoString = function(callFrames, asyncStackTrace
 
     while (asyncStackTrace) {
         results.push("    [" + (asyncStackTrace.description || "Async Call") + "]");
-        var printed = printCallFrames(WebInspector.DebuggerModel.CallFrame.fromPayloadArray(WebInspector.targetManager.activeTarget(), asyncStackTrace.callFrames));
+        var printed = printCallFrames(WebInspector.DebuggerModel.CallFrame.fromPayloadArray(WebInspector.targetManager.mainTarget(), asyncStackTrace.callFrames));
         if (!printed)
             results.pop();
         if (asyncStackTrace.callFrames.peekLast().functionName === "testFunction")
@@ -223,7 +268,7 @@ InspectorTest._pausedScript = function(callFrames, reason, auxData, breakpointId
 {
     if (!InspectorTest._quiet)
         InspectorTest.addResult("Script execution paused.");
-    InspectorTest._pausedScriptArguments = [WebInspector.DebuggerModel.CallFrame.fromPayloadArray(WebInspector.targetManager.activeTarget(), callFrames), reason, breakpointIds, asyncStackTrace, auxData];
+    InspectorTest._pausedScriptArguments = [WebInspector.DebuggerModel.CallFrame.fromPayloadArray(WebInspector.targetManager.mainTarget(), callFrames), reason, breakpointIds, asyncStackTrace, auxData];
     if (InspectorTest._waitUntilPausedCallback) {
         var callback = InspectorTest._waitUntilPausedCallback;
         delete InspectorTest._waitUntilPausedCallback;
@@ -371,20 +416,23 @@ InspectorTest.queryScripts = function(filter)
     return scripts;
 };
 
-InspectorTest.createScriptMock = function(url, startLine, startColumn, isContentScript, source)
+InspectorTest.createScriptMock = function(url, startLine, startColumn, isContentScript, source, target, preRegisterCallback)
 {
+    target = target || WebInspector.targetManager.mainTarget();
     var scriptId = ++InspectorTest._lastScriptId;
     var lineCount = source.lineEndings().length;
     var endLine = startLine + lineCount - 1;
     var endColumn = lineCount === 1 ? startColumn + source.length : source.length - source.lineEndings()[lineCount - 2];
     var hasSourceURL = !!source.match(/\/\/#\ssourceURL=\s*(\S*?)\s*$/m) || !!source.match(/\/\/@\ssourceURL=\s*(\S*?)\s*$/m);
-    var script = new WebInspector.Script(WebInspector.targetManager.activeTarget(), scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, null, hasSourceURL);
+    var script = new WebInspector.Script(target, scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, null, hasSourceURL);
     script.requestContent = function(callback)
     {
         var trimmedSource = WebInspector.Script._trimSourceURLComment(source);
         callback(trimmedSource, false, "text/javascript");
     };
-    WebInspector.debuggerModel._registerScript(script);
+    if (preRegisterCallback)
+        preRegisterCallback(script);
+    target.debuggerModel._registerScript(script);
     return script;
 };
 
@@ -407,7 +455,7 @@ InspectorTest.checkUILocation = function(uiSourceCode, lineNumber, columnNumber,
 
 InspectorTest.scriptFormatter = function()
 {
-    var editorActions = WebInspector.moduleManager.instances(WebInspector.SourcesView.EditorAction);
+    var editorActions = self.runtime.instances(WebInspector.SourcesView.EditorAction);
     for (var i = 0; i < editorActions.length; ++i) {
         if (editorActions[i] instanceof WebInspector.ScriptFormatterEditorAction)
             return editorActions[i];