3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/console-test.js"></script>
11 a
.formattableBy1
= true;
12 b
.formattableBy2
= true;
13 c
.formattableBy1
= true;
14 c
.formattableBy2
= true;
19 if (!x
.formattableBy1
)
22 return ["span", {}, "Header formatted by 1 ", x
.name
];
32 return ["span", {}, "Body formatted by 1 ", x
.name
]
39 if (!x
.formattableBy2
)
42 return ["span", {}, "Header formatted by 2 ", x
.name
];
52 return ["span", {}, "Body formatted by 2 ", x
.name
]
57 var formatterWithConfig1
= {
58 header: function(x
, config
)
60 if (x
!== configTest
|| config
)
63 return ["span", {}, "Formatter with config ", ["object", {"object": x
, "config": {"info": "additional info"}}]];
77 var formatterWithConfig2
= {
78 header: function(x
, config
)
80 if (x
!== configTest
|| !config
)
83 return ["span", {}, "Header ", "info: ", config
.info
];
86 hasBody: function(x
, config
)
88 return config
&& config
.info
;
91 body: function(x
, config
)
93 return ["span", {}, "body", "info: ", config
.info
]
97 var selfReferenceTest
= {};
98 var selfReferencingFormatter
= {
101 if (x
!== selfReferenceTest
)
104 return ["span", {}, "Formatter with config ", ["object", {"object": x
}]];
119 window
.devtoolsFormatters
= [formatter1
, formatter2
, formatterWithConfig1
, formatterWithConfig2
, selfReferencingFormatter
];
126 console
.log(configTest
);
127 console
.log(selfReferenceTest
);
128 //swap first formatters: test that header+body should be generated by the same formatter
129 window
.devtoolsFormatters
= [formatter2
, formatter1
, formatterWithConfig1
, formatterWithConfig2
, selfReferencingFormatter
];
134 InspectorTest
.mainTarget
.runtimeAgent().setCustomObjectFormatterEnabled(true);
135 InspectorTest
.evaluateInPage("logVars()", expandVariablesInConsole
);
137 function expandVariablesInConsole()
139 var consoleView
= WebInspector
.ConsolePanel
._view();
140 if (consoleView
._needsFullUpdate
)
141 consoleView
._updateMessageList();
142 var viewMessages
= consoleView
._visibleViewMessages
;
143 for (var i
= 0; i
< viewMessages
.length
; ++i
) {
144 var uiMessage
= viewMessages
[i
];
145 var customElement
= uiMessage
.contentElement().querySelector("span /deep/ .custom-expandable-section-header");
147 customElement
.click();
150 InspectorTest
.runAfterPendingDispatches(dumpExpanded
);
153 function dumpExpanded()
155 InspectorTest
.dumpConsoleMessages();
156 InspectorTest
.completeTest();
162 <body onload=
"runTest()">
163 <p>Tests that console logging dumps properly when there are multiple custom formatters on the page
</p>