1 function initialize_LayerTreeTests()
3 // FIXME: remove once out of experimental.
4 WebInspector.moduleManager.registerModule("layers");
5 var extensions = WebInspector.moduleManager.extensions(WebInspector.Panel).forEach(function(extension) {
6 if (extension.module().name() === "layers")
7 WebInspector.inspectorView.addPanel(new WebInspector.ModuleManagerExtensionPanelDescriptor(extension));
9 InspectorTest._layerTreeModel = WebInspector.panel("layers")._model;
11 InspectorTest.labelForLayer = function(layer)
13 var node = WebInspector.domAgent.nodeForId(layer.nodeIdForSelfOrAncestor());
14 var label = WebInspector.DOMPresentationUtils.fullQualifiedSelector(node, false);
15 var height = layer.height();
16 var width = layer.width();
17 if (height <= 200 && width <= 200)
18 label += " " + height + "x" + width;
19 if (typeof layer.__extraData !== "undefined")
20 label += " (" + layer.__extraData + ")";
24 InspectorTest.dumpLayerTree = function(prefix, root)
29 root = InspectorTest._layerTreeModel.contentRoot();
31 InspectorTest.addResult("No layer root, perhaps not in the composited mode! ");
32 InspectorTest.completeTest();
36 InspectorTest.addResult(prefix + InspectorTest.labelForLayer(root));
37 root.children().forEach(InspectorTest.dumpLayerTree.bind(InspectorTest, prefix + " "));
40 InspectorTest.dumpLayerTreeOutline = function(prefix, root)
45 root = WebInspector.panel("layers")._layerTree._treeOutline;
46 if (root.representedObject)
47 InspectorTest.addResult(prefix + InspectorTest.labelForLayer(root.representedObject));
48 root.children.forEach(InspectorTest.dumpLayerTreeOutline.bind(InspectorTest, prefix + " "));
51 InspectorTest.dumpLayers3DView = function(prefix, root)
56 root = WebInspector.panel("layers")._layers3DView._rotatingContainerElement;
58 InspectorTest.addResult(prefix + InspectorTest.labelForLayer(root.__layer));
59 for (var element = root.firstElementChild; element; element = element.nextSibling)
60 InspectorTest.dumpLayers3DView(prefix + " ", element);
63 InspectorTest.evaluateAndRunWhenTreeChanges = function(expression, callback)
65 function eventHandler()
67 InspectorTest._layerTreeModel.removeEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, eventHandler);
70 InspectorTest.evaluateInPage(expression, function() {
71 InspectorTest._layerTreeModel.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, eventHandler);
75 InspectorTest.findLayerByNodeIdAttribute = function(nodeIdAttribute)
78 function testLayer(layer)
82 var node = WebInspector.domAgent.nodeForId(layer.nodeId());
83 if (!node || node.getAttribute("id") !== nodeIdAttribute)
88 InspectorTest._layerTreeModel.forEachLayer(testLayer);
90 InspectorTest.addResult("ERROR: No layer for " + nodeIdAttribute);
94 InspectorTest.requestLayers = function(callback)
96 InspectorTest._layerTreeModel.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, onLayerTreeChanged);
97 InspectorTest._layerTreeModel.enable();
98 function onLayerTreeChanged()
100 InspectorTest._layerTreeModel.removeEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, onLayerTreeChanged);