Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 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.
| |
| 2 | |
| 3 InspectorTest.preloadModule("persistence"); | |
| 4 InspectorTest.preloadModule("sources"); | |
| 5 | |
| 6 WebInspector.PersistenceBinding.prototype.toString = function() | |
| 7 { | |
| 8 var lines = [ | |
| 9 "{", | |
| 10 " network: " + this.network.url(), | |
| 11 " fileSystem: " + this.fileSystem.url(), | |
| 12 "}" | |
| 13 ]; | |
| 14 return lines.join("\n"); | |
| 15 } | |
| 16 | |
| 17 InspectorTest.waitForBinding = function(fileName) | |
| 18 { | |
| 19 var bindings = WebInspector.persistence._bindings.valuesArray(); | |
| 20 for (var binding of bindings) { | |
| 21 if (binding.network.name() === fileName || binding.fileSystem.name() === fileName) | |
| 22 return Promise.resolve(binding); | |
| 23 } | |
| 24 var fulfill; | |
| 25 var promise = new Promise(x => fulfill = x); | |
| 26 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, onBindingCreated); | |
| 27 return promise; | |
| 28 | |
| 29 function onBindingCreated(event) | |
| 30 { | |
| 31 var binding = event.data; | |
| 32 if (binding.network.name() !== fileName && binding.fileSystem.name() !== fileName) | |
| 33 return; | |
| 34 WebInspector.persistence.removeEventListener(WebInspector.Persistence.Ev ents.BindingCreated, onBindingCreated); | |
| 35 fulfill(binding); | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 InspectorTest.waitForUISourceCode = function(name, projectType) | |
| 40 { | |
| 41 var uiSourceCodes = WebInspector.workspace.uiSourceCodes(); | |
| 42 var uiSourceCode = uiSourceCodes.find(filterCode); | |
| 43 if (uiSourceCode) | |
| 44 return Promise.resolve(uiSourceCode); | |
| 45 | |
| 46 var fulfill; | |
| 47 var promise = new Promise(x => fulfill = x); | |
| 48 WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, onUISourceCode); | |
| 49 return promise; | |
| 50 | |
| 51 function onUISourceCode(event) | |
| 52 { | |
| 53 var uiSourceCode = event.data; | |
| 54 if (!filterCode(uiSourceCode)) | |
| 55 return; | |
| 56 WebInspector.workspace.removeEventListener(WebInspector.Workspace.Events .UISourceCodeAdded, onUISourceCode); | |
| 57 fulfill(uiSourceCode); | |
| 58 } | |
| 59 | |
| 60 function filterCode(uiSourceCode) | |
| 61 { | |
| 62 return uiSourceCode.name() === name && uiSourceCode.project().type() === projectType; | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 InspectorTest.addFooJSFile = function(fs) | |
| 67 { | |
| 68 return fs.root.mkdir("inspector").mkdir("persistence").mkdir("resources").ad dFile("foo.js", "window.foo = ()=>'foo';"); | |
| 69 } | |
| 70 | |
| 71 } | |
| OLD | NEW |