Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js

Issue 1641063002: DevTools: InspectorTest.TestFileSystem to support Entry.remove (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
index bf214603d0d62da8b26e50ce871bce2f100af2a3..1ac85af1550ea3641e1598ce6b38769a732436ef 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/isolated-filesystem-test.js
@@ -7,7 +7,7 @@ InspectorFrontendHost.isolatedFileSystem = function(name)
InspectorTest.TestFileSystem = function(fileSystemPath)
{
- this.root = new InspectorTest.TestFileSystem.Entry("", true, null);
+ this.root = new InspectorTest.TestFileSystem.Entry(this, "", true, null);
this.fileSystemPath = fileSystemPath;
}
@@ -50,8 +50,9 @@ InspectorTest.TestFileSystem.prototype = {
}
}
-InspectorTest.TestFileSystem.Entry = function(name, isDirectory, parent)
+InspectorTest.TestFileSystem.Entry = function(fileSystem, name, isDirectory, parent)
{
+ this._fileSystem = fileSystem;
this.name = name;
this._children = [];
this._childrenMap = {};
@@ -66,9 +67,29 @@ InspectorTest.TestFileSystem.Entry.prototype = {
return this.parent ? this.parent.fullPath + "/" + this.name : "";
},
+ remove: function(success, failure)
+ {
+ this._parent._removeChild(this, success, failure);
+ },
+
+ _removeChild: function(child, success, failure)
+ {
+ var index = this._children.indexOf(child);
+ if (index === -1) {
+ failure("Failed to remove file: file not found.");
+ return;
+ }
+ var fullPath = this._fileSystem.fileSystemPath + child.fullPath;
+ this._children.splice(index, 1);
+ delete this._childrenMap[child.name];
+ child.parent = null;
+ InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.FileSystemFilesChanged, [fullPath]);
+ success();
+ },
+
mkdir: function(name)
{
- var child = new InspectorTest.TestFileSystem.Entry(name, true, this);
+ var child = new InspectorTest.TestFileSystem.Entry(this._fileSystem, name, true, this);
this._childrenMap[name] = child;
this._children.push(child);
child.parent = this;
@@ -77,11 +98,12 @@ InspectorTest.TestFileSystem.Entry.prototype = {
addFile: function(name, content)
{
- var child = new InspectorTest.TestFileSystem.Entry(name, false, this);
+ var child = new InspectorTest.TestFileSystem.Entry(this._fileSystem, name, false, this);
this._childrenMap[name] = child;
this._children.push(child);
child.parent = this;
child.content = new Blob([content], {type: 'text/plain'});
+ return child;
},
createReader: function()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698