Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / layers-test.js
index 76ec232..43f4ce4 100644 (file)
@@ -1,17 +1,18 @@
 function initialize_LayerTreeTests()
 {
     // FIXME: remove once out of experimental.
-    WebInspector.moduleManager.registerModule("layers");
-    var extensions = WebInspector.moduleManager.extensions(WebInspector.Panel).forEach(function(extension) {
+    InspectorTest.registerModule("layers");
+    var extensions = runtime.extensions(WebInspector.Panel).forEach(function(extension) {
         if (extension.module().name() === "layers")
-            WebInspector.inspectorView.addPanel(new WebInspector.ModuleManagerExtensionPanelDescriptor(extension));
+            WebInspector.inspectorView.addPanel(new WebInspector.RuntimeExtensionPanelDescriptor(extension));
     });
-    InspectorTest._layerTreeModel = WebInspector.panel("layers")._model;
+    InspectorTest.layerTreeModel = WebInspector.inspectorView.panel("layers")._model;
+    InspectorTest.layers3DView = WebInspector.inspectorView.panel("layers")._layers3DView;
 
     InspectorTest.labelForLayer = function(layer)
     {
-        var node = WebInspector.domAgent.nodeForId(layer.nodeIdForSelfOrAncestor());
-        var label = WebInspector.DOMPresentationUtils.appropriateSelectorFor(node, false);
+        var node = layer.nodeForSelfOrAncestor();
+        var label = node ? WebInspector.DOMPresentationUtils.fullQualifiedSelector(node, false) : "<invalid node id>";
         var height = layer.height();
         var width = layer.width();
         if (height <= 200 && width <= 200)
@@ -26,7 +27,7 @@ function initialize_LayerTreeTests()
         if (!prefix)
             prefix = "";
         if (!root) {
-            root = InspectorTest._layerTreeModel.contentRoot();
+            root = InspectorTest.layerTreeModel.layerTree().contentRoot();
             if (!root) {
                 InspectorTest.addResult("No layer root, perhaps not in the composited mode! ");
                 InspectorTest.completeTest();
@@ -42,7 +43,7 @@ function initialize_LayerTreeTests()
         if (!prefix)
             prefix = "";
         if (!root)
-            root = WebInspector.panel("layers")._layerTree._treeOutline;
+            root = WebInspector.inspectorView.panel("layers")._layerTree._treeOutline;
         if (root.representedObject)
             InspectorTest.addResult(prefix + InspectorTest.labelForLayer(root.representedObject));
         root.children.forEach(InspectorTest.dumpLayerTreeOutline.bind(InspectorTest, prefix + "    "));
@@ -53,7 +54,7 @@ function initialize_LayerTreeTests()
         if (!prefix)
             prefix = "";
         if (!root)
-            root = WebInspector.panel("layers")._layers3DView._rotatingContainerElement;
+            root = InspectorTest.layers3DView._rotatingContainerElement;
         if (root.__layer)
             InspectorTest.addResult(prefix + InspectorTest.labelForLayer(root.__layer));
         for (var element = root.firstElementChild; element; element = element.nextSibling)
@@ -64,11 +65,12 @@ function initialize_LayerTreeTests()
     {
         function eventHandler()
         {
-            InspectorTest._layerTreeModel.removeEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, eventHandler);
+            InspectorTest.layerTreeModel.removeEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, eventHandler);
             callback();
         }
-        InspectorTest._layerTreeModel.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, eventHandler);
-        InspectorTest.evaluateInPage(expression, function() {});
+        InspectorTest.evaluateInPage(expression, function() {
+            InspectorTest.layerTreeModel.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, eventHandler);
+        });
     }
 
     InspectorTest.findLayerByNodeIdAttribute = function(nodeIdAttribute)
@@ -76,15 +78,15 @@ function initialize_LayerTreeTests()
         var result;
         function testLayer(layer)
         {
-            if (!layer.nodeId())
+            var node = layer.node();
+            if (!node)
                 return false;
-            var node = WebInspector.domAgent.nodeForId(layer.nodeId());
             if (!node || node.getAttribute("id") !== nodeIdAttribute)
                 return false;
             result = layer;
             return true;
         }
-        InspectorTest._layerTreeModel.forEachLayer(testLayer);
+        InspectorTest.layerTreeModel.layerTree().forEachLayer(testLayer);
         if (!result)
             InspectorTest.addResult("ERROR: No layer for " + nodeIdAttribute);
         return result;
@@ -92,13 +94,47 @@ function initialize_LayerTreeTests()
 
     InspectorTest.requestLayers = function(callback)
     {
-        InspectorTest._layerTreeModel.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, onLayerTreeChanged);
-        InspectorTest._layerTreeModel.enable();
+        InspectorTest.layerTreeModel.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, onLayerTreeChanged);
+        InspectorTest.layerTreeModel.enable();
         function onLayerTreeChanged()
         {
-            InspectorTest._layerTreeModel.removeEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, onLayerTreeChanged);
+            InspectorTest.layerTreeModel.removeEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged, onLayerTreeChanged);
             callback();
         }
     }
 
+    InspectorTest.dumpModelScrollRects = function()
+    {
+        function dumpScrollRectsForLayer(layer)
+        {
+            if (layer._scrollRects.length > 0)
+                InspectorTest.addObject(layer._scrollRects);
+        }
+
+        InspectorTest.addResult("Model elements dump");
+        InspectorTest.layerTreeModel.layerTree().forEachLayer(dumpScrollRectsForLayer.bind(this));
+    }
+
+    InspectorTest.dispatchMouseEvent = function(eventType, button, element, offsetX, offsetY)
+    {
+        var totalOffset = element.totalOffset();
+        var scrollOffset = element.scrollOffset();
+        var eventArguments = {
+            bubbles: true,
+            cancelable: true,
+            view: window,
+            screenX: totalOffset.left - scrollOffset.left + offsetX,
+            screenY: totalOffset.top - scrollOffset.top + offsetY,
+            clientX: totalOffset.left + offsetX,
+            clientY: totalOffset.top + offsetY,
+            button: button
+        };
+        if (eventType === "mouseout") {
+            eventArguments.screenX = 0;
+            eventArguments.screenY = 0;
+            eventArguments.clientX = 0;
+            eventArguments.clientY = 0;
+        }
+        element.dispatchEvent(new MouseEvent(eventType, eventArguments));
+    }
 }