| <html> |
| <head> |
| |
| <style type="text/css" media="screen"> |
| body { background:blue; } |
| </style> |
| |
| <script src="../http/tests/inspector/inspector-test.js"></script> |
| <script src="elements-tests.js"></script> |
| <script> |
| |
| function doit() |
| { |
| runAfterIframeIsLoaded(function() { |
| function callback(result) |
| { |
| for (var i = 0; i < result.length; ++i) { |
| output("Style: " + i); |
| var matchedRules = result[i].matchedCSSRules; |
| for (var j = 0; matchedRules && j < matchedRules.length; ++j) { |
| output(JSON.stringify(matchedRules[j].style.shorthandValues)); |
| } |
| } |
| notifyDone(); |
| } |
| evaluateInWebInspector("frontend_dumpStyles", callback); |
| }); |
| } |
| |
| |
| // Frontend functions. |
| |
| function frontend_dumpStyles(testController) |
| { |
| testController.waitUntilDone(); |
| frontend_expandDOMSubtreeAndRun(testController, null, frontend_dumpStylesContinuation); |
| } |
| |
| function frontend_dumpStylesContinuation(testController) |
| { |
| // 1. Get styles for body, store them in mainStyles var. |
| var body = WebInspector.domAgent.document.body; |
| var mainStyles = null; |
| function mainFrameCallback(styles) |
| { |
| mainStyles = styles; |
| } |
| |
| InspectorBackend.getStyles(body.id, false, mainFrameCallback); |
| |
| // 2. Find iframe node |
| var innerMapping = WebInspector.domAgent._idToDOMNode; |
| var iframeBody = null; |
| |
| for (var nodeId in innerMapping) { |
| if (innerMapping[nodeId].nodeName === "IFRAME") |
| iframeBody = innerMapping[nodeId].firstChild.lastChild; |
| } |
| if (!iframeBody) { |
| testController.notifyDone(["No iframe node found"]); |
| return; |
| } |
| |
| // 3. Get styles for iframe's body, return them together with main styles. |
| function iframeCallback(styles) |
| { |
| testController.notifyDone([mainStyles, styles]); |
| } |
| |
| InspectorBackend.getStyles(iframeBody.id, false, iframeCallback); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="onload()"> |
| <p> |
| Tests that proper (and different) styles are returned for body elements of main document and iframe. |
| </p> |
| |
| <iframe src="resources/styles-iframe-data.html"></iframe> |
| |
| </body> |
| </html> |