Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / breakpoint-manager.html
index e9162eb..43e85a6 100644 (file)
@@ -6,19 +6,21 @@
 
 function test()
 {
+    var workspace;
     var uiSourceCodes = {};
+    var mockTarget = {};
 
     var defaultMapping = {
         rawLocationToUILocation: function(rawLocation)
         {
-            return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptId], rawLocation.lineNumber, 0);
+            return uiSourceCodes[rawLocation.scriptId].uiLocation(rawLocation.lineNumber, 0);
         },
 
         uiLocationToRawLocation: function(uiSourceCode, lineNumber)
         {
             if (!uiSourceCodes[uiSourceCode.url])
                 return null;
-            return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lineNumber, 0);
+            return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceCode.url, lineNumber, 0);
         },
 
         isIdentity: function()
@@ -32,12 +34,12 @@ function test()
         {
             if (this._disabled)
                 return null;
-            return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptId], rawLocation.lineNumber + 10, 0);
+            return uiSourceCodes[rawLocation.scriptId].uiLocation(rawLocation.lineNumber + 10, 0);
         },
 
         uiLocationToRawLocation: function(uiSourceCode, lineNumber)
         {
-            return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lineNumber - 10, 0);
+            return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceCode.url, lineNumber - 10, 0);
         },
 
         isIdentity: function()
@@ -53,12 +55,12 @@ function test()
             {
                 if (this._disabled)
                     return null;
-                return new WebInspector.UILocation(uiSourceCodeB, rawLocation.lineNumber + 10, 0);
+                return uiSourceCodeB.uiLocation(rawLocation.lineNumber + 10, 0);
             },
 
             uiLocationToRawLocation: function(uiSourceCode, lineNumber)
             {
-                return new WebInspector.DebuggerModel.Location(uiSourceCodeA.url, lineNumber - 10, 0);
+                return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceCodeA.url, lineNumber - 10, 0);
             },
 
             isIdentity: function()
@@ -72,15 +74,21 @@ function test()
 
     function DebuggerModelMock(sourceMapping)
     {
+        mockTarget.debuggerModel = this;
         this._scripts = {};
         this._sourceMapping = sourceMapping;
         this._breakpoints = {};
     }
 
     DebuggerModelMock.prototype = {
+        target: function()
+        {
+            return mockTarget;
+        },
+
         _addScript: function(scriptId, url)
         {
-            this._scripts[scriptId] = new WebInspector.Script(scriptId, url);
+            this._scripts[scriptId] = new WebInspector.Script(mockTarget, scriptId, url);
             this._scripts[scriptId].pushSourceMapping(this._sourceMapping);
         },
 
@@ -123,7 +131,7 @@ function test()
             var locations = [];
             var script = this._scriptForURL(url);
             if (script) {
-                var location = new WebInspector.DebuggerModel.Location(script.scriptId, lineNumber, 0);
+                var location = new WebInspector.DebuggerModel.Location(mockTarget, script.scriptId, lineNumber, 0);
                 locations.push(location);
             }
 
@@ -146,12 +154,12 @@ function test()
                 return;
             }
             if (location.lineNumber >= 1000) {
-                var shiftedLocation = {scriptId: location.scriptId, lineNumber: location.lineNumber + 10, columnNumber: location.columnNumber };
+                var shiftedLocation = new WebInspector.DebuggerModel.Location(mockTarget, location.scriptId, location.lineNumber + 10, location.columnNumber);
                 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedLocation]);
                 return;
             }
 
-            this._scheduleSetBeakpointCallback(callback, breakpointId, [location]);
+            this._scheduleSetBeakpointCallback(callback, breakpointId, [WebInspector.DebuggerModel.Location.fromPayload(mockTarget, location)]);
         },
 
         removeBreakpoint: function(breakpointId, callback)
@@ -166,7 +174,7 @@ function test()
 
         createLiveLocation: function(rawLocation, updateDelegate)
         {
-             return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocation, updateDelegate);
+            return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocation, updateDelegate);
         },
 
         scriptForId: function(scriptId)
@@ -203,8 +211,8 @@ function test()
     function resetWorkspace(breakpointManager)
     {
         InspectorTest.addResult("  Resetting workspace.");
-        breakpointManager._networkWorkspaceProvider.reset();
-        breakpointManager._debuggerWorkspaceProvider.reset();
+        breakpointManager._networkWorkspaceBinding.reset();
+        breakpointManager._debuggerProjectDelegate.reset();
     }
 
     function breakpointAdded(event)
@@ -235,7 +243,7 @@ function test()
             breakpointManager._debuggerModel._addScript(url, url);
         InspectorTest.addResult("  Adding UISourceCode: " + url);
         var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "");
-        var uiSourceCode = breakpointManager._networkWorkspaceProvider.addFileForURL(url, contentProvider, true);
+        var uiSourceCode = breakpointManager._networkWorkspaceBinding.addFileForURL(url, contentProvider);
         uiSourceCodes[url] = uiSourceCode;
         if (!doNotSetSourceMapping)
             uiSourceCode.setSourceMapping(defaultMapping);
@@ -244,11 +252,11 @@ function test()
 
     function addTemporaryUISourceCode(breakpointManager, url)
     {
-
         breakpointManager._debuggerModel._addScript(url, url);
         InspectorTest.addResult("  Adding temporary UISourceCode: " + url);
         var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "");
-        var uiSourceCode = breakpointManager._debuggerWorkspaceProvider.addUniqueFileForURL(url, contentProvider, true);
+        var path = breakpointManager._debuggerProjectDelegate.addContentProvider("", url, url, contentProvider);
+        var uiSourceCode = workspace.uiSourceCode("debugger:", path);
         uiSourceCode.setSourceMapping(defaultMapping);
         uiSourceCodes[url] = uiSourceCode;
         return uiSourceCode;
@@ -274,10 +282,10 @@ function test()
 
         var sourceMapping = sourceMapping || defaultMapping;
         var debuggerModel = new DebuggerModelMock(sourceMapping);
-        var workspace = new WebInspector.Workspace();
+        workspace = new WebInspector.Workspace();
         var breakpointManager = new WebInspector.BreakpointManager(setting, debuggerModel, workspace);
-        breakpointManager._networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace, WebInspector.projectTypes.Network);
-        breakpointManager._debuggerWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace, WebInspector.projectTypes.Debugger);
+        breakpointManager._networkWorkspaceBinding = new WebInspector.NetworkWorkspaceBinding(workspace);
+        breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerProjectDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger);
         breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, breakpointAdded);
         breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, breakpointRemoved);
         InspectorTest.addResult("  Created breakpoints manager");
@@ -577,7 +585,7 @@ function test()
                 resetWorkspace(breakpointManager);
                 InspectorTest.addResult("  Resolving provisional breakpoint.");
                 addTemporaryUISourceCode(breakpointManager, "a.js");
-                var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
+                var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)};
                 breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
                 addUISourceCode(breakpointManager, "a.js");
                 window.setBreakpointCallback = step4.bind(this);
@@ -647,7 +655,7 @@ function test()
                 resetWorkspace(breakpointManager);
                 InspectorTest.addResult("  Resolving provisional breakpoint.");
                 addTemporaryUISourceCode(breakpointManager, "a.js")            
-                var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
+                var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)};
                 breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
                 var breakpoints = breakpointManager.allBreakpoints();
                 InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one provisional breakpoint should be registered in breakpoint manager.");
@@ -691,7 +699,7 @@ function test()
 
                 InspectorTest.addResult("\n  Adding files:");
                 addTemporaryUISourceCode(breakpointManager, "a.js");
-                var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 10, columnNumber: 5 }};
+                var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)};
                 breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
                 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js");
                 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true, true);
@@ -742,7 +750,7 @@ function test()
                 var uiSourceCode = addUISourceCode(breakpointManager, "a.js");
 
                 InspectorTest.addResult("\n  Emulating breakpoint resolved event:");
-                var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 10, columnNumber: 5 }};
+                var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)};
                 breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
 
                 InspectorTest.addResult("\n  Waiting for breakpoint to be set in debugger again:");