Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / elements-test.js
index 4aee99b..c5a80b3 100644 (file)
@@ -1,5 +1,15 @@
+function getInspectorHighlightJSON(nodeId, opt_frameId)
+{
+    var doc = document;
+    if (opt_frameId)
+        doc = document.getElementById(opt_frameId).contentDocument;
+    return window.internals.inspectorHighlightJSON(doc.getElementById(nodeId));
+}
+
 var initialize_ElementTest = function() {
 
+InspectorTest.preloadPanel("elements");
+
 InspectorTest.findNode = function(matchFunction, callback)
 {
     callback = InspectorTest.safeWrap(callback);
@@ -84,7 +94,7 @@ InspectorTest.expandedNodeWithId = function(idValue)
 
 InspectorTest.selectNode = function(node)
 {
-    WebInspector.Revealer.reveal(node);
+    return WebInspector.Revealer.revealPromise(node);
 }
 
 InspectorTest.selectNodeWithId = function(idValue, callback)
@@ -92,8 +102,7 @@ InspectorTest.selectNodeWithId = function(idValue, callback)
     callback = InspectorTest.safeWrap(callback);
     function onNodeFound(node)
     {
-        InspectorTest.selectNode(node);
-        callback(node);
+        InspectorTest.selectNode(node).then(callback.bind(null, node));
     }
     InspectorTest.nodeWithId(idValue, onNodeFound);
 }
@@ -135,9 +144,18 @@ InspectorTest.waitForStylesForClass = function(classValue, callback, requireRebu
     waitForStylesRebuild(nodeWithClass, callback, requireRebuild);
 }
 
+InspectorTest.waitForSelectorCommitted = function(callback)
+{
+    InspectorTest.addSniffer(WebInspector.StylePropertiesSection.prototype, "_editingSelectorCommittedForTest", callback);
+}
+
+InspectorTest.waitForStyleApplied = function(callback)
+{
+    InspectorTest.addSniffer(WebInspector.StylePropertyTreeElement.prototype, "styleTextAppliedForTest", callback);
+}
+
 InspectorTest.selectNodeAndWaitForStyles = function(idValue, callback)
 {
-    WebInspector.inspectorView.showPanel("elements");
 
     callback = InspectorTest.safeWrap(callback);
 
@@ -217,7 +235,7 @@ InspectorTest.dumpSelectedElementStyles = function(excludeComputed, excludeMatch
                 continue;
             if (section.element.previousSibling && section.element.previousSibling.className === "sidebar-separator")
                 InspectorTest.addResult("======== " + section.element.previousSibling.textContent + " ========");
-            InspectorTest.addResult((section.expanded ? "[expanded] " : "[collapsed] ") + (section.noAffect ? "[no-affect] " : ""));
+            InspectorTest.addResult((section.expanded ? "[expanded] " : "[collapsed] ") + (section.element.classList.contains("no-affect") ? "[no-affect] " : ""));
             var chainEntries = section.titleElement.querySelectorAll(".media-list .media");
             chainEntries = Array.prototype.slice.call(chainEntries);
             if (section.titleElement.children[1])
@@ -253,69 +271,50 @@ InspectorTest.toggleMatchedStyleProperty = function(propertyName, checked)
 
 InspectorTest.expandAndDumpSelectedElementEventListeners = function(callback)
 {
-    InspectorTest.expandSelectedElementEventListeners(function() {
-        InspectorTest.dumpSelectedElementEventListeners(callback);
-    });
-}
+    InspectorTest.addSniffer(WebInspector.EventListenersSidebarPane.prototype, "_onEventListeners", listenersArrived);
 
-InspectorTest.expandSelectedElementEventListeners = function(callback)
-{
     var sidebarPane = WebInspector.panels.elements.sidebarPanes.eventListeners;
     sidebarPane.expand();
-
-    InspectorTest.runAfterPendingDispatches(function() {
-        InspectorTest.expandSelectedElementEventListenersSubsections(callback);
-    });
-}
-
-InspectorTest.expandSelectedElementEventListenersSubsections = function(callback)
-{
     var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventListeners.sections;
     for (var i = 0; i < eventListenerSections.length; ++i)
         eventListenerSections[i].expand();
 
-    // Multiple sections may expand.
-    InspectorTest.runAfterPendingDispatches(function() {
-        InspectorTest.expandSelectedElementEventListenersEventBars(callback);
-    });
-}
-
-InspectorTest.expandSelectedElementEventListenersEventBars = function(callback)
-{
-    var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventListeners.sections;
-    for (var i = 0; i < eventListenerSections.length; ++i) {
-        var eventBarChildren = eventListenerSections[i]._eventBars.children;
-        for (var j = 0; j < eventBarChildren.length; ++j)
-            eventBarChildren[j]._section.expand();
+    function listenersArrived()
+    {
+        var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventListeners.sections;
+        for (var i = 0; i < eventListenerSections.length; ++i) {
+            var eventType = eventListenerSections[i]._title;
+            var eventBarChildren = eventListenerSections[i]._eventBars.children;
+            for (var j = 0; j < eventBarChildren.length; ++j) {
+                var objectPropertiesSection = eventBarChildren[j]._section;
+                objectPropertiesSection.expand();
+            }
+        }
+        InspectorTest.runAfterPendingDispatches(objectsExpanded);
     }
 
-    // Multiple sections may expand.
-    InspectorTest.runAfterPendingDispatches(callback);
-}
+    function objectsExpanded()
+    {
+        var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventListeners.sections;
+        for (var i = 0; i < eventListenerSections.length; ++i) {
+            var eventType = eventListenerSections[i]._title;
+            InspectorTest.addResult("");
+            InspectorTest.addResult("======== " + eventType + " ========");
+            var eventBarChildren = eventListenerSections[i]._eventBars.children;
+            for (var j = 0; j < eventBarChildren.length; ++j) {
+                var objectPropertiesSection = eventBarChildren[j]._section;
+                InspectorTest.dumpObjectPropertySection(objectPropertiesSection, {
+                    sourceName: formatSourceNameProperty
+                });
+            }
+        }
+        callback();
+    }
 
-InspectorTest.dumpSelectedElementEventListeners = function(callback)
-{
     function formatSourceNameProperty(value)
     {
         return "[clipped-for-test]/" + value.replace(/(.*?\/)LayoutTests/, "LayoutTests");
     }
-
-    var eventListenerSections = WebInspector.panels.elements.sidebarPanes.eventListeners.sections;
-    for (var i = 0; i < eventListenerSections.length; ++i) {
-        var section = eventListenerSections[i];
-        var eventType = section._title;
-        InspectorTest.addResult("");
-        InspectorTest.addResult("======== " + eventType + " ========");
-        var eventBarChildren = section._eventBars.children;
-        for (var j = 0; j < eventBarChildren.length; ++j) {
-            var objectPropertiesSection = eventBarChildren[j]._section;
-            InspectorTest.dumpObjectPropertySection(objectPropertiesSection, {
-                sourceName: formatSourceNameProperty
-            });
-        }
-    }
-
-    callback();
 }
 
 InspectorTest.dumpObjectPropertySection = function(section, formatters)
@@ -369,11 +368,17 @@ InspectorTest.getElementStylePropertyTreeItem = function(propertyName)
 // FIXME: this returns the first tree item found (may fail for same-named properties in a style).
 InspectorTest.getMatchedStylePropertyTreeItem = function(propertyName)
 {
-    var styleSections = WebInspector.panels.elements.sidebarPanes.styles.sections[0];
-    for (var i = 1; i < styleSections.length; ++i) {
-        var treeItem = InspectorTest.getFirstPropertyTreeItemForSection(styleSections[i], propertyName);
-        if (treeItem)
-            return treeItem;
+    var sections = WebInspector.panels.elements.sidebarPanes.styles.sections;
+    for (var pseudoId in sections) {
+        var styleSections = sections[pseudoId];
+        for (var i = 0; i < styleSections.length; ++i) {
+            var section = styleSections[i];
+            if (section.computedStyle)
+                continue;
+            var treeItem = InspectorTest.getFirstPropertyTreeItemForSection(section, propertyName);
+            if (treeItem)
+                return treeItem;
+        }
     }
     return null;
 };
@@ -524,9 +529,9 @@ InspectorTest.expandElementsTree = function(callback)
     {
         InspectorTest.firstElementsTreeOutline()._updateModifiedNodes();
         expand(InspectorTest.firstElementsTreeOutline());
-        callback(expandedSomething);
+        // Make all promises succeed.
+        setTimeout(callback.bind(null, expandedSomething));
     }
-    WebInspector.inspectorView.showPanel("elements");
     InspectorTest.findNode(function() { return false; }, onAllNodesAvailable);
 };
 
@@ -739,7 +744,7 @@ InspectorTest.dumpBreadcrumb = function(message)
     if (message)
         InspectorTest.addResult(message + ":");
     var result = [];
-    var crumbs = WebInspector.inspectorView.panel("elements").crumbsElement;
+    var crumbs = WebInspector.panels.elements._breadcrumbs.crumbsElement;
     var crumb = crumbs.lastChild;
     while (crumb) {
         result.unshift(crumb.textContent);
@@ -775,27 +780,18 @@ function onBlankSection(selector, callback)
     if (typeof selector === "string")
         section._selectorElement.textContent = selector;
     section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
-    InspectorTest.runAfterPendingDispatches(callback.bind(null, section));
-}
-
-InspectorTest.dumpInspectorHighlight = function(node, callback)
-{
-    node.boxModel(function(boxModel) {
-        var rectNames = ["margin", "border", "padding", "content"];
-        for (var i = 0; i < rectNames.length; i++) {
-            var rect = boxModel[rectNames[i]];
-            InspectorTest.addResult(rectNames[i] + " rect is " + (rect[4] - rect[0]) + " x " + (rect[5] - rect[1]) + " at (" + rect[0] + ", " + rect[1] + ")");
-        }
-        callback();
-   });
+    InspectorTest.waitForSelectorCommitted(callback.bind(null, section));
 }
 
-InspectorTest.dumpInspectorHighlightShape = function(node, callback)
+InspectorTest.dumpInspectorHighlightJSON = function(nodeId, callback, opt_frameId)
 {
-    node.boxModel(function(shapes) {
-        InspectorTest.addResult(JSON.stringify(shapes.shapeOutside.shape));
+    function innerCallback(result)
+    {
+        InspectorTest.addResult(nodeId + ": " + result.description);
         callback();
-    });
+    }
+    opt_frameId = opt_frameId || "";
+    InspectorTest.evaluateInPage("getInspectorHighlightJSON(\"" + nodeId + "\", \"" + opt_frameId + "\")", innerCallback);
 }
 
 };