Rubber-stamped by Brady Eidson.
[webbrowser.git] / LayoutTests / inspector / styles-iframe.html
blobd40a3cddcd3ab822b941b6e8bb4d6bc048aa2063
1 <html>
2 <head>
4 <style type="text/css" media="screen">
5 body { background:blue; }
6 </style>
8 <script src="inspector-test.js"></script>
9 <script src="elements-tests.js"></script>
10 <script>
12 function runAfterIframeIsLoaded(continuation)
14 function step()
16 if (!window.iframeLoaded)
17 setTimeout(step, 100);
18 else
19 continuation();
21 setTimeout(step, 100);
24 function doit()
26 runAfterIframeIsLoaded(function() {
27 function callback(result)
29 for (var i = 0; i < result.length; ++i) {
30 output("Style: " + i);
31 var matchedRules = result[i].matchedCSSRules;
32 for (var j = 0; matchedRules && j < matchedRules.length; ++j) {
33 output(JSON.stringify(matchedRules[j].style.shorthandValues));
36 notifyDone();
38 evaluateInWebInspector("frontend_dumpStyles", callback);
39 });
43 // Frontend functions.
45 function frontend_dumpStyles(testController)
47 testController.waitUntilDone();
49 frontend_expandDOMSubtree(WebInspector.domAgent.document);
51 testController.runAfterPendingDispatches(function() {
52 frontend_dumpStylesContinuation(testController);
53 });
56 function frontend_dumpStylesContinuation(testController)
58 // 1. Get styles for body, store them in mainStyles var.
59 var bodyId = WebInspector.domAgent.document.body.id;
60 var mainStyles = null;
61 function mainFrameCallback(styles) {
62 mainStyles = styles;
64 InjectedScriptAccess.getStyles(bodyId, false, mainFrameCallback);
66 // 2. Find iframe node
67 var innerMapping = WebInspector.domAgent._idToDOMNode;
68 var iframeBodyId = null;
70 for (var nodeId in innerMapping) {
71 if (innerMapping[nodeId].nodeName === "IFRAME")
72 iframeBodyId = innerMapping[nodeId].firstChild.lastChild.id;
74 if (typeof iframeBodyId !== "number") {
75 testController.notifyDone(["No iframe node found"]);
76 return;
79 // 3. Get styles for iframe's body, return them together with main styles.
80 function iframeCallback(styles) {
81 testController.notifyDone([mainStyles, styles]);
83 InjectedScriptAccess.getStyles(iframeBodyId, false, iframeCallback);
86 </script>
87 </head>
89 <body onload="onload()">
90 <p>
91 Tests that proper (and different) styles are returned for body elements of main document and iframe.
92 </p>
94 <iframe src="resources/styles-iframe-data.html"></iframe>
96 </body>
97 </html>