Index: third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-test.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ddceabd0491995f1661e131d5fe5ee2b2cce30bd |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-test.js |
@@ -0,0 +1,71 @@ |
+var initialize_PersistenceTest = function() { |
dgozman
2016/09/23 23:03:21
Let's add a test for "didn't bind because of isDir
lushnikov
2016/09/24 00:30:50
Done.
|
+ |
+InspectorTest.preloadModule("persistence"); |
+InspectorTest.preloadModule("sources"); |
+ |
+WebInspector.PersistenceBinding.prototype.toString = function() |
+{ |
+ var lines = [ |
+ "{", |
+ " network: " + this.network.url(), |
+ " fileSystem: " + this.fileSystem.url(), |
+ "}" |
+ ]; |
+ return lines.join("\n"); |
+} |
+ |
+InspectorTest.waitForBinding = function(fileName) |
+{ |
+ var bindings = WebInspector.persistence._bindings.valuesArray(); |
+ for (var binding of bindings) { |
+ if (binding.network.name() === fileName || binding.fileSystem.name() === fileName) |
+ return Promise.resolve(binding); |
+ } |
+ var fulfill; |
+ var promise = new Promise(x => fulfill = x); |
+ WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.BindingCreated, onBindingCreated); |
+ return promise; |
+ |
+ function onBindingCreated(event) |
+ { |
+ var binding = event.data; |
+ if (binding.network.name() !== fileName && binding.fileSystem.name() !== fileName) |
+ return; |
+ WebInspector.persistence.removeEventListener(WebInspector.Persistence.Events.BindingCreated, onBindingCreated); |
+ fulfill(binding); |
+ } |
+} |
+ |
+InspectorTest.waitForUISourceCode = function(name, projectType) |
+{ |
+ var uiSourceCodes = WebInspector.workspace.uiSourceCodes(); |
+ var uiSourceCode = uiSourceCodes.find(filterCode); |
+ if (uiSourceCode) |
+ return Promise.resolve(uiSourceCode); |
+ |
+ var fulfill; |
+ var promise = new Promise(x => fulfill = x); |
+ WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, onUISourceCode); |
+ return promise; |
+ |
+ function onUISourceCode(event) |
+ { |
+ var uiSourceCode = event.data; |
+ if (!filterCode(uiSourceCode)) |
+ return; |
+ WebInspector.workspace.removeEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, onUISourceCode); |
+ fulfill(uiSourceCode); |
+ } |
+ |
+ function filterCode(uiSourceCode) |
+ { |
+ return uiSourceCode.name() === name && uiSourceCode.project().type() === projectType; |
+ } |
+} |
+ |
+InspectorTest.addFooJSFile = function(fs) |
+{ |
+ return fs.root.mkdir("inspector").mkdir("persistence").mkdir("resources").addFile("foo.js", "window.foo = ()=>'foo';"); |
+} |
+ |
+} |