2011-01-26 Martin Robinson <mrobinson@igalia.com>
[WebKit-https.git] / LayoutTests / inspector / elements-img-tooltip.html
1 <html>
2 <head>
3
4 <script src="../http/tests/inspector/inspector-test.js"></script>
5 <script src="elements-tests.js"></script>
6 <script>
7 var EXPECTED_TOOLTIP_TEXT = "215 \xd7 174 pixels";
8 function doit()
9 {
10     function callback(tooltipText)
11     {
12         if (!tooltipText)
13             output("FAILED, tooltip text should have been \"" + EXPECTED_TOOLTIP_TEXT + "\". Was " + tooltipText + ".");
14         else if (tooltipText == EXPECTED_TOOLTIP_TEXT)
15             output("PASSED, tooltip text is \"" + EXPECTED_TOOLTIP_TEXT + "\".");
16         else
17             output("FAILED, tooltip text should have been \"" + EXPECTED_TOOLTIP_TEXT + "\". Was \"" + tooltipText + "\".");
18         notifyDone();
19     }
20     evaluateInWebInspector("frontend_dumpTooltip", callback);
21 }
22
23 // Frontend functions.
24
25 function frontend_dumpTooltip(testController)
26 {
27     testController.waitUntilDone();
28     frontend_expandDOMSubtreeAndRun(testController, null, frontend_dumpTooltipContinuation);
29 }
30
31 function frontend_dumpTooltipContinuation(testController)
32 {
33     function callback(tooltipText)
34     {
35         testController.notifyDone(tooltipText);
36     }
37
38     var innerMapping = WebInspector.domAgent._idToDOMNode;
39     for (var nodeId in innerMapping) {
40         if (innerMapping[nodeId].nodeName === "IMG") {
41             var node = innerMapping[nodeId];
42             var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
43             treeElement._createTooltipForNode();
44             testController.runAfterPendingDispatches(function() {
45                 testController.notifyDone(treeElement.tooltip);
46             });
47             break;
48         }
49     }
50 }
51 </script>
52 </head>
53
54 <body onload="onload()">
55 <p>
56 Tests that the tooltip text for the image (below) is &quot;<script>document.write(EXPECTED_TOOLTIP_TEXT)</script>&quot;.
57 </p>
58
59 <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAACuCAIAAAAqMg/rAAAAAXNSR0IArs4c6QAAAU9JREFUeNrt0jERAAAIxDDAv+dHAxNLIqHXTlLwaiTAheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSF4EJcCC7EheBCXAguxIXgQlwILsSFEuBCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLgQX4kJwIS4EF+JCcCEuBBfiQnAhLoSDBZXqBFnkRyeqAAAAAElFTkSuQmCC"/>
60
61 </body>
62 </html>