DevTools: [Workspace] fix removing stylesheet-related uiSourceCodes

The patch fixes a bug in removing uiSourceCodes from workspace as
the associated stylesheet gets removed.

BUG=424544
R=vsevik

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

git-svn-id: svn://svn.chromium.org/blink/trunk@183915 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 09de5eae
...@@ -28,7 +28,11 @@ UISourceCode: http://fake.url/4 ...@@ -28,7 +28,11 @@ UISourceCode: http://fake.url/4
Highlighter type: text/css Highlighter type: text/css
UISourceCode content: <stylesheet resource content> UISourceCode content: <stylesheet resource content>
Running: testRemoveStyleSheetFromModel Running: testRemoveStyleSheetFromModelWithComplexURL
Added uiSourceCode: http://example.com/foo.css
Removed uiSourceCode: http://example.com/foo.css
Running: testRemoveStyleSheetFromModelWithSimpleURL
Added uiSourceCode: foo.css Added uiSourceCode: foo.css
Removed uiSourceCode: foo.css Removed uiSourceCode: foo.css
...@@ -8,15 +8,20 @@ function test() ...@@ -8,15 +8,20 @@ function test()
{ {
var mockContentsMap = {}; var mockContentsMap = {};
var lastResourceId = 0; var lastResourceId = 0;
var lastStyleSheetId = 0;
var mockStyleSheetHeader = {
styleSheetId: "1", function createMockStyleSheetHeader(url)
sourceURL: "foo.css", {
sourceMapURL: "", return {
origin: "regular", styleSheetId: (++lastStyleSheetId) + "",
title: "", sourceURL: url,
disabled: false sourceMapURL: "",
}; origin: "regular",
title: "",
disabled: false
};
}
NetworkAgent.getResponseBody = function(requestId, callback) NetworkAgent.getResponseBody = function(requestId, callback)
{ {
...@@ -138,27 +143,39 @@ function test() ...@@ -138,27 +143,39 @@ function test()
} }
}, },
function testRemoveStyleSheetFromModel(next) function testRemoveStyleSheetFromModelWithComplexURL(next)
{ {
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider(); var mockStyleSheetHeader = createMockStyleSheetHeader("http://example.com/foo.css");
var target = WebInspector.targetManager.mainTarget(); testRemoveStyleSheetFromModel(mockStyleSheetHeader, next);
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded); },
target.cssModel._styleSheetAdded(mockStyleSheetHeader);
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.addResult("Added uiSourceCode: " + InspectorTest.uiSourceCodeURL(uiSourceCode));
InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent(uiSourceCodeRemoved);
target.cssModel._styleSheetRemoved(mockStyleSheetHeader.styleSheetId);
}
function uiSourceCodeRemoved(uiSourceCode) function testRemoveStyleSheetFromModelWithSimpleURL(next)
{ {
InspectorTest.addResult("Removed uiSourceCode: " + InspectorTest.uiSourceCodeURL(uiSourceCode)); var mockStyleSheetHeader = createMockStyleSheetHeader("foo.css");
next(); testRemoveStyleSheetFromModel(mockStyleSheetHeader, next);
}
} }
]); ]);
function testRemoveStyleSheetFromModel(mockStyleSheetHeader, callback)
{
var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
var target = WebInspector.targetManager.mainTarget();
InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
target.cssModel._styleSheetAdded(mockStyleSheetHeader);
function uiSourceCodeAdded(uiSourceCode)
{
InspectorTest.addResult("Added uiSourceCode: " + InspectorTest.uiSourceCodeURL(uiSourceCode));
InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent(uiSourceCodeRemoved);
target.cssModel._styleSheetRemoved(mockStyleSheetHeader.styleSheetId);
}
function uiSourceCodeRemoved(uiSourceCode)
{
InspectorTest.addResult("Removed uiSourceCode: " + InspectorTest.uiSourceCodeURL(uiSourceCode));
callback();
}
}
}; };
</script> </script>
</head> </head>
......
...@@ -153,8 +153,9 @@ WebInspector.NetworkWorkspaceBinding.prototype = { ...@@ -153,8 +153,9 @@ WebInspector.NetworkWorkspaceBinding.prototype = {
{ {
var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url); var splitURL = WebInspector.ParsedURL.splitURLIntoPathComponents(url);
var projectName = splitURL[0]; var projectName = splitURL[0];
var path = splitURL.slice(1).join("/");
var projectDelegate = this._projectDelegates[projectName]; var projectDelegate = this._projectDelegates[projectName];
projectDelegate.removeFile(url); projectDelegate.removeFile(path);
}, },
reset: function() reset: function()
......
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