browser/devtools/webconsole/test/browser_console_log_inspectable_object.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 // Test that objects given to console.log() are inspectable.
michael@0 6
michael@0 7 function test()
michael@0 8 {
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 addTab("data:text/html;charset=utf8,test for bug 676722 - inspectable objects for window.console");
michael@0 12
michael@0 13 gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
michael@0 14 gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
michael@0 15 openConsole(null, performTest);
michael@0 16 }, true);
michael@0 17 }
michael@0 18
michael@0 19 function performTest(hud)
michael@0 20 {
michael@0 21 hud.jsterm.clearOutput(true);
michael@0 22
michael@0 23 hud.jsterm.execute("myObj = {abba: 'omgBug676722'}");
michael@0 24 hud.jsterm.execute("console.log('fooBug676722', myObj)");
michael@0 25
michael@0 26 waitForMessages({
michael@0 27 webconsole: hud,
michael@0 28 messages: [{
michael@0 29 text: "fooBug676722",
michael@0 30 category: CATEGORY_WEBDEV,
michael@0 31 severity: SEVERITY_LOG,
michael@0 32 objects: true,
michael@0 33 }],
michael@0 34 }).then(([result]) => {
michael@0 35 let msg = [...result.matched][0];
michael@0 36 ok(msg, "message element");
michael@0 37 let body = msg.querySelector(".message-body");
michael@0 38 ok(body, "message body");
michael@0 39 let clickable = result.clickableElements[0];
michael@0 40 ok(clickable, "the console.log() object anchor was found");
michael@0 41 ok(body.textContent.contains('{ abba: "omgBug676722" }'),
michael@0 42 "clickable node content is correct");
michael@0 43
michael@0 44 hud.jsterm.once("variablesview-fetched",
michael@0 45 (aEvent, aVar) => {
michael@0 46 ok(aVar, "object inspector opened on click");
michael@0 47
michael@0 48 findVariableViewProperties(aVar, [{
michael@0 49 name: "abba",
michael@0 50 value: "omgBug676722",
michael@0 51 }], { webconsole: hud }).then(finishTest);
michael@0 52 });
michael@0 53
michael@0 54 executeSoon(function() {
michael@0 55 EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
michael@0 56 });
michael@0 57 });
michael@0 58 }

mercurial