Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/view-location.js |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/view-location.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/view-location.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..41de2d28b4139548cdf4605b57ce2737e14f3cd5 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/view-location.js |
| @@ -0,0 +1,63 @@ |
| +class ClosableView extends UI.SimpleView { |
| + isCloseable() { |
| + return true; |
| + } |
| +} |
| + |
| +var views = ['first', 'second', 'third', 'fourth'].map(title => new ClosableView(title)); |
| + |
| +class MockViewManager { |
| + constructor() { |
| + /** @type {!Map<string, !UI.View>} */ |
| + this._views = new Map(); |
| + |
| + for (var view of views) |
| + this._views.set(view.viewId(), view); |
|
dgozman
2017/05/25 17:12:49
Instead of mock, should we inject real extensions
einbinder
2017/05/25 23:48:54
Done.
|
| + } |
| + |
| + /** |
| + * @param {string} location |
| + * @return {!Array<!UI.View>} |
| + */ |
| + _viewsForLocation(location) { |
| + return Array.from(this._views.values()); |
| + } |
| +} |
| + |
| +var tabbedLocation; |
| +createTabbedLocation(); |
| +dumpTabs(); |
| +TestRunner.addResult('Appending three views') |
| +tabbedLocation.appendView(views[0]); |
| +tabbedLocation.appendView(views[1]); |
| +tabbedLocation.appendView(views[2]); |
| +dumpTabs(); |
| +createTabbedLocation(); |
| +dumpTabs(); |
| +TestRunner.addResult('Re-order tabs'); |
| +tabbedLocation.tabbedPane()._insertBefore(tabbedLocation.tabbedPane()._tabsById.get("third"), 0); |
| +dumpTabs(); |
| +createTabbedLocation(); |
| +dumpTabs(); |
| +tabbedLocation.appendView(views[3]); |
| +dumpTabs(); |
| +createTabbedLocation(); |
| +dumpTabs(); |
| +TestRunner.addResult('Closing second tab'); |
| +tabbedLocation.tabbedPane().closeTab('second'); |
| +dumpTabs(); |
| +createTabbedLocation(); |
| +dumpTabs(); |
| +TestRunner.completeTest(); |
| + |
| +function createTabbedLocation() { |
| + TestRunner.addResult('Creating new TabbedLocation'); |
| + if (tabbedLocation) |
| + tabbedLocation.tabbedPane().detach(true); |
| + tabbedLocation = new UI.ViewManager._TabbedLocation(new MockViewManager(), undefined, 'mock-location', true, true); |
| + tabbedLocation.widget().show(UI.inspectorView.element); |
| +} |
| + |
| +function dumpTabs() { |
| + TestRunner.addResult(JSON.stringify(tabbedLocation.tabbedPane().tabIds())); |
| +} |