Chromium Code Reviews| 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 |
| index 7925b155380bad0debece7efeab9e1b39565adf1..e0394d36216fab1a5b80a66a9fc8bf56a53fbd12 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-test.js |
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-test.js |
| @@ -47,4 +47,54 @@ InspectorTest.addFooJSFile = function(fs) |
| return fs.root.mkdir("inspector").mkdir("persistence").mkdir("resources").addFile("foo.js", "\n\nwindow.foo = ()=>'foo';"); |
| } |
| +InspectorTest.initializeTestMapping = function() { |
| + var testMapping; |
| + Persistence.persistence._setMappingForTest((bindingCreated, bindingRemoved) => { |
| + testMapping = new TestMapping(bindingCreated, bindingRemoved); |
| + return testMapping; |
| + }); |
| + return testMapping; |
| +} |
| + |
| +class TestMapping{ |
| + constructor(onBindingAdded, onBindingRemoved) { |
| + this._onBindingAdded = onBindingAdded; |
| + this._onBindingRemoved = onBindingRemoved; |
| + this._bindings = new Set(); |
| + } |
| + |
| + async addBinding(urlSuffix) { |
| + if (this._findBinding(urlSuffix)) |
| + throw new Error(`FAILED TO ADD BINDING: binding already exists for ${urlSuffix}`); |
|
dgozman
2017/03/28 22:51:20
InspectorTest.addResult + completeTest instead to
lushnikov
2017/03/28 23:11:27
Done.
|
| + var networkUISourceCode = await InspectorTest.waitForUISourceCode(urlSuffix, Workspace.projectTypes.Network); |
| + var fileSystemUISourceCode = await InspectorTest.waitForUISourceCode(urlSuffix, Workspace.projectTypes.FileSystem); |
| + |
| + var binding = new Persistence.PersistenceBinding(networkUISourceCode, fileSystemUISourceCode, false); |
| + this._bindings.add(binding); |
| + this._onBindingAdded.call(null, binding); |
| + } |
| + |
| + _findBinding(urlSuffix) { |
| + for (var binding of this._bindings) { |
| + if (binding.network.url().endsWith(urlSuffix)) |
| + return binding; |
| + } |
| + return null; |
| + } |
| + |
| + async removeBinding(urlSuffix) { |
| + var binding = this._findBinding(urlSuffix); |
| + if (!binding) |
| + throw new Error(`FAILED TO REMOVE BINDING: binding does not exist for ${urlSuffix}`); |
|
dgozman
2017/03/28 22:51:20
ditto
lushnikov
2017/03/28 23:11:27
Done.
|
| + this._bindings.delete(binding); |
| + this._onBindingRemoved.call(null, binding); |
| + } |
| + |
| + dispose() { |
| + for (var binding of this._bindings) |
| + this._onBindingRemoved.call(null, binding); |
| + this._bindings.clear(); |
| + } |
| +} |
| + |
| } |