4 <style type=
"text/css" media=
"screen">
5 body { background:blue; }
8 <script src=
"inspector-test.js"></script>
9 <script src=
"elements-tests.js"></script>
12 function runAfterIframeIsLoaded(continuation
)
16 if (!window
.iframeLoaded
)
17 setTimeout(step
, 100);
21 setTimeout(step
, 100);
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
));
38 evaluateInWebInspector("frontend_dumpStyles", callback
);
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
);
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
) {
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"]);
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
);
89 <body onload=
"onload()">
91 Tests that proper (and different) styles are returned for body elements of main document and iframe.
94 <iframe src=
"resources/styles-iframe-data.html"></iframe>